From 199f832c8f79b9bbd09277ccca584ab6bcb65759 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 22 Jun 2021 01:09:08 +0000 Subject: [PATCH 1/2] chore: remove all monolith Bazel deps chore: release gapic-generator-csharp v1.3.7 chore: release gapic-generator-go 0.20.5 chore: release gapic-generator-java 1.0.14 chore: release gapic-generator-php 1.0.1 chore: release gapic-generator-python 0.50.0 chore: update gapic-generator-ruby to the latest commit chore: release gapic-generator-typescript 1.5.0 Committer: @miraleung PiperOrigin-RevId: 380641501 Source-Link: https://github.com/googleapis/googleapis/commit/076f7e9f0b258bdb54338895d7251b202e8f0de3 Source-Link: https://github.com/googleapis/googleapis-gen/commit/27e4c88b4048e5f56508d4e1aa417d60a3380892 --- owl-bot-staging/v1/.eslintignore | 6 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 10 + owl-bot-staging/v1/package.json | 65 + .../v1/containeranalysis.proto | 162 ++ .../v1/protos/grafeas/v1/attestation.proto | 73 + .../v1/protos/grafeas/v1/build.proto | 50 + .../v1/protos/grafeas/v1/common.proto | 103 + .../v1/protos/grafeas/v1/cvss.proto | 85 + .../v1/protos/grafeas/v1/deployment.proto | 66 + .../v1/protos/grafeas/v1/discovery.proto | 83 + .../v1/protos/grafeas/v1/grafeas.proto | 531 +++++ .../v1/protos/grafeas/v1/image.proto | 83 + .../v1/protos/grafeas/v1/package.proto | 124 ++ .../v1/protos/grafeas/v1/provenance.proto | 265 +++ .../v1/protos/grafeas/v1/upgrade.proto | 114 + .../v1/protos/grafeas/v1/vulnerability.proto | 226 ++ owl-bot-staging/v1/src/index.ts | 27 + .../v1/src/v1/container_analysis_client.ts | 731 +++++++ .../v1/container_analysis_client_config.json | 42 + .../src/v1/container_analysis_proto_list.json | 15 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 229 ++ owl-bot-staging/v1/src/v1/grafeas_client.ts | 1795 ++++++++++++++++ .../v1/src/v1/grafeas_client_config.json | 82 + .../v1/src/v1/grafeas_proto_list.json | 15 + owl-bot-staging/v1/src/v1/index.ts | 20 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + owl-bot-staging/v1/system-test/install.ts | 49 + .../v1/test/gapic_container_analysis_v1.ts | 565 +++++ owl-bot-staging/v1/test/gapic_grafeas_v1.ts | 1866 ++++++++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1beta1/.eslintignore | 6 + owl-bot-staging/v1beta1/.eslintrc.json | 3 + owl-bot-staging/v1beta1/.gitignore | 14 + owl-bot-staging/v1beta1/.jsdoc.js | 55 + owl-bot-staging/v1beta1/.mocharc.js | 33 + owl-bot-staging/v1beta1/.prettierrc.js | 22 + owl-bot-staging/v1beta1/README.md | 1 + .../v1beta1/linkinator.config.json | 10 + owl-bot-staging/v1beta1/package.json | 65 + .../v1beta1/attestation/attestation.proto | 170 ++ .../v1beta1/common/common.proto | 101 + .../v1beta1/containeranalysis.proto | 219 ++ .../containeranalysis/v1beta1/cvss/cvss.proto | 85 + .../v1beta1/deployment/deployment.proto | 74 + .../v1beta1/discovery/discovery.proto | 86 + .../v1beta1/grafeas/grafeas.proto | 506 +++++ .../v1beta1/image/image.proto | 145 ++ .../v1beta1/package/package.proto | 127 ++ .../v1beta1/provenance/provenance.proto | 164 ++ .../v1beta1/source/source.proto | 134 ++ .../v1beta1/vulnerability/vulnerability.proto | 203 ++ owl-bot-staging/v1beta1/src/index.ts | 27 + .../container_analysis_v1_beta1_client.ts | 959 +++++++++ ...ainer_analysis_v1_beta1_client_config.json | 50 + ...ontainer_analysis_v1_beta1_proto_list.json | 15 + .../v1beta1/src/v1beta1/gapic_metadata.json | 263 +++ .../src/v1beta1/grafeas_v1_beta1_client.ts | 1800 ++++++++++++++++ .../grafeas_v1_beta1_client_config.json | 86 + .../v1beta1/grafeas_v1_beta1_proto_list.json | 15 + owl-bot-staging/v1beta1/src/v1beta1/index.ts | 20 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1beta1/system-test/install.ts | 49 + ...pic_container_analysis_v1_beta1_v1beta1.ts | 880 ++++++++ .../test/gapic_grafeas_v1_beta1_v1beta1.ts | 1882 +++++++++++++++++ owl-bot-staging/v1beta1/tsconfig.json | 19 + owl-bot-staging/v1beta1/webpack.config.js | 64 + 75 files changed, 16177 insertions(+) create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/devtools/containeranalysis/v1/containeranalysis.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/attestation.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/build.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/common.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/cvss.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/deployment.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/discovery.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/grafeas.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/image.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/package.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/provenance.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/upgrade.proto create mode 100644 owl-bot-staging/v1/protos/grafeas/v1/vulnerability.proto create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/container_analysis_client.ts create mode 100644 owl-bot-staging/v1/src/v1/container_analysis_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/container_analysis_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/grafeas_client.ts create mode 100644 owl-bot-staging/v1/src/v1/grafeas_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/grafeas_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_container_analysis_v1.ts create mode 100644 owl-bot-staging/v1/test/gapic_grafeas_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js create mode 100644 owl-bot-staging/v1beta1/.eslintignore create mode 100644 owl-bot-staging/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1beta1/.gitignore create mode 100644 owl-bot-staging/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1beta1/README.md create mode 100644 owl-bot-staging/v1beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1beta1/package.json create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/common/common.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/image/image.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/package/package.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/source/source.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto create mode 100644 owl-bot-staging/v1beta1/src/index.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client_config.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_proto_list.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client_config.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_proto_list.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1beta1/test/gapic_container_analysis_v1_beta1_v1beta1.ts create mode 100644 owl-bot-staging/v1beta1/test/gapic_grafeas_v1_beta1_v1beta1.ts create mode 100644 owl-bot-staging/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/v1beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 0000000..521dc25 --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,6 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 0000000..7821534 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 0000000..5d32b23 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 0000000..cb937ac --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2021 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/containeranalysis', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 0000000..50bc7f7 --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 0000000..84f4713 --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 0000000..dc843b7 --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Containeranalysis: 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..5e3eb9c --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/containeranalysis", + "version": "0.1.0", + "description": "Containeranalysis client for Node.js", + "repository": "googleapis/nodejs-containeranalysis", + "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 containeranalysis", + "containeranalysis", + "container analysis", + "grafeas" + ], + "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.15.0" + }, + "devDependencies": { + "@types/mocha": "^8.2.2", + "@types/node": "^14.17.3", + "@types/sinon": "^10.0.2", + "c8": "^7.7.3", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.0", + "jsdoc-region-tag": "^1.1.0", + "linkinator": "^2.13.6", + "mocha": "^8.4.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.1", + "ts-loader": "^9.2.3", + "typescript": "^4.3.4", + "webpack": "^5.39.1", + "webpack-cli": "^4.7.2" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1/protos/google/devtools/containeranalysis/v1/containeranalysis.proto b/owl-bot-staging/v1/protos/google/devtools/containeranalysis/v1/containeranalysis.proto new file mode 100644 index 0000000..2bd968c --- /dev/null +++ b/owl-bot-staging/v1/protos/google/devtools/containeranalysis/v1/containeranalysis.proto @@ -0,0 +1,162 @@ +// 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.devtools.containeranalysis.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/protobuf/timestamp.proto"; +import "grafeas/v1/vulnerability.proto"; + +option csharp_namespace = "Google.Cloud.DevTools.ContainerAnalysis.V1"; +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1;containeranalysis"; +option java_multiple_files = true; +option java_package = "com.google.containeranalysis.v1"; +option objc_class_prefix = "GCA"; +option ruby_package = "Google::Cloud::ContainerAnalysis::V1"; +option php_namespace = "Google\\Cloud\\ContainerAnalysis\\V1"; + +// Retrieves analysis results of Cloud components such as Docker container +// images. The Container Analysis API is an implementation of the +// [Grafeas](https://grafeas.io) API. +// +// Analysis results are stored as a series of occurrences. An `Occurrence` +// contains information about a specific analysis instance on a resource. An +// occurrence refers to a `Note`. A note contains details describing the +// analysis and is generally stored in a separate project, called a `Provider`. +// Multiple occurrences can refer to the same note. +// +// For example, an SSL vulnerability could affect multiple images. In this case, +// there would be one note for the vulnerability and an occurrence for each +// image with the vulnerability referring to that note. +service ContainerAnalysis { + option (google.api.default_host) = "containeranalysis.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Sets the access control policy on the specified note or occurrence. + // Requires `containeranalysis.notes.setIamPolicy` or + // `containeranalysis.occurrences.setIamPolicy` permission if the resource is + // a note or an occurrence, respectively. + // + // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + // occurrences. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/notes/*}:setIamPolicy" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*/occurrences/*}:setIamPolicy" + body: "*" + } + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Gets the access control policy for a note or an occurrence resource. + // Requires `containeranalysis.notes.setIamPolicy` or + // `containeranalysis.occurrences.setIamPolicy` permission if the resource is + // a note or occurrence, respectively. + // + // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + // occurrences. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/notes/*}:getIamPolicy" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*/occurrences/*}:getIamPolicy" + body: "*" + } + }; + option (google.api.method_signature) = "resource"; + } + + // Returns the permissions that a caller has on the specified note or + // occurrence. Requires list permission on the project (for example, + // `containeranalysis.notes.list`). + // + // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + // occurrences. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/notes/*}:testIamPermissions" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*/occurrences/*}:testIamPermissions" + body: "*" + } + }; + option (google.api.method_signature) = "resource,permissions"; + } + + // Gets a summary of the number and severity of occurrences. + rpc GetVulnerabilityOccurrencesSummary( + GetVulnerabilityOccurrencesSummaryRequest) + returns (VulnerabilityOccurrencesSummary) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/occurrences:vulnerabilitySummary" + }; + option (google.api.method_signature) = "parent,filter"; + } +} + +// Request to get a vulnerability summary for some set of occurrences. +message GetVulnerabilityOccurrencesSummaryRequest { + // The name of the project to get a vulnerability summary for in the form of + // `projects/[PROJECT_ID]`. + string parent = 1 [ + (google.api.resource_reference).type = + "cloudresourcemanager.googleapis.com/Project", + (google.api.field_behavior) = REQUIRED + ]; + + // The filter expression. + string filter = 2; +} + +// A summary of how many vulnerability occurrences there are per resource and +// severity type. +message VulnerabilityOccurrencesSummary { + // Per resource and severity counts of fixable and total vulnerabilities. + message FixableTotalByDigest { + // The affected resource. + string resource_uri = 1; + + // The severity for this count. SEVERITY_UNSPECIFIED indicates total across + // all severities. + grafeas.v1.Severity severity = 2; + + // The number of fixable vulnerabilities associated with this resource. + int64 fixable_count = 3; + + // The total number of vulnerabilities associated with this resource. + int64 total_count = 4; + } + + // A listing by resource of the number of fixable and total vulnerabilities. + repeated FixableTotalByDigest counts = 1; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/attestation.proto b/owl-bot-staging/v1/protos/grafeas/v1/attestation.proto new file mode 100644 index 0000000..61423d3 --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/attestation.proto @@ -0,0 +1,73 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +import "grafeas/v1/common.proto"; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// An attestation wrapper with a PGP-compatible signature. This message only +// supports `ATTACHED` signatures, where the payload that is signed is included +// alongside the signature itself in the same file. + +// Note kind that represents a logical attestation "role" or "authority". For +// example, an organization might have one `Authority` for "QA" and one for +// "build". This note is intended to act strictly as a grouping mechanism for +// the attached occurrences (Attestations). This grouping mechanism also +// provides a security boundary, since IAM ACLs gate the ability for a principle +// to attach an occurrence to a given note. It also provides a single point of +// lookup to find all attached attestation occurrences, even if they don't all +// live in the same project. +message AttestationNote { + // This submessage provides human-readable hints about the purpose of the + // authority. Because the name of a note acts as its resource reference, it is + // important to disambiguate the canonical name of the Note (which might be a + // UUID for security purposes) from "readable" names more suitable for debug + // output. Note that these hints should not be used to look up authorities in + // security sensitive contexts, such as when looking up attestations to + // verify. + message Hint { + // Required. The human readable name of this attestation authority, for + // example "qa". + string human_readable_name = 1; + } + + // Hint hints at the purpose of the attestation authority. + Hint hint = 1; +} + +// Occurrence that represents a single "attestation". The authenticity of an +// attestation can be verified using the attached signature. If the verifier +// trusts the public key of the signer, then verifying the signature is +// sufficient to establish trust. In this circumstance, the authority to which +// this attestation is attached is primarily useful for lookup (how to find +// this attestation if you already know the authority and artifact to be +// verified) and intent (for which authority this attestation was intended to +// sign. +message AttestationOccurrence { + // Required. The serialized payload that is verified by one or more + // `signatures`. + bytes serialized_payload = 1; + // One or more signatures over `serialized_payload`. Verifier implementations + // should consider this attestation message verified if at least one + // `signature` verifies `serialized_payload`. See `Signature` in common.proto + // for more details on signature structure and verification. + repeated Signature signatures = 2; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/build.proto b/owl-bot-staging/v1/protos/grafeas/v1/build.proto new file mode 100644 index 0000000..c0e9c75 --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/build.proto @@ -0,0 +1,50 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +import "grafeas/v1/provenance.proto"; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// Note holding the version of the provider's builder and the signature of the +// provenance message in the build details occurrence. +message BuildNote { + // Required. Immutable. Version of the builder which produced this build. + string builder_version = 1; +} + +// Details of a build occurrence. +message BuildOccurrence { + // Required. The actual provenance for the build. + grafeas.v1.BuildProvenance provenance = 1; + + // Serialized JSON representation of the provenance, used in generating the + // build signature in the corresponding build note. After verifying the + // signature, `provenance_bytes` can be unmarshalled and compared to the + // provenance to confirm that it is unchanged. A base64-encoded string + // representation of the provenance bytes is used for the signature in order + // to interoperate with openssl which expects this format for signature + // verification. + // + // The serialized form is captured both to avoid ambiguity in how the + // provenance is marshalled to json as well to prevent incompatibilities with + // future changes. + string provenance_bytes = 2; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/common.proto b/owl-bot-staging/v1/protos/grafeas/v1/common.proto new file mode 100644 index 0000000..db780bb --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/common.proto @@ -0,0 +1,103 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// Kind represents the kinds of notes supported. +enum NoteKind { + // Unknown. + NOTE_KIND_UNSPECIFIED = 0; + // The note and occurrence represent a package vulnerability. + VULNERABILITY = 1; + // The note and occurrence assert build provenance. + BUILD = 2; + // This represents an image basis relationship. + IMAGE = 3; + // This represents a package installed via a package manager. + PACKAGE = 4; + // The note and occurrence track deployment events. + DEPLOYMENT = 5; + // The note and occurrence track the initial discovery status of a resource. + DISCOVERY = 6; + // This represents a logical "role" that can attest to artifacts. + ATTESTATION = 7; + // This represents an available package upgrade. + UPGRADE = 8; +} + +// Metadata for any related URL information. +message RelatedUrl { + // Specific URL associated with the resource. + string url = 1; + // Label to describe usage of the URL. + string label = 2; +} + +// Verifiers (e.g. Kritis implementations) MUST verify signatures +// with respect to the trust anchors defined in policy (e.g. a Kritis policy). +// Typically this means that the verifier has been configured with a map from +// `public_key_id` to public key material (and any required parameters, e.g. +// signing algorithm). +// +// In particular, verification implementations MUST NOT treat the signature +// `public_key_id` as anything more than a key lookup hint. The `public_key_id` +// DOES NOT validate or authenticate a public key; it only provides a mechanism +// for quickly selecting a public key ALREADY CONFIGURED on the verifier through +// a trusted channel. Verification implementations MUST reject signatures in any +// of the following circumstances: +// * The `public_key_id` is not recognized by the verifier. +// * The public key that `public_key_id` refers to does not verify the +// signature with respect to the payload. +// +// The `signature` contents SHOULD NOT be "attached" (where the payload is +// included with the serialized `signature` bytes). Verifiers MUST ignore any +// "attached" payload and only verify signatures with respect to explicitly +// provided payload (e.g. a `payload` field on the proto message that holds +// this Signature, or the canonical serialization of the proto message that +// holds this signature). +message Signature { + // The content of the signature, an opaque bytestring. + // The payload that this signature verifies MUST be unambiguously provided + // with the Signature during verification. A wrapper message might provide + // the payload explicitly. Alternatively, a message might have a canonical + // serialization that can always be unambiguously computed to derive the + // payload. + bytes signature = 1; + + // The identifier for the public key that verifies this signature. + // * The `public_key_id` is required. + // * The `public_key_id` MUST be an RFC3986 conformant URI. + // * When possible, the `public_key_id` SHOULD be an immutable reference, + // such as a cryptographic digest. + // + // Examples of valid `public_key_id`s: + // + // OpenPGP V4 public key fingerprint: + // * "openpgp4fpr:74FAF3B861BDA0870C7B6DEF607E48D2A663AEEA" + // See https://www.iana.org/assignments/uri-schemes/prov/openpgp4fpr for more + // details on this scheme. + // + // RFC6920 digest-named SubjectPublicKeyInfo (digest of the DER + // serialization): + // * "ni:///sha-256;cD9o9Cq6LG3jD0iKXqEi_vdjJGecm_iXkbqVoScViaU" + // * "nih:///sha-256;703f68f42aba2c6de30f488a5ea122fef76324679c9bf89791ba95a1271589a5" + string public_key_id = 2; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/cvss.proto b/owl-bot-staging/v1/protos/grafeas/v1/cvss.proto new file mode 100644 index 0000000..b41cd63 --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/cvss.proto @@ -0,0 +1,85 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// Common Vulnerability Scoring System version 3. +// For details, see https://www.first.org/cvss/specification-document +message CVSSv3 { + // The base score is a function of the base metric scores. + float base_score = 1; + + float exploitability_score = 2; + + float impact_score = 3; + + // Base Metrics + // Represents the intrinsic characteristics of a vulnerability that are + // constant over time and across user environments. + AttackVector attack_vector = 5; + AttackComplexity attack_complexity = 6; + PrivilegesRequired privileges_required = 7; + UserInteraction user_interaction = 8; + Scope scope = 9; + Impact confidentiality_impact = 10; + Impact integrity_impact = 11; + Impact availability_impact = 12; + + enum AttackVector { + ATTACK_VECTOR_UNSPECIFIED = 0; + ATTACK_VECTOR_NETWORK = 1; + ATTACK_VECTOR_ADJACENT = 2; + ATTACK_VECTOR_LOCAL = 3; + ATTACK_VECTOR_PHYSICAL = 4; + } + + enum AttackComplexity { + ATTACK_COMPLEXITY_UNSPECIFIED = 0; + ATTACK_COMPLEXITY_LOW = 1; + ATTACK_COMPLEXITY_HIGH = 2; + } + + enum PrivilegesRequired { + PRIVILEGES_REQUIRED_UNSPECIFIED = 0; + PRIVILEGES_REQUIRED_NONE = 1; + PRIVILEGES_REQUIRED_LOW = 2; + PRIVILEGES_REQUIRED_HIGH = 3; + } + + enum UserInteraction { + USER_INTERACTION_UNSPECIFIED = 0; + USER_INTERACTION_NONE = 1; + USER_INTERACTION_REQUIRED = 2; + } + + enum Scope { + SCOPE_UNSPECIFIED = 0; + SCOPE_UNCHANGED = 1; + SCOPE_CHANGED = 2; + } + + enum Impact { + IMPACT_UNSPECIFIED = 0; + IMPACT_HIGH = 1; + IMPACT_LOW = 2; + IMPACT_NONE = 3; + } +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/deployment.proto b/owl-bot-staging/v1/protos/grafeas/v1/deployment.proto new file mode 100644 index 0000000..5204004 --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/deployment.proto @@ -0,0 +1,66 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// An artifact that can be deployed in some runtime. +message DeploymentNote { + // Required. Resource URI for the artifact being deployed. + repeated string resource_uri = 1; +} + +// The period during which some deployable was active in a runtime. +message DeploymentOccurrence { + // Identity of the user that triggered this deployment. + string user_email = 1; + + // Required. Beginning of the lifetime of this deployment. + google.protobuf.Timestamp deploy_time = 2; + + // End of the lifetime of this deployment. + google.protobuf.Timestamp undeploy_time = 3; + + // Configuration used to create this deployment. + string config = 4; + + // Address of the runtime element hosting this deployment. + string address = 5; + + // Output only. Resource URI for the artifact being deployed taken from + // the deployable field with the same name. + repeated string resource_uri = 6; + + // Types of platforms. + enum Platform { + // Unknown. + PLATFORM_UNSPECIFIED = 0; + // Google Container Engine. + GKE = 1; + // Google App Engine: Flexible Environment. + FLEX = 2; + // Custom user-defined platform. + CUSTOM = 3; + } + // Platform hosting this deployment. + Platform platform = 7; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/discovery.proto b/owl-bot-staging/v1/protos/grafeas/v1/discovery.proto new file mode 100644 index 0000000..e079925 --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/discovery.proto @@ -0,0 +1,83 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "grafeas/v1/common.proto"; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// A note that indicates a type of analysis a provider would perform. This note +// exists in a provider's project. A `Discovery` occurrence is created in a +// consumer's project at the start of analysis. +message DiscoveryNote { + // Required. Immutable. The kind of analysis that is handled by this + // discovery. + grafeas.v1.NoteKind analysis_kind = 1; +} + +// Provides information about the analysis status of a discovered resource. +message DiscoveryOccurrence { + // Whether the resource is continuously analyzed. + enum ContinuousAnalysis { + // Unknown. + CONTINUOUS_ANALYSIS_UNSPECIFIED = 0; + // The resource is continuously analyzed. + ACTIVE = 1; + // The resource is ignored for continuous analysis. + INACTIVE = 2; + } + + // Whether the resource is continuously analyzed. + ContinuousAnalysis continuous_analysis = 1; + + // Analysis status for a resource. Currently for initial analysis only (not + // updated in continuous analysis). + enum AnalysisStatus { + // Unknown. + ANALYSIS_STATUS_UNSPECIFIED = 0; + // Resource is known but no action has been taken yet. + PENDING = 1; + // Resource is being analyzed. + SCANNING = 2; + // Analysis has finished successfully. + FINISHED_SUCCESS = 3; + // Analysis has finished unsuccessfully, the analysis itself is in a bad + // state. + FINISHED_FAILED = 4; + // The resource is known not to be supported + FINISHED_UNSUPPORTED = 5; + } + + // The status of discovery for the resource. + AnalysisStatus analysis_status = 2; + + // When an error is encountered this will contain a LocalizedMessage under + // details to show to the user. The LocalizedMessage is output only and + // populated by the API. + google.rpc.Status analysis_status_error = 3; + + // The CPE of the resource being scanned. + string cpe = 4; + + // The last time this resource was scanned. + google.protobuf.Timestamp last_scan_time = 5; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/grafeas.proto b/owl-bot-staging/v1/protos/grafeas/v1/grafeas.proto new file mode 100644 index 0000000..57b2fc2 --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/grafeas.proto @@ -0,0 +1,531 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "grafeas/v1/attestation.proto"; +import "grafeas/v1/build.proto"; +import "grafeas/v1/common.proto"; +import "grafeas/v1/deployment.proto"; +import "grafeas/v1/discovery.proto"; +import "grafeas/v1/image.proto"; +import "grafeas/v1/package.proto"; +import "grafeas/v1/upgrade.proto"; +import "grafeas/v1/vulnerability.proto"; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; +option (google.api.resource_definition) = { + type: "grafeas.io/Project" + pattern: "projects/{project}" +}; + +// [Grafeas](https://grafeas.io) API. +// +// Retrieves analysis results of Cloud components such as Docker container +// images. +// +// Analysis results are stored as a series of occurrences. An `Occurrence` +// contains information about a specific analysis instance on a resource. An +// occurrence refers to a `Note`. A note contains details describing the +// analysis and is generally stored in a separate project, called a `Provider`. +// Multiple occurrences can refer to the same note. +// +// For example, an SSL vulnerability could affect multiple images. In this case, +// there would be one note for the vulnerability and an occurrence for each +// image with the vulnerability referring to that note. +service Grafeas { + option (google.api.default_host) = "containeranalysis.googleapis.com"; + + // Gets the specified occurrence. + rpc GetOccurrence(GetOccurrenceRequest) returns (Occurrence) { + option (google.api.http) = { + get: "/v1/{name=projects/*/occurrences/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists occurrences for the specified project. + rpc ListOccurrences(ListOccurrencesRequest) + returns (ListOccurrencesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/occurrences" + }; + option (google.api.method_signature) = "parent,filter"; + } + + // Deletes the specified occurrence. For example, use this method to delete an + // occurrence when the occurrence is no longer applicable for the given + // resource. + rpc DeleteOccurrence(DeleteOccurrenceRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/occurrences/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new occurrence. + rpc CreateOccurrence(CreateOccurrenceRequest) returns (Occurrence) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/occurrences" + body: "occurrence" + }; + option (google.api.method_signature) = "parent,occurrence"; + } + + // Creates new occurrences in batch. + rpc BatchCreateOccurrences(BatchCreateOccurrencesRequest) + returns (BatchCreateOccurrencesResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/occurrences:batchCreate" + body: "*" + }; + option (google.api.method_signature) = "parent,occurrences"; + } + + // Updates the specified occurrence. + rpc UpdateOccurrence(UpdateOccurrenceRequest) returns (Occurrence) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/occurrences/*}" + body: "occurrence" + }; + option (google.api.method_signature) = "name,occurrence,update_mask"; + } + + // Gets the note attached to the specified occurrence. Consumer projects can + // use this method to get a note that belongs to a provider project. + rpc GetOccurrenceNote(GetOccurrenceNoteRequest) returns (Note) { + option (google.api.http) = { + get: "/v1/{name=projects/*/occurrences/*}/notes" + }; + option (google.api.method_signature) = "name"; + } + + // Gets the specified note. + rpc GetNote(GetNoteRequest) returns (Note) { + option (google.api.http) = { + get: "/v1/{name=projects/*/notes/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists notes for the specified project. + rpc ListNotes(ListNotesRequest) returns (ListNotesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/notes" + }; + option (google.api.method_signature) = "parent,filter"; + } + + // Deletes the specified note. + rpc DeleteNote(DeleteNoteRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/notes/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new note. + rpc CreateNote(CreateNoteRequest) returns (Note) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/notes" + body: "note" + }; + option (google.api.method_signature) = "parent,note_id,note"; + } + + // Creates new notes in batch. + rpc BatchCreateNotes(BatchCreateNotesRequest) + returns (BatchCreateNotesResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/notes:batchCreate" + body: "*" + }; + option (google.api.method_signature) = "parent,notes"; + } + + // Updates the specified note. + rpc UpdateNote(UpdateNoteRequest) returns (Note) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/notes/*}" + body: "note" + }; + option (google.api.method_signature) = "name,note,update_mask"; + } + + // Lists occurrences referencing the specified note. Provider projects can use + // this method to get all occurrences across consumer projects referencing the + // specified note. + rpc ListNoteOccurrences(ListNoteOccurrencesRequest) + returns (ListNoteOccurrencesResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*/notes/*}/occurrences" + }; + option (google.api.method_signature) = "name,filter"; + } +} + +// An instance of an analysis type that has been found on a resource. +message Occurrence { + option (google.api.resource) = { + type: "grafeas.io/Occurrence" + pattern: "projects/{project}/occurrences/{occurrence}" + }; + + // Output only. The name of the occurrence in the form of + // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + string name = 1; + + // Required. Immutable. A URI that represents the resource for which the + // occurrence applies. For example, + // `https://gcr.io/project/image@sha256:123abc` for a Docker image. + string resource_uri = 2; + + // Required. Immutable. The analysis note associated with this occurrence, in + // the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. This field can be + // used as a filter in list requests. + string note_name = 3; + + // Output only. This explicitly denotes which of the occurrence details are + // specified. This field can be used as a filter in list requests. + grafeas.v1.NoteKind kind = 4; + + // A description of actions that can be taken to remedy the note. + string remediation = 5; + + // Output only. The time this occurrence was created. + google.protobuf.Timestamp create_time = 6; + + // Output only. The time this occurrence was last updated. + google.protobuf.Timestamp update_time = 7; + + // Required. Immutable. Describes the details of the note kind found on this + // resource. + oneof details { + // Describes a security vulnerability. + grafeas.v1.VulnerabilityOccurrence vulnerability = 8; + // Describes a verifiable build. + grafeas.v1.BuildOccurrence build = 9; + // Describes how this resource derives from the basis in the associated + // note. + grafeas.v1.ImageOccurrence image = 10; + // Describes the installation of a package on the linked resource. + grafeas.v1.PackageOccurrence package = 11; + // Describes the deployment of an artifact on a runtime. + grafeas.v1.DeploymentOccurrence deployment = 12; + // Describes when a resource was discovered. + grafeas.v1.DiscoveryOccurrence discovery = 13; + // Describes an attestation of an artifact. + grafeas.v1.AttestationOccurrence attestation = 14; + // Describes an available package upgrade on the linked resource. + grafeas.v1.UpgradeOccurrence upgrade = 15; + } +} + +// A type of analysis that can be done for a resource. +message Note { + option (google.api.resource) = { + type: "grafeas.io/Note" + pattern: "projects/{project}/notes/{note}" + }; + + // Output only. The name of the note in the form of + // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + string name = 1; + + // A one sentence description of this note. + string short_description = 2; + + // A detailed description of this note. + string long_description = 3; + + // Output only. The type of analysis. This field can be used as a filter in + // list requests. + grafeas.v1.NoteKind kind = 4; + + // URLs associated with this note. + repeated grafeas.v1.RelatedUrl related_url = 5; + + // Time of expiration for this note. Empty if note does not expire. + google.protobuf.Timestamp expiration_time = 6; + + // Output only. The time this note was created. This field can be used as a + // filter in list requests. + google.protobuf.Timestamp create_time = 7; + + // Output only. The time this note was last updated. This field can be used as + // a filter in list requests. + google.protobuf.Timestamp update_time = 8; + + // Other notes related to this note. + repeated string related_note_names = 9; + + // Required. Immutable. The type of analysis this note represents. + oneof type { + // A note describing a package vulnerability. + grafeas.v1.VulnerabilityNote vulnerability = 10; + // A note describing build provenance for a verifiable build. + grafeas.v1.BuildNote build = 11; + // A note describing a base image. + grafeas.v1.ImageNote image = 12; + // A note describing a package hosted by various package managers. + grafeas.v1.PackageNote package = 13; + // A note describing something that can be deployed. + grafeas.v1.DeploymentNote deployment = 14; + // A note describing the initial analysis of a resource. + grafeas.v1.DiscoveryNote discovery = 15; + // A note describing an attestation role. + grafeas.v1.AttestationNote attestation = 16; + // A note describing available package upgrades. + grafeas.v1.UpgradeNote upgrade = 17; + } +} + +// Request to get an occurrence. +message GetOccurrenceRequest { + // The name of the occurrence in the form of + // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Occurrence" + ]; +} + +// Request to list occurrences. +message ListOccurrencesRequest { + // The name of the project to list occurrences for in the form of + // `projects/[PROJECT_ID]`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Project" + ]; + + // The filter expression. + string filter = 2; + + // Number of occurrences to return in the list. Must be positive. Max allowed + // page size is 1000. If not specified, page size defaults to 20. + int32 page_size = 3; + + // Token to provide to skip to a particular spot in the list. + string page_token = 4; +} + +// Response for listing occurrences. +message ListOccurrencesResponse { + // The occurrences requested. + repeated Occurrence occurrences = 1; + // The next pagination token in the list response. It should be used as + // `page_token` for the following request. An empty value means no more + // results. + string next_page_token = 2; +} + +// Request to delete an occurrence. +message DeleteOccurrenceRequest { + // The name of the occurrence in the form of + // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Occurrence" + ]; +} + +// Request to create a new occurrence. +message CreateOccurrenceRequest { + // The name of the project in the form of `projects/[PROJECT_ID]`, under which + // the occurrence is to be created. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Project" + ]; + // The occurrence to create. + Occurrence occurrence = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request to update an occurrence. +message UpdateOccurrenceRequest { + // The name of the occurrence in the form of + // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Occurrence" + ]; + // The updated occurrence. + Occurrence occurrence = 2 [(google.api.field_behavior) = REQUIRED]; + // The fields to update. + google.protobuf.FieldMask update_mask = 3; +} + +// Request to get a note. +message GetNoteRequest { + // The name of the note in the form of + // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Note" + ]; +} + +// Request to get the note to which the specified occurrence is attached. +message GetOccurrenceNoteRequest { + // The name of the occurrence in the form of + // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Occurrence" + ]; +} + +// Request to list notes. +message ListNotesRequest { + // The name of the project to list notes for in the form of + // `projects/[PROJECT_ID]`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Project" + ]; + + // The filter expression. + string filter = 2; + + // Number of notes to return in the list. Must be positive. Max allowed page + // size is 1000. If not specified, page size defaults to 20. + int32 page_size = 3; + + // Token to provide to skip to a particular spot in the list. + string page_token = 4; +} + +// Response for listing notes. +message ListNotesResponse { + // The notes requested. + repeated Note notes = 1; + // The next pagination token in the list response. It should be used as + // `page_token` for the following request. An empty value means no more + // results. + string next_page_token = 2; +} + +// Request to delete a note. +message DeleteNoteRequest { + // The name of the note in the form of + // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Note" + ]; +} + +// Request to create a new note. +message CreateNoteRequest { + // The name of the project in the form of `projects/[PROJECT_ID]`, under which + // the note is to be created. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Project" + ]; + // The ID to use for this note. + string note_id = 2 [(google.api.field_behavior) = REQUIRED]; + // The note to create. + Note note = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request to update a note. +message UpdateNoteRequest { + // The name of the note in the form of + // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Note" + ]; + // The updated note. + Note note = 2 [(google.api.field_behavior) = REQUIRED]; + // The fields to update. + google.protobuf.FieldMask update_mask = 3; +} + +// Request to list occurrences for a note. +message ListNoteOccurrencesRequest { + // The name of the note to list occurrences for in the form of + // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Note" + ]; + // The filter expression. + string filter = 2; + // Number of occurrences to return in the list. + int32 page_size = 3; + // Token to provide to skip to a particular spot in the list. + string page_token = 4; +} + +// Response for listing occurrences for a note. +message ListNoteOccurrencesResponse { + // The occurrences attached to the specified note. + repeated Occurrence occurrences = 1; + // Token to provide to skip to a particular spot in the list. + string next_page_token = 2; +} + +// Request to create notes in batch. +message BatchCreateNotesRequest { + // The name of the project in the form of `projects/[PROJECT_ID]`, under which + // the notes are to be created. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Project" + ]; + + // The notes to create. Max allowed length is 1000. + map notes = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response for creating notes in batch. +message BatchCreateNotesResponse { + // The notes that were created. + repeated Note notes = 1; +} + +// Request to create occurrences in batch. +message BatchCreateOccurrencesRequest { + // The name of the project in the form of `projects/[PROJECT_ID]`, under which + // the occurrences are to be created. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "grafeas.io/Project" + ]; + + // The occurrences to create. Max allowed length is 1000. + repeated Occurrence occurrences = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response for creating occurrences in batch. +message BatchCreateOccurrencesResponse { + // The occurrences that were created. + repeated Occurrence occurrences = 1; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/image.proto b/owl-bot-staging/v1/protos/grafeas/v1/image.proto new file mode 100644 index 0000000..9ac162c --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/image.proto @@ -0,0 +1,83 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// Layer holds metadata specific to a layer of a Docker image. +message Layer { + // Required. The recovered Dockerfile directive used to construct this layer. + // See https://docs.docker.com/engine/reference/builder/ for more information. + string directive = 1; + + // The recovered arguments to the Dockerfile directive. + string arguments = 2; +} + +// A set of properties that uniquely identify a given Docker image. +message Fingerprint { + // Required. The layer ID of the final layer in the Docker image's v1 + // representation. + string v1_name = 1; + + // Required. The ordered list of v2 blobs that represent a given image. + repeated string v2_blob = 2; + + // Output only. The name of the image's v2 blobs computed via: + // [bottom] := v2_blob[bottom] + // [N] := sha256(v2_blob[N] + " " + v2_name[N+1]) + // Only the name of the final blob is kept. + string v2_name = 3; +} + +// Basis describes the base image portion (Note) of the DockerImage +// relationship. Linked occurrences are derived from this or an equivalent image +// via: +// FROM +// Or an equivalent reference, e.g., a tag of the resource_url. +message ImageNote { + // Required. Immutable. The resource_url for the resource representing the + // basis of associated occurrence images. + string resource_url = 1; + + // Required. Immutable. The fingerprint of the base image. + Fingerprint fingerprint = 2; +} + +// Details of the derived image portion of the DockerImage relationship. This +// image would be produced from a Dockerfile with FROM . +message ImageOccurrence { + // Required. The fingerprint of the derived image. + Fingerprint fingerprint = 1; + + // Output only. The number of layers by which this image differs from the + // associated image basis. + int32 distance = 2; + + // This contains layer-specific metadata, if populated it has length + // "distance" and is ordered with [distance] being the layer immediately + // following the base image and [1] being the final layer. + repeated Layer layer_info = 3; + + // Output only. This contains the base image URL for the derived image + // occurrence. + string base_resource_url = 4; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/package.proto b/owl-bot-staging/v1/protos/grafeas/v1/package.proto new file mode 100644 index 0000000..b04686d --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/package.proto @@ -0,0 +1,124 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// Instruction set architectures supported by various package managers. +enum Architecture { + // Unknown architecture. + ARCHITECTURE_UNSPECIFIED = 0; + // X86 architecture. + X86 = 1; + // X64 architecture. + X64 = 2; +} + +// This represents a particular channel of distribution for a given package. +// E.g., Debian's jessie-backports dpkg mirror. +message Distribution { + // Required. The cpe_uri in [CPE format](https://cpe.mitre.org/specification/) + // denoting the package manager version distributing a package. + string cpe_uri = 1; + + // The CPU architecture for which packages in this distribution channel were + // built. + Architecture architecture = 2; + + // The latest available version of this package in this distribution channel. + Version latest_version = 3; + + // A freeform string denoting the maintainer of this package. + string maintainer = 4; + + // The distribution channel-specific homepage for this package. + string url = 5; + + // The distribution channel-specific description of this package. + string description = 6; +} + +// An occurrence of a particular package installation found within a system's +// filesystem. E.g., glibc was found in `/var/lib/dpkg/status`. +message Location { + // Required. The CPE URI in [CPE format](https://cpe.mitre.org/specification/) + // denoting the package manager version distributing a package. + string cpe_uri = 1; + + // The version installed at this location. + Version version = 2; + + // The path from which we gathered that this package/version is installed. + string path = 3; +} + +// This represents a particular package that is distributed over various +// channels. E.g., glibc (aka libc6) is distributed by many, at various +// versions. +message PackageNote { + // Required. Immutable. The name of the package. + string name = 1; + + // The various channels by which a package is distributed. + repeated Distribution distribution = 10; +} + +// Details on how a particular software package was installed on a system. +message PackageOccurrence { + // Output only. The name of the installed package. + string name = 1; + + // Required. All of the places within the filesystem versions of this package + // have been found. + repeated Location location = 2; +} + +// Version contains structured information about the version of a package. +message Version { + // Used to correct mistakes in the version numbering scheme. + int32 epoch = 1; + + // Required only when version kind is NORMAL. The main part of the version + // name. + string name = 2; + + // The iteration of the package build from the above version. + string revision = 3; + + // Whether this is an ordinary package version or a sentinel MIN/MAX version. + enum VersionKind { + // Unknown. + VERSION_KIND_UNSPECIFIED = 0; + // A standard package version. + NORMAL = 1; + // A special version representing negative infinity. + MINIMUM = 2; + // A special version representing positive infinity. + MAXIMUM = 3; + }; + + // Required. Distinguishes between sentinel MIN/MAX versions and normal + // versions. + VersionKind kind = 4; + + // Human readable version string. This string is of the form + // :- and is only set when kind is NORMAL. + string full_name = 5; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/provenance.proto b/owl-bot-staging/v1/protos/grafeas/v1/provenance.proto new file mode 100644 index 0000000..06b1097 --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/provenance.proto @@ -0,0 +1,265 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// Provenance of a build. Contains all information needed to verify the full +// details about the build from source to completion. +message BuildProvenance { + // Required. Unique identifier of the build. + string id = 1; + + // ID of the project. + string project_id = 2; + + // Commands requested by the build. + repeated Command commands = 3; + + // Output of the build. + repeated Artifact built_artifacts = 4; + + // Time at which the build was created. + google.protobuf.Timestamp create_time = 5; + + // Time at which execution of the build was started. + google.protobuf.Timestamp start_time = 6; + + // Time at which execution of the build was finished. + google.protobuf.Timestamp end_time = 7; + + // E-mail address of the user who initiated this build. Note that this was the + // user's e-mail address at the time the build was initiated; this address may + // not represent the same end-user for all time. + string creator = 8; + + // URI where any logs for this provenance were written. + string logs_uri = 9; + + // Details of the Source input to the build. + Source source_provenance = 10; + + // Trigger identifier if the build was triggered automatically; empty if not. + string trigger_id = 11; + + // Special options applied to this build. This is a catch-all field where + // build providers can enter any desired additional details. + map build_options = 12; + + // Version string of the builder at the time this build was executed. + string builder_version = 13; +} + +// Source describes the location of the source used for the build. +message Source { + // If provided, the input binary artifacts for the build came from this + // location. + string artifact_storage_source_uri = 1; + + // Hash(es) of the build source, which can be used to verify that the original + // source integrity was maintained in the build. + // + // The keys to this map are file paths used as build source and the values + // contain the hash values for those files. + // + // If the build source came in a single package such as a gzipped tarfile + // (.tar.gz), the FileHash will be for the single path to that file. + map file_hashes = 2; + + // If provided, the source code used for the build came from this location. + SourceContext context = 3; + + // If provided, some of the source code used for the build may be found in + // these locations, in the case where the source repository had multiple + // remotes or submodules. This list will not include the context specified in + // the context field. + repeated SourceContext additional_contexts = 4; +} + +// Container message for hashes of byte content of files, used in source +// messages to verify integrity of source input to the build. +message FileHashes { + // Required. Collection of file hashes. + repeated Hash file_hash = 1; +} + +// Container message for hash values. +message Hash { + // Required. The type of hash that was performed, e.g. "SHA-256". + string type = 1; + // Required. The hash value. + bytes value = 2; +} + +// Command describes a step performed as part of the build pipeline. +message Command { + // Required. Name of the command, as presented on the command line, or if the + // command is packaged as a Docker container, as presented to `docker pull`. + string name = 1; + + // Environment variables set before running this command. + repeated string env = 2; + + // Command-line arguments used when executing this command. + repeated string args = 3; + + // Working directory (relative to project source root) used when running this + // command. + string dir = 4; + + // Optional unique identifier for this command, used in wait_for to reference + // this command as a dependency. + string id = 5; + + // The ID(s) of the command(s) that this command depends on. + repeated string wait_for = 6; +} + +// Artifact describes a build product. +message Artifact { + // Hash or checksum value of a binary, or Docker Registry 2.0 digest of a + // container. + string checksum = 1; + + // Artifact ID, if any; for container images, this will be a URL by digest + // like `gcr.io/projectID/imagename@sha256:123456`. + string id = 2; + + // Related artifact names. This may be the path to a binary or jar file, or in + // the case of a container build, the name used to push the container image to + // Google Container Registry, as presented to `docker push`. Note that a + // single Artifact ID can have multiple names, for example if two tags are + // applied to one image. + repeated string names = 3; +} + +// A SourceContext is a reference to a tree of files. A SourceContext together +// with a path point to a unique revision of a single file or directory. +message SourceContext { + // A SourceContext can refer any one of the following types of repositories. + oneof context { + // A SourceContext referring to a revision in a Google Cloud Source Repo. + CloudRepoSourceContext cloud_repo = 1; + + // A SourceContext referring to a Gerrit project. + GerritSourceContext gerrit = 2; + + // A SourceContext referring to any third party Git repo (e.g., GitHub). + GitSourceContext git = 3; + } + + // Labels with user defined metadata. + map labels = 4; +} + +// An alias to a repo revision. +message AliasContext { + // The type of an alias. + enum Kind { + // Unknown. + KIND_UNSPECIFIED = 0; + // Git tag. + FIXED = 1; + // Git branch. + MOVABLE = 2; + // Used to specify non-standard aliases. For example, if a Git repo has a + // ref named "refs/foo/bar". + OTHER = 4; + } + + // The alias kind. + Kind kind = 1; + + // The alias name. + string name = 2; +} + +// A CloudRepoSourceContext denotes a particular revision in a Google Cloud +// Source Repo. +message CloudRepoSourceContext { + // The ID of the repo. + RepoId repo_id = 1; + + // A revision in a Cloud Repo can be identified by either its revision ID or + // its alias. + oneof revision { + // A revision ID. + string revision_id = 2; + + // An alias, which may be a branch or tag. + AliasContext alias_context = 3; + } +} + +// A SourceContext referring to a Gerrit project. +message GerritSourceContext { + // The URI of a running Gerrit instance. + string host_uri = 1; + + // The full project name within the host. Projects may be nested, so + // "project/subproject" is a valid project name. The "repo name" is the + // hostURI/project. + string gerrit_project = 2; + + // A revision in a Gerrit project can be identified by either its revision ID + // or its alias. + oneof revision { + // A revision (commit) ID. + string revision_id = 3; + + // An alias, which may be a branch or tag. + AliasContext alias_context = 4; + } +} + +// A GitSourceContext denotes a particular revision in a third party Git +// repository (e.g., GitHub). +message GitSourceContext { + // Git repository URL. + string url = 1; + + // Git commit hash. + string revision_id = 2; +} + +// A unique identifier for a Cloud Repo. +message RepoId { + // A cloud repo can be identified by either its project ID and repository name + // combination, or its globally unique identifier. + oneof id { + // A combination of a project ID and a repo name. + ProjectRepoId project_repo_id = 1; + + // A server-assigned, globally unique identifier. + string uid = 2; + } +} + +// Selects a repo using a Google Cloud Platform project ID (e.g., +// winged-cargo-31) and a repo name within that project. +message ProjectRepoId { + // The ID of the project. + string project_id = 1; + + // The name of the repo. Leave empty for the default repo. + string repo_name = 2; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/upgrade.proto b/owl-bot-staging/v1/protos/grafeas/v1/upgrade.proto new file mode 100644 index 0000000..89d3892 --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/upgrade.proto @@ -0,0 +1,114 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +import "google/protobuf/timestamp.proto"; +import "grafeas/v1/package.proto"; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// An Upgrade Note represents a potential upgrade of a package to a given +// version. For each package version combination (i.e. bash 4.0, bash 4.1, +// bash 4.1.2), there will be an Upgrade Note. For Windows, windows_update field +// represents the information related to the update. +message UpgradeNote { + // Required for non-Windows OS. The package this Upgrade is for. + string package = 1; + // Required for non-Windows OS. The version of the package in machine + human + // readable form. + grafeas.v1.Version version = 2; + // Metadata about the upgrade for each specific operating system. + repeated UpgradeDistribution distributions = 3; + // Required for Windows OS. Represents the metadata about the Windows update. + WindowsUpdate windows_update = 4; +} + +// The Upgrade Distribution represents metadata about the Upgrade for each +// operating system (CPE). Some distributions have additional metadata around +// updates, classifying them into various categories and severities. +message UpgradeDistribution { + // Required - The specific operating system this metadata applies to. See + // https://cpe.mitre.org/specification/. + string cpe_uri = 1; + // The operating system classification of this Upgrade, as specified by the + // upstream operating system upgrade feed. For Windows the classification is + // one of the category_ids listed at + // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ff357803(v=vs.85) + string classification = 2; + // The severity as specified by the upstream operating system. + string severity = 3; + // The cve tied to this Upgrade. + repeated string cve = 4; +} + +// Windows Update represents the metadata about the update for the Windows +// operating system. The fields in this message come from the Windows Update API +// documented at +// https://docs.microsoft.com/en-us/windows/win32/api/wuapi/nn-wuapi-iupdate. +message WindowsUpdate { + // The unique identifier of the update. + message Identity { + // The revision independent identifier of the update. + string update_id = 1; + // The revision number of the update. + int32 revision = 2; + } + // Required - The unique identifier for the update. + Identity identity = 1; + // The localized title of the update. + string title = 2; + // The localized description of the update. + string description = 3; + // The category to which the update belongs. + message Category { + // The identifier of the category. + string category_id = 1; + // The localized name of the category. + string name = 2; + } + // The list of categories to which the update belongs. + repeated Category categories = 4; + // The Microsoft Knowledge Base article IDs that are associated with the + // update. + repeated string kb_article_ids = 5; + // The hyperlink to the support information for the update. + string support_url = 6; + // The last published timestamp of the update. + google.protobuf.Timestamp last_published_timestamp = 7; +} + +// An Upgrade Occurrence represents that a specific resource_url could install a +// specific upgrade. This presence is supplied via local sources (i.e. it is +// present in the mirror and the running system has noticed its availability). +// For Windows, both distribution and windows_update contain information for the +// Windows update. +message UpgradeOccurrence { + // Required for non-Windows OS. The package this Upgrade is for. + string package = 1; + // Required for non-Windows OS. The version of the package in a machine + + // human readable form. + grafeas.v1.Version parsed_version = 3; + // Metadata about the upgrade for available for the specific operating system + // for the resource_url. This allows efficient filtering, as well as + // making it easier to use the occurrence. + UpgradeDistribution distribution = 4; + // Required for Windows OS. Represents the metadata about the Windows update. + WindowsUpdate windows_update = 5; +} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/vulnerability.proto b/owl-bot-staging/v1/protos/grafeas/v1/vulnerability.proto new file mode 100644 index 0000000..6c94cdf --- /dev/null +++ b/owl-bot-staging/v1/protos/grafeas/v1/vulnerability.proto @@ -0,0 +1,226 @@ +// Copyright 2019 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1; + +import "google/protobuf/timestamp.proto"; +import "grafeas/v1/common.proto"; +import "grafeas/v1/cvss.proto"; +import "grafeas/v1/package.proto"; + +option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1"; +option objc_class_prefix = "GRA"; + +// Note provider assigned severity/impact ranking. +enum Severity { + // Unknown. + SEVERITY_UNSPECIFIED = 0; + // Minimal severity. + MINIMAL = 1; + // Low severity. + LOW = 2; + // Medium severity. + MEDIUM = 3; + // High severity. + HIGH = 4; + // Critical severity. + CRITICAL = 5; +} + +// A security vulnerability that can be found in resources. +message VulnerabilityNote { + // The CVSS score of this vulnerability. CVSS score is on a scale of 0 - 10 + // where 0 indicates low severity and 10 indicates high severity. + float cvss_score = 1; + + // The note provider assigned severity of this vulnerability. + Severity severity = 2; + + // Details of all known distros and packages affected by this vulnerability. + repeated Detail details = 3; + + // A detail for a distro and package affected by this vulnerability and its + // associated fix (if one is available). + message Detail { + // The distro assigned severity of this vulnerability. + string severity_name = 1; + + // A vendor-specific description of this vulnerability. + string description = 2; + + // The type of package; whether native or non native (e.g., ruby gems, + // node.js packages, etc.). + string package_type = 3; + + // Required. The [CPE URI](https://cpe.mitre.org/specification/) this + // vulnerability affects. + string affected_cpe_uri = 4; + + // Required. The package this vulnerability affects. + string affected_package = 5; + + // The version number at the start of an interval in which this + // vulnerability exists. A vulnerability can affect a package between + // version numbers that are disjoint sets of intervals (example: + // [1.0.0-1.1.0], [2.4.6-2.4.8] and [4.5.6-4.6.8]) each of which will be + // represented in its own Detail. If a specific affected version is provided + // by a vulnerability database, affected_version_start and + // affected_version_end will be the same in that Detail. + grafeas.v1.Version affected_version_start = 6; + + // The version number at the end of an interval in which this vulnerability + // exists. A vulnerability can affect a package between version numbers + // that are disjoint sets of intervals (example: [1.0.0-1.1.0], + // [2.4.6-2.4.8] and [4.5.6-4.6.8]) each of which will be represented in its + // own Detail. If a specific affected version is provided by a vulnerability + // database, affected_version_start and affected_version_end will be the + // same in that Detail. + grafeas.v1.Version affected_version_end = 7; + + // The distro recommended [CPE URI](https://cpe.mitre.org/specification/) + // to update to that contains a fix for this vulnerability. It is possible + // for this to be different from the affected_cpe_uri. + string fixed_cpe_uri = 8; + + // The distro recommended package to update to that contains a fix for this + // vulnerability. It is possible for this to be different from the + // affected_package. + string fixed_package = 9; + + // The distro recommended version to update to that contains a + // fix for this vulnerability. Setting this to VersionKind.MAXIMUM means no + // such version is yet available. + grafeas.v1.Version fixed_version = 10; + + // Whether this detail is obsolete. Occurrences are expected not to point to + // obsolete details. + bool is_obsolete = 11; + + // The time this information was last changed at the source. This is an + // upstream timestamp from the underlying information source - e.g. Ubuntu + // security tracker. + google.protobuf.Timestamp source_update_time = 12; + } + + // The full description of the CVSSv3 for this vulnerability. + CVSSv3 cvss_v3 = 4; + + // Windows details get their own format because the information format and + // model don't match a normal detail. Specifically Windows updates are done as + // patches, thus Windows vulnerabilities really are a missing package, rather + // than a package being at an incorrect version. + repeated WindowsDetail windows_details = 5; + + message WindowsDetail { + // Required. The [CPE URI](https://cpe.mitre.org/specification/) this + // vulnerability affects. + string cpe_uri = 1; + + // Required. The name of this vulnerability. + string name = 2; + + // The description of this vulnerability. + string description = 3; + + // Required. The names of the KBs which have hotfixes to mitigate this + // vulnerability. Note that there may be multiple hotfixes (and thus + // multiple KBs) that mitigate a given vulnerability. Currently any listed + // KBs presence is considered a fix. + repeated KnowledgeBase fixing_kbs = 4; + + message KnowledgeBase { + // The KB name (generally of the form KB[0-9]+ (e.g., KB123456)). + string name = 1; + // A link to the KB in the [Windows update catalog] + // (https://www.catalog.update.microsoft.com/). + string url = 2; + } + } + + // The time this information was last changed at the source. This is an + // upstream timestamp from the underlying information source - e.g. Ubuntu + // security tracker. + google.protobuf.Timestamp source_update_time = 6; +} + +// An occurrence of a severity vulnerability on a resource. +message VulnerabilityOccurrence { + // The type of package; whether native or non native (e.g., ruby gems, node.js + // packages, etc.). + string type = 1; + + // Output only. The note provider assigned severity of this vulnerability. + Severity severity = 2; + + // Output only. The CVSS score of this vulnerability. CVSS score is on a + // scale of 0 - 10 where 0 indicates low severity and 10 indicates high + // severity. + float cvss_score = 3; + + // Required. The set of affected locations and their fixes (if available) + // within the associated resource. + repeated PackageIssue package_issue = 4; + + // A detail for a distro and package this vulnerability occurrence was found + // in and its associated fix (if one is available). + message PackageIssue { + // Required. The [CPE URI](https://cpe.mitre.org/specification/) this + // vulnerability was found in. + string affected_cpe_uri = 1; + + // Required. The package this vulnerability was found in. + string affected_package = 2; + + // Required. The version of the package that is installed on the resource + // affected by this vulnerability. + grafeas.v1.Version affected_version = 3; + + // The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability + // was fixed in. It is possible for this to be different from the + // affected_cpe_uri. + string fixed_cpe_uri = 4; + + // The package this vulnerability was fixed in. It is possible for this to + // be different from the affected_package. + string fixed_package = 5; + + // Required. The version of the package this vulnerability was fixed in. + // Setting this to VersionKind.MAXIMUM means no fix is yet available. + grafeas.v1.Version fixed_version = 6; + + // Output only. Whether a fix is available for this package. + bool fix_available = 7; + } + + // Output only. A one sentence description of this vulnerability. + string short_description = 5; + + // Output only. A detailed description of this vulnerability. + string long_description = 6; + + // Output only. URLs related to this vulnerability. + repeated grafeas.v1.RelatedUrl related_urls = 7; + + // The distro assigned severity for this vulnerability when it is available, + // otherwise this is the note provider assigned severity. + Severity effective_severity = 8; + + // Output only. Whether at least one of the affected packages has a fix + // available. + bool fix_available = 9; +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 0000000..d2d5b9d --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -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. ** + +import * as v1 from './v1'; +const ContainerAnalysisClient = v1.ContainerAnalysisClient; +type ContainerAnalysisClient = v1.ContainerAnalysisClient; +const GrafeasClient = v1.GrafeasClient; +type GrafeasClient = v1.GrafeasClient; +export {v1, ContainerAnalysisClient, GrafeasClient}; +export default {v1, ContainerAnalysisClient, GrafeasClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/container_analysis_client.ts b/owl-bot-staging/v1/src/v1/container_analysis_client.ts new file mode 100644 index 0000000..43c05ea --- /dev/null +++ b/owl-bot-staging/v1/src/v1/container_analysis_client.ts @@ -0,0 +1,731 @@ +// 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} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/container_analysis_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './container_analysis_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Retrieves analysis results of Cloud components such as Docker container + * images. The Container Analysis API is an implementation of the + * [Grafeas](https://grafeas.io) API. + * + * Analysis results are stored as a series of occurrences. An `Occurrence` + * contains information about a specific analysis instance on a resource. An + * occurrence refers to a `Note`. A note contains details describing the + * analysis and is generally stored in a separate project, called a `Provider`. + * Multiple occurrences can refer to the same note. + * + * For example, an SSL vulnerability could affect multiple images. In this case, + * there would be one note for the vulnerability and an occurrence for each + * image with the vulnerability referring to that note. + * @class + * @memberof v1 + */ +export class ContainerAnalysisClient { + 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}; + containerAnalysisStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ContainerAnalysisClient. + * + * @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 ContainerAnalysisClient; + 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 = { + notePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/notes/{note}' + ), + occurrencePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/occurrences/{occurrence}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.devtools.containeranalysis.v1.ContainerAnalysis', 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.containerAnalysisStub) { + return this.containerAnalysisStub; + } + + // Put together the "service stub" for + // google.devtools.containeranalysis.v1.ContainerAnalysis. + this.containerAnalysisStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.devtools.containeranalysis.v1.ContainerAnalysis') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.devtools.containeranalysis.v1.ContainerAnalysis, + 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 containerAnalysisStubMethods = + ['setIamPolicy', 'getIamPolicy', 'testIamPermissions', 'getVulnerabilityOccurrencesSummary']; + for (const methodName of containerAnalysisStubMethods) { + const callPromise = this.containerAnalysisStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.containerAnalysisStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'containeranalysis.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 'containeranalysis.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 -- + // ------------------- + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Sets the access control policy on the specified note or occurrence. + * Requires `containeranalysis.notes.setIamPolicy` or + * `containeranalysis.occurrences.setIamPolicy` permission if the resource is + * a note or an occurrence, respectively. + * + * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + * occurrences. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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.setIamPolicy(request); + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets the access control policy for a note or an occurrence resource. + * Requires `containeranalysis.notes.setIamPolicy` or + * `containeranalysis.occurrences.setIamPolicy` permission if the resource is + * a note or occurrence, respectively. + * + * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + * occurrences. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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.getIamPolicy(request); + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; +/** + * Returns the permissions that a caller has on the specified note or + * occurrence. Requires list permission on the project (for example, + * `containeranalysis.notes.list`). + * + * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + * occurrences. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * 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.testIamPermissions(request); + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + getVulnerabilityOccurrencesSummary( + request?: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, + options?: CallOptions): + Promise<[ + protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, + protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|undefined, {}|undefined + ]>; + getVulnerabilityOccurrencesSummary( + request: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, + options: CallOptions, + callback: Callback< + protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, + protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, + {}|null|undefined>): void; + getVulnerabilityOccurrencesSummary( + request: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, + callback: Callback< + protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, + protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a summary of the number and severity of occurrences. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project to get a vulnerability summary for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @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 [VulnerabilityOccurrencesSummary]{@link google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary}. + * 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.getVulnerabilityOccurrencesSummary(request); + */ + getVulnerabilityOccurrencesSummary( + request?: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, + protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, + protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, + protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|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.getVulnerabilityOccurrencesSummary(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified note resource name string. + * + * @param {string} project + * @param {string} note + * @returns {string} Resource name string. + */ + notePath(project:string,note:string) { + return this.pathTemplates.notePathTemplate.render({ + project: project, + note: note, + }); + } + + /** + * Parse the project from Note resource. + * + * @param {string} noteName + * A fully-qualified path representing Note resource. + * @returns {string} A string representing the project. + */ + matchProjectFromNoteName(noteName: string) { + return this.pathTemplates.notePathTemplate.match(noteName).project; + } + + /** + * Parse the note from Note resource. + * + * @param {string} noteName + * A fully-qualified path representing Note resource. + * @returns {string} A string representing the note. + */ + matchNoteFromNoteName(noteName: string) { + return this.pathTemplates.notePathTemplate.match(noteName).note; + } + + /** + * Return a fully-qualified occurrence resource name string. + * + * @param {string} project + * @param {string} occurrence + * @returns {string} Resource name string. + */ + occurrencePath(project:string,occurrence:string) { + return this.pathTemplates.occurrencePathTemplate.render({ + project: project, + occurrence: occurrence, + }); + } + + /** + * Parse the project from Occurrence resource. + * + * @param {string} occurrenceName + * A fully-qualified path representing Occurrence resource. + * @returns {string} A string representing the project. + */ + matchProjectFromOccurrenceName(occurrenceName: string) { + return this.pathTemplates.occurrencePathTemplate.match(occurrenceName).project; + } + + /** + * Parse the occurrence from Occurrence resource. + * + * @param {string} occurrenceName + * A fully-qualified path representing Occurrence resource. + * @returns {string} A string representing the occurrence. + */ + matchOccurrenceFromOccurrenceName(occurrenceName: string) { + return this.pathTemplates.occurrencePathTemplate.match(occurrenceName).occurrence; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.containerAnalysisStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/container_analysis_client_config.json b/owl-bot-staging/v1/src/v1/container_analysis_client_config.json new file mode 100644 index 0000000..244cccc --- /dev/null +++ b/owl-bot-staging/v1/src/v1/container_analysis_client_config.json @@ -0,0 +1,42 @@ +{ + "interfaces": { + "google.devtools.containeranalysis.v1.ContainerAnalysis": { + "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": { + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetVulnerabilityOccurrencesSummary": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/container_analysis_proto_list.json b/owl-bot-staging/v1/src/v1/container_analysis_proto_list.json new file mode 100644 index 0000000..e44e771 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/container_analysis_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/devtools/containeranalysis/v1/containeranalysis.proto", + "../../protos/grafeas/v1/attestation.proto", + "../../protos/grafeas/v1/build.proto", + "../../protos/grafeas/v1/common.proto", + "../../protos/grafeas/v1/cvss.proto", + "../../protos/grafeas/v1/deployment.proto", + "../../protos/grafeas/v1/discovery.proto", + "../../protos/grafeas/v1/grafeas.proto", + "../../protos/grafeas/v1/image.proto", + "../../protos/grafeas/v1/package.proto", + "../../protos/grafeas/v1/provenance.proto", + "../../protos/grafeas/v1/upgrade.proto", + "../../protos/grafeas/v1/vulnerability.proto" +] 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..322e34e --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,229 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.devtools.containeranalysis.v1", + "libraryPackage": "@google-cloud/containeranalysis", + "services": { + "ContainerAnalysis": { + "clients": { + "grpc": { + "libraryClient": "ContainerAnalysisClient", + "rpcs": { + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "GetVulnerabilityOccurrencesSummary": { + "methods": [ + "getVulnerabilityOccurrencesSummary" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ContainerAnalysisClient", + "rpcs": { + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "GetVulnerabilityOccurrencesSummary": { + "methods": [ + "getVulnerabilityOccurrencesSummary" + ] + } + } + } + } + }, + "Grafeas": { + "clients": { + "grpc": { + "libraryClient": "GrafeasClient", + "rpcs": { + "GetOccurrence": { + "methods": [ + "getOccurrence" + ] + }, + "DeleteOccurrence": { + "methods": [ + "deleteOccurrence" + ] + }, + "CreateOccurrence": { + "methods": [ + "createOccurrence" + ] + }, + "BatchCreateOccurrences": { + "methods": [ + "batchCreateOccurrences" + ] + }, + "UpdateOccurrence": { + "methods": [ + "updateOccurrence" + ] + }, + "GetOccurrenceNote": { + "methods": [ + "getOccurrenceNote" + ] + }, + "GetNote": { + "methods": [ + "getNote" + ] + }, + "DeleteNote": { + "methods": [ + "deleteNote" + ] + }, + "CreateNote": { + "methods": [ + "createNote" + ] + }, + "BatchCreateNotes": { + "methods": [ + "batchCreateNotes" + ] + }, + "UpdateNote": { + "methods": [ + "updateNote" + ] + }, + "ListOccurrences": { + "methods": [ + "listOccurrences", + "listOccurrencesStream", + "listOccurrencesAsync" + ] + }, + "ListNotes": { + "methods": [ + "listNotes", + "listNotesStream", + "listNotesAsync" + ] + }, + "ListNoteOccurrences": { + "methods": [ + "listNoteOccurrences", + "listNoteOccurrencesStream", + "listNoteOccurrencesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "GrafeasClient", + "rpcs": { + "GetOccurrence": { + "methods": [ + "getOccurrence" + ] + }, + "DeleteOccurrence": { + "methods": [ + "deleteOccurrence" + ] + }, + "CreateOccurrence": { + "methods": [ + "createOccurrence" + ] + }, + "BatchCreateOccurrences": { + "methods": [ + "batchCreateOccurrences" + ] + }, + "UpdateOccurrence": { + "methods": [ + "updateOccurrence" + ] + }, + "GetOccurrenceNote": { + "methods": [ + "getOccurrenceNote" + ] + }, + "GetNote": { + "methods": [ + "getNote" + ] + }, + "DeleteNote": { + "methods": [ + "deleteNote" + ] + }, + "CreateNote": { + "methods": [ + "createNote" + ] + }, + "BatchCreateNotes": { + "methods": [ + "batchCreateNotes" + ] + }, + "UpdateNote": { + "methods": [ + "updateNote" + ] + }, + "ListOccurrences": { + "methods": [ + "listOccurrences", + "listOccurrencesStream", + "listOccurrencesAsync" + ] + }, + "ListNotes": { + "methods": [ + "listNotes", + "listNotesStream", + "listNotesAsync" + ] + }, + "ListNoteOccurrences": { + "methods": [ + "listNoteOccurrences", + "listNoteOccurrencesStream", + "listNoteOccurrencesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/grafeas_client.ts b/owl-bot-staging/v1/src/v1/grafeas_client.ts new file mode 100644 index 0000000..892da48 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/grafeas_client.ts @@ -0,0 +1,1795 @@ +// 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/grafeas_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './grafeas_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * [Grafeas](https://grafeas.io) API. + * + * Retrieves analysis results of Cloud components such as Docker container + * images. + * + * Analysis results are stored as a series of occurrences. An `Occurrence` + * contains information about a specific analysis instance on a resource. An + * occurrence refers to a `Note`. A note contains details describing the + * analysis and is generally stored in a separate project, called a `Provider`. + * Multiple occurrences can refer to the same note. + * + * For example, an SSL vulnerability could affect multiple images. In this case, + * there would be one note for the vulnerability and an occurrence for each + * image with the vulnerability referring to that note. + * @class + * @memberof v1 + */ +export class GrafeasClient { + 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}; + grafeasStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of GrafeasClient. + * + * @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 GrafeasClient; + 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 = { + notePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/notes/{note}' + ), + occurrencePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/occurrences/{occurrence}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listOccurrences: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'occurrences'), + listNotes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'notes'), + listNoteOccurrences: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'occurrences') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.devtools.containeranalysis.v1.Grafeas', 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.grafeasStub) { + return this.grafeasStub; + } + + // Put together the "service stub" for + // google.devtools.containeranalysis.v1.Grafeas. + this.grafeasStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.devtools.containeranalysis.v1.Grafeas') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.devtools.containeranalysis.v1.Grafeas, + 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 grafeasStubMethods = + ['getOccurrence', 'listOccurrences', 'deleteOccurrence', 'createOccurrence', 'batchCreateOccurrences', 'updateOccurrence', 'getOccurrenceNote', 'getNote', 'listNotes', 'deleteNote', 'createNote', 'batchCreateNotes', 'updateNote', 'listNoteOccurrences']; + for (const methodName of grafeasStubMethods) { + const callPromise = this.grafeasStub.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.grafeasStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'containeranalysis.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 'containeranalysis.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 []; + } + + 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 -- + // ------------------- + getOccurrence( + request?: protos.grafeas.v1.IGetOccurrenceRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IGetOccurrenceRequest|undefined, {}|undefined + ]>; + getOccurrence( + request: protos.grafeas.v1.IGetOccurrenceRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IGetOccurrenceRequest|null|undefined, + {}|null|undefined>): void; + getOccurrence( + request: protos.grafeas.v1.IGetOccurrenceRequest, + callback: Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IGetOccurrenceRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets the specified occurrence. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the occurrence in the form of + * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Occurrence]{@link grafeas.v1.Occurrence}. + * 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.getOccurrence(request); + */ + getOccurrence( + request?: protos.grafeas.v1.IGetOccurrenceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IGetOccurrenceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IGetOccurrenceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IGetOccurrenceRequest|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.getOccurrence(request, options, callback); + } + deleteOccurrence( + request?: protos.grafeas.v1.IDeleteOccurrenceRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteOccurrenceRequest|undefined, {}|undefined + ]>; + deleteOccurrence( + request: protos.grafeas.v1.IDeleteOccurrenceRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteOccurrenceRequest|null|undefined, + {}|null|undefined>): void; + deleteOccurrence( + request: protos.grafeas.v1.IDeleteOccurrenceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteOccurrenceRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes the specified occurrence. For example, use this method to delete an + * occurrence when the occurrence is no longer applicable for the given + * resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the occurrence in the form of + * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteOccurrence(request); + */ + deleteOccurrence( + request?: protos.grafeas.v1.IDeleteOccurrenceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteOccurrenceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteOccurrenceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteOccurrenceRequest|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.deleteOccurrence(request, options, callback); + } + createOccurrence( + request?: protos.grafeas.v1.ICreateOccurrenceRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.ICreateOccurrenceRequest|undefined, {}|undefined + ]>; + createOccurrence( + request: protos.grafeas.v1.ICreateOccurrenceRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.ICreateOccurrenceRequest|null|undefined, + {}|null|undefined>): void; + createOccurrence( + request: protos.grafeas.v1.ICreateOccurrenceRequest, + callback: Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.ICreateOccurrenceRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new occurrence. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project in the form of `projects/[PROJECT_ID]`, under which + * the occurrence is to be created. + * @param {grafeas.v1.Occurrence} request.occurrence + * The occurrence to create. + * @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 [Occurrence]{@link grafeas.v1.Occurrence}. + * 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.createOccurrence(request); + */ + createOccurrence( + request?: protos.grafeas.v1.ICreateOccurrenceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.ICreateOccurrenceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.ICreateOccurrenceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.ICreateOccurrenceRequest|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.createOccurrence(request, options, callback); + } + batchCreateOccurrences( + request?: protos.grafeas.v1.IBatchCreateOccurrencesRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1.IBatchCreateOccurrencesRequest|undefined, {}|undefined + ]>; + batchCreateOccurrences( + request: protos.grafeas.v1.IBatchCreateOccurrencesRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1.IBatchCreateOccurrencesRequest|null|undefined, + {}|null|undefined>): void; + batchCreateOccurrences( + request: protos.grafeas.v1.IBatchCreateOccurrencesRequest, + callback: Callback< + protos.grafeas.v1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1.IBatchCreateOccurrencesRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates new occurrences in batch. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project in the form of `projects/[PROJECT_ID]`, under which + * the occurrences are to be created. + * @param {number[]} request.occurrences + * The occurrences to create. Max allowed length is 1000. + * @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 [BatchCreateOccurrencesResponse]{@link grafeas.v1.BatchCreateOccurrencesResponse}. + * 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.batchCreateOccurrences(request); + */ + batchCreateOccurrences( + request?: protos.grafeas.v1.IBatchCreateOccurrencesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1.IBatchCreateOccurrencesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1.IBatchCreateOccurrencesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1.IBatchCreateOccurrencesRequest|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.batchCreateOccurrences(request, options, callback); + } + updateOccurrence( + request?: protos.grafeas.v1.IUpdateOccurrenceRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IUpdateOccurrenceRequest|undefined, {}|undefined + ]>; + updateOccurrence( + request: protos.grafeas.v1.IUpdateOccurrenceRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IUpdateOccurrenceRequest|null|undefined, + {}|null|undefined>): void; + updateOccurrence( + request: protos.grafeas.v1.IUpdateOccurrenceRequest, + callback: Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IUpdateOccurrenceRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates the specified occurrence. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the occurrence in the form of + * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + * @param {grafeas.v1.Occurrence} request.occurrence + * The updated occurrence. + * @param {google.protobuf.FieldMask} request.updateMask + * The fields to update. + * @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 [Occurrence]{@link grafeas.v1.Occurrence}. + * 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.updateOccurrence(request); + */ + updateOccurrence( + request?: protos.grafeas.v1.IUpdateOccurrenceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IUpdateOccurrenceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IUpdateOccurrenceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1.IOccurrence, + protos.grafeas.v1.IUpdateOccurrenceRequest|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.updateOccurrence(request, options, callback); + } + getOccurrenceNote( + request?: protos.grafeas.v1.IGetOccurrenceNoteRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetOccurrenceNoteRequest|undefined, {}|undefined + ]>; + getOccurrenceNote( + request: protos.grafeas.v1.IGetOccurrenceNoteRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetOccurrenceNoteRequest|null|undefined, + {}|null|undefined>): void; + getOccurrenceNote( + request: protos.grafeas.v1.IGetOccurrenceNoteRequest, + callback: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetOccurrenceNoteRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets the note attached to the specified occurrence. Consumer projects can + * use this method to get a note that belongs to a provider project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the occurrence in the form of + * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Note]{@link grafeas.v1.Note}. + * 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.getOccurrenceNote(request); + */ + getOccurrenceNote( + request?: protos.grafeas.v1.IGetOccurrenceNoteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetOccurrenceNoteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetOccurrenceNoteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetOccurrenceNoteRequest|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.getOccurrenceNote(request, options, callback); + } + getNote( + request?: protos.grafeas.v1.IGetNoteRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetNoteRequest|undefined, {}|undefined + ]>; + getNote( + request: protos.grafeas.v1.IGetNoteRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetNoteRequest|null|undefined, + {}|null|undefined>): void; + getNote( + request: protos.grafeas.v1.IGetNoteRequest, + callback: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetNoteRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets the specified note. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the note in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Note]{@link grafeas.v1.Note}. + * 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.getNote(request); + */ + getNote( + request?: protos.grafeas.v1.IGetNoteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetNoteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetNoteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1.INote, + protos.grafeas.v1.IGetNoteRequest|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.getNote(request, options, callback); + } + deleteNote( + request?: protos.grafeas.v1.IDeleteNoteRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteNoteRequest|undefined, {}|undefined + ]>; + deleteNote( + request: protos.grafeas.v1.IDeleteNoteRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteNoteRequest|null|undefined, + {}|null|undefined>): void; + deleteNote( + request: protos.grafeas.v1.IDeleteNoteRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteNoteRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes the specified note. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the note in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteNote(request); + */ + deleteNote( + request?: protos.grafeas.v1.IDeleteNoteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteNoteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteNoteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.grafeas.v1.IDeleteNoteRequest|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.deleteNote(request, options, callback); + } + createNote( + request?: protos.grafeas.v1.ICreateNoteRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.INote, + protos.grafeas.v1.ICreateNoteRequest|undefined, {}|undefined + ]>; + createNote( + request: protos.grafeas.v1.ICreateNoteRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.ICreateNoteRequest|null|undefined, + {}|null|undefined>): void; + createNote( + request: protos.grafeas.v1.ICreateNoteRequest, + callback: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.ICreateNoteRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new note. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project in the form of `projects/[PROJECT_ID]`, under which + * the note is to be created. + * @param {string} request.noteId + * The ID to use for this note. + * @param {grafeas.v1.Note} request.note + * The note to create. + * @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 [Note]{@link grafeas.v1.Note}. + * 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.createNote(request); + */ + createNote( + request?: protos.grafeas.v1.ICreateNoteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.ICreateNoteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.ICreateNoteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1.INote, + protos.grafeas.v1.ICreateNoteRequest|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.createNote(request, options, callback); + } + batchCreateNotes( + request?: protos.grafeas.v1.IBatchCreateNotesRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.IBatchCreateNotesResponse, + protos.grafeas.v1.IBatchCreateNotesRequest|undefined, {}|undefined + ]>; + batchCreateNotes( + request: protos.grafeas.v1.IBatchCreateNotesRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1.IBatchCreateNotesResponse, + protos.grafeas.v1.IBatchCreateNotesRequest|null|undefined, + {}|null|undefined>): void; + batchCreateNotes( + request: protos.grafeas.v1.IBatchCreateNotesRequest, + callback: Callback< + protos.grafeas.v1.IBatchCreateNotesResponse, + protos.grafeas.v1.IBatchCreateNotesRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates new notes in batch. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project in the form of `projects/[PROJECT_ID]`, under which + * the notes are to be created. + * @param {number[]} request.notes + * The notes to create. Max allowed length is 1000. + * @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 [BatchCreateNotesResponse]{@link grafeas.v1.BatchCreateNotesResponse}. + * 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.batchCreateNotes(request); + */ + batchCreateNotes( + request?: protos.grafeas.v1.IBatchCreateNotesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1.IBatchCreateNotesResponse, + protos.grafeas.v1.IBatchCreateNotesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1.IBatchCreateNotesResponse, + protos.grafeas.v1.IBatchCreateNotesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1.IBatchCreateNotesResponse, + protos.grafeas.v1.IBatchCreateNotesRequest|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.batchCreateNotes(request, options, callback); + } + updateNote( + request?: protos.grafeas.v1.IUpdateNoteRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.INote, + protos.grafeas.v1.IUpdateNoteRequest|undefined, {}|undefined + ]>; + updateNote( + request: protos.grafeas.v1.IUpdateNoteRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IUpdateNoteRequest|null|undefined, + {}|null|undefined>): void; + updateNote( + request: protos.grafeas.v1.IUpdateNoteRequest, + callback: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IUpdateNoteRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates the specified note. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the note in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {grafeas.v1.Note} request.note + * The updated note. + * @param {google.protobuf.FieldMask} request.updateMask + * The fields to update. + * @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 [Note]{@link grafeas.v1.Note}. + * 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.updateNote(request); + */ + updateNote( + request?: protos.grafeas.v1.IUpdateNoteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IUpdateNoteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1.INote, + protos.grafeas.v1.IUpdateNoteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1.INote, + protos.grafeas.v1.IUpdateNoteRequest|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.updateNote(request, options, callback); + } + + listOccurrences( + request?: protos.grafeas.v1.IListOccurrencesRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.IOccurrence[], + protos.grafeas.v1.IListOccurrencesRequest|null, + protos.grafeas.v1.IListOccurrencesResponse + ]>; + listOccurrences( + request: protos.grafeas.v1.IListOccurrencesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.grafeas.v1.IListOccurrencesRequest, + protos.grafeas.v1.IListOccurrencesResponse|null|undefined, + protos.grafeas.v1.IOccurrence>): void; + listOccurrences( + request: protos.grafeas.v1.IListOccurrencesRequest, + callback: PaginationCallback< + protos.grafeas.v1.IListOccurrencesRequest, + protos.grafeas.v1.IListOccurrencesResponse|null|undefined, + protos.grafeas.v1.IOccurrence>): void; +/** + * Lists occurrences for the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project to list occurrences for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. Must be positive. Max allowed + * page size is 1000. If not specified, page size defaults to 20. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Occurrence]{@link grafeas.v1.Occurrence}. + * 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 `listOccurrencesAsync()` + * 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. + */ + listOccurrences( + request?: protos.grafeas.v1.IListOccurrencesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.grafeas.v1.IListOccurrencesRequest, + protos.grafeas.v1.IListOccurrencesResponse|null|undefined, + protos.grafeas.v1.IOccurrence>, + callback?: PaginationCallback< + protos.grafeas.v1.IListOccurrencesRequest, + protos.grafeas.v1.IListOccurrencesResponse|null|undefined, + protos.grafeas.v1.IOccurrence>): + Promise<[ + protos.grafeas.v1.IOccurrence[], + protos.grafeas.v1.IListOccurrencesRequest|null, + protos.grafeas.v1.IListOccurrencesResponse + ]>|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.listOccurrences(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 + * The name of the project to list occurrences for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. Must be positive. Max allowed + * page size is 1000. If not specified, page size defaults to 20. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Occurrence]{@link grafeas.v1.Occurrence} 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 `listOccurrencesAsync()` + * 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. + */ + listOccurrencesStream( + request?: protos.grafeas.v1.IListOccurrencesRequest, + 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.listOccurrences.createStream( + this.innerApiCalls.listOccurrences as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listOccurrences`, 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 + * The name of the project to list occurrences for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. Must be positive. Max allowed + * page size is 1000. If not specified, page size defaults to 20. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 + * [Occurrence]{@link grafeas.v1.Occurrence}. 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.listOccurrencesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listOccurrencesAsync( + request?: protos.grafeas.v1.IListOccurrencesRequest, + 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.listOccurrences.asyncIterate( + this.innerApiCalls['listOccurrences'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listNotes( + request?: protos.grafeas.v1.IListNotesRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.INote[], + protos.grafeas.v1.IListNotesRequest|null, + protos.grafeas.v1.IListNotesResponse + ]>; + listNotes( + request: protos.grafeas.v1.IListNotesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.grafeas.v1.IListNotesRequest, + protos.grafeas.v1.IListNotesResponse|null|undefined, + protos.grafeas.v1.INote>): void; + listNotes( + request: protos.grafeas.v1.IListNotesRequest, + callback: PaginationCallback< + protos.grafeas.v1.IListNotesRequest, + protos.grafeas.v1.IListNotesResponse|null|undefined, + protos.grafeas.v1.INote>): void; +/** + * Lists notes for the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project to list notes for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of notes to return in the list. Must be positive. Max allowed page + * size is 1000. If not specified, page size defaults to 20. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Note]{@link grafeas.v1.Note}. + * 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 `listNotesAsync()` + * 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. + */ + listNotes( + request?: protos.grafeas.v1.IListNotesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.grafeas.v1.IListNotesRequest, + protos.grafeas.v1.IListNotesResponse|null|undefined, + protos.grafeas.v1.INote>, + callback?: PaginationCallback< + protos.grafeas.v1.IListNotesRequest, + protos.grafeas.v1.IListNotesResponse|null|undefined, + protos.grafeas.v1.INote>): + Promise<[ + protos.grafeas.v1.INote[], + protos.grafeas.v1.IListNotesRequest|null, + protos.grafeas.v1.IListNotesResponse + ]>|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.listNotes(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 + * The name of the project to list notes for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of notes to return in the list. Must be positive. Max allowed page + * size is 1000. If not specified, page size defaults to 20. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Note]{@link grafeas.v1.Note} 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 `listNotesAsync()` + * 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. + */ + listNotesStream( + request?: protos.grafeas.v1.IListNotesRequest, + 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.listNotes.createStream( + this.innerApiCalls.listNotes as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listNotes`, 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 + * The name of the project to list notes for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of notes to return in the list. Must be positive. Max allowed page + * size is 1000. If not specified, page size defaults to 20. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 + * [Note]{@link grafeas.v1.Note}. 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.listNotesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listNotesAsync( + request?: protos.grafeas.v1.IListNotesRequest, + 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.listNotes.asyncIterate( + this.innerApiCalls['listNotes'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listNoteOccurrences( + request?: protos.grafeas.v1.IListNoteOccurrencesRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1.IOccurrence[], + protos.grafeas.v1.IListNoteOccurrencesRequest|null, + protos.grafeas.v1.IListNoteOccurrencesResponse + ]>; + listNoteOccurrences( + request: protos.grafeas.v1.IListNoteOccurrencesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.grafeas.v1.IListNoteOccurrencesRequest, + protos.grafeas.v1.IListNoteOccurrencesResponse|null|undefined, + protos.grafeas.v1.IOccurrence>): void; + listNoteOccurrences( + request: protos.grafeas.v1.IListNoteOccurrencesRequest, + callback: PaginationCallback< + protos.grafeas.v1.IListNoteOccurrencesRequest, + protos.grafeas.v1.IListNoteOccurrencesResponse|null|undefined, + protos.grafeas.v1.IOccurrence>): void; +/** + * Lists occurrences referencing the specified note. Provider projects can use + * this method to get all occurrences across consumer projects referencing the + * specified note. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the note to list occurrences for in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Occurrence]{@link grafeas.v1.Occurrence}. + * 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 `listNoteOccurrencesAsync()` + * 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. + */ + listNoteOccurrences( + request?: protos.grafeas.v1.IListNoteOccurrencesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.grafeas.v1.IListNoteOccurrencesRequest, + protos.grafeas.v1.IListNoteOccurrencesResponse|null|undefined, + protos.grafeas.v1.IOccurrence>, + callback?: PaginationCallback< + protos.grafeas.v1.IListNoteOccurrencesRequest, + protos.grafeas.v1.IListNoteOccurrencesResponse|null|undefined, + protos.grafeas.v1.IOccurrence>): + Promise<[ + protos.grafeas.v1.IOccurrence[], + protos.grafeas.v1.IListNoteOccurrencesRequest|null, + protos.grafeas.v1.IListNoteOccurrencesResponse + ]>|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.listNoteOccurrences(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.name + * The name of the note to list occurrences for in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Occurrence]{@link grafeas.v1.Occurrence} 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 `listNoteOccurrencesAsync()` + * 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. + */ + listNoteOccurrencesStream( + request?: protos.grafeas.v1.IListNoteOccurrencesRequest, + 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({ + 'name': request.name || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listNoteOccurrences.createStream( + this.innerApiCalls.listNoteOccurrences as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listNoteOccurrences`, 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.name + * The name of the note to list occurrences for in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 + * [Occurrence]{@link grafeas.v1.Occurrence}. 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.listNoteOccurrencesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listNoteOccurrencesAsync( + request?: protos.grafeas.v1.IListNoteOccurrencesRequest, + 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({ + 'name': request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listNoteOccurrences.asyncIterate( + this.innerApiCalls['listNoteOccurrences'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified note resource name string. + * + * @param {string} project + * @param {string} note + * @returns {string} Resource name string. + */ + notePath(project:string,note:string) { + return this.pathTemplates.notePathTemplate.render({ + project: project, + note: note, + }); + } + + /** + * Parse the project from Note resource. + * + * @param {string} noteName + * A fully-qualified path representing Note resource. + * @returns {string} A string representing the project. + */ + matchProjectFromNoteName(noteName: string) { + return this.pathTemplates.notePathTemplate.match(noteName).project; + } + + /** + * Parse the note from Note resource. + * + * @param {string} noteName + * A fully-qualified path representing Note resource. + * @returns {string} A string representing the note. + */ + matchNoteFromNoteName(noteName: string) { + return this.pathTemplates.notePathTemplate.match(noteName).note; + } + + /** + * Return a fully-qualified occurrence resource name string. + * + * @param {string} project + * @param {string} occurrence + * @returns {string} Resource name string. + */ + occurrencePath(project:string,occurrence:string) { + return this.pathTemplates.occurrencePathTemplate.render({ + project: project, + occurrence: occurrence, + }); + } + + /** + * Parse the project from Occurrence resource. + * + * @param {string} occurrenceName + * A fully-qualified path representing Occurrence resource. + * @returns {string} A string representing the project. + */ + matchProjectFromOccurrenceName(occurrenceName: string) { + return this.pathTemplates.occurrencePathTemplate.match(occurrenceName).project; + } + + /** + * Parse the occurrence from Occurrence resource. + * + * @param {string} occurrenceName + * A fully-qualified path representing Occurrence resource. + * @returns {string} A string representing the occurrence. + */ + matchOccurrenceFromOccurrenceName(occurrenceName: string) { + return this.pathTemplates.occurrencePathTemplate.match(occurrenceName).occurrence; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.grafeasStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/grafeas_client_config.json b/owl-bot-staging/v1/src/v1/grafeas_client_config.json new file mode 100644 index 0000000..5a325a2 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/grafeas_client_config.json @@ -0,0 +1,82 @@ +{ + "interfaces": { + "google.devtools.containeranalysis.v1.Grafeas": { + "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": { + "GetOccurrence": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListOccurrences": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteOccurrence": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateOccurrence": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "BatchCreateOccurrences": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateOccurrence": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetOccurrenceNote": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNote": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListNotes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteNote": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateNote": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "BatchCreateNotes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateNote": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListNoteOccurrences": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/grafeas_proto_list.json b/owl-bot-staging/v1/src/v1/grafeas_proto_list.json new file mode 100644 index 0000000..e44e771 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/grafeas_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/devtools/containeranalysis/v1/containeranalysis.proto", + "../../protos/grafeas/v1/attestation.proto", + "../../protos/grafeas/v1/build.proto", + "../../protos/grafeas/v1/common.proto", + "../../protos/grafeas/v1/cvss.proto", + "../../protos/grafeas/v1/deployment.proto", + "../../protos/grafeas/v1/discovery.proto", + "../../protos/grafeas/v1/grafeas.proto", + "../../protos/grafeas/v1/image.proto", + "../../protos/grafeas/v1/package.proto", + "../../protos/grafeas/v1/provenance.proto", + "../../protos/grafeas/v1/upgrade.proto", + "../../protos/grafeas/v1/vulnerability.proto" +] 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..953e590 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// 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 {ContainerAnalysisClient} from './container_analysis_client'; +export {GrafeasClient} from './grafeas_client'; 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..088e6bd --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// 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 containeranalysis = require('@google-cloud/containeranalysis'); + +function main() { + const containerAnalysisClient = new containeranalysis.ContainerAnalysisClient(); + const grafeasClient = new containeranalysis.GrafeasClient(); +} + +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..4e31b0b --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// 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 {ContainerAnalysisClient, GrafeasClient} from '@google-cloud/containeranalysis'; + +// check that the client class type name can be used +function doStuffWithContainerAnalysisClient(client: ContainerAnalysisClient) { + client.close(); +} +function doStuffWithGrafeasClient(client: GrafeasClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const containerAnalysisClient = new ContainerAnalysisClient(); + doStuffWithContainerAnalysisClient(containerAnalysisClient); + // check that the client instance can be created + const grafeasClient = new GrafeasClient(); + doStuffWithGrafeasClient(grafeasClient); +} + +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_container_analysis_v1.ts b/owl-bot-staging/v1/test/gapic_container_analysis_v1.ts new file mode 100644 index 0000000..95fcda9 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_container_analysis_v1.ts @@ -0,0 +1,565 @@ +// 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 containeranalysisModule from '../src'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1.ContainerAnalysisClient', () => { + it('has servicePath', () => { + const servicePath = containeranalysisModule.v1.ContainerAnalysisClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = containeranalysisModule.v1.ContainerAnalysisClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = containeranalysisModule.v1.ContainerAnalysisClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.containerAnalysisStub, undefined); + await client.initialize(); + assert(client.containerAnalysisStub); + }); + + it('has close method', () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + 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 containeranalysisModule.v1.ContainerAnalysisClient({ + 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('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getVulnerabilityOccurrencesSummary', () => { + it('invokes getVulnerabilityOccurrencesSummary without error', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary()); + client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCall(expectedResponse); + const [response] = await client.getVulnerabilityOccurrencesSummary(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getVulnerabilityOccurrencesSummary without error using callback', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary()); + client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getVulnerabilityOccurrencesSummary( + request, + (err?: Error|null, result?: protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getVulnerabilityOccurrencesSummary with error', async () => { + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getVulnerabilityOccurrencesSummary(request), expectedError); + assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('Path templates', () => { + + describe('note', () => { + const fakePath = "/rendered/path/note"; + const expectedParameters = { + project: "projectValue", + note: "noteValue", + }; + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.notePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.notePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('notePath', () => { + const result = client.notePath("projectValue", "noteValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.notePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromNoteName', () => { + const result = client.matchProjectFromNoteName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.notePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchNoteFromNoteName', () => { + const result = client.matchNoteFromNoteName(fakePath); + assert.strictEqual(result, "noteValue"); + assert((client.pathTemplates.notePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('occurrence', () => { + const fakePath = "/rendered/path/occurrence"; + const expectedParameters = { + project: "projectValue", + occurrence: "occurrenceValue", + }; + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.occurrencePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.occurrencePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('occurrencePath', () => { + const result = client.occurrencePath("projectValue", "occurrenceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.occurrencePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromOccurrenceName', () => { + const result = client.matchProjectFromOccurrenceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.occurrencePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchOccurrenceFromOccurrenceName', () => { + const result = client.matchOccurrenceFromOccurrenceName(fakePath); + assert.strictEqual(result, "occurrenceValue"); + assert((client.pathTemplates.occurrencePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new containeranalysisModule.v1.ContainerAnalysisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/test/gapic_grafeas_v1.ts b/owl-bot-staging/v1/test/gapic_grafeas_v1.ts new file mode 100644 index 0000000..4aaaef1 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_grafeas_v1.ts @@ -0,0 +1,1866 @@ +// 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 grafeasModule 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.GrafeasClient', () => { + it('has servicePath', () => { + const servicePath = grafeasModule.v1.GrafeasClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = grafeasModule.v1.GrafeasClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = grafeasModule.v1.GrafeasClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new grafeasModule.v1.GrafeasClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new grafeasModule.v1.GrafeasClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.grafeasStub, undefined); + await client.initialize(); + assert(client.grafeasStub); + }); + + it('has close method', () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new grafeasModule.v1.GrafeasClient({ + 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 grafeasModule.v1.GrafeasClient({ + 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('getOccurrence', () => { + it('invokes getOccurrence without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); + client.innerApiCalls.getOccurrence = stubSimpleCall(expectedResponse); + const [response] = await client.getOccurrence(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getOccurrence without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); + client.innerApiCalls.getOccurrence = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOccurrence( + request, + (err?: Error|null, result?: protos.grafeas.v1.IOccurrence|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getOccurrence with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getOccurrence = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getOccurrence(request), expectedError); + assert((client.innerApiCalls.getOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('deleteOccurrence', () => { + it('invokes deleteOccurrence without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.DeleteOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteOccurrence = stubSimpleCall(expectedResponse); + const [response] = await client.deleteOccurrence(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteOccurrence without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.DeleteOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteOccurrence = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteOccurrence( + 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.deleteOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteOccurrence with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.DeleteOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteOccurrence = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteOccurrence(request), expectedError); + assert((client.innerApiCalls.deleteOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('createOccurrence', () => { + it('invokes createOccurrence without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.CreateOccurrenceRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); + client.innerApiCalls.createOccurrence = stubSimpleCall(expectedResponse); + const [response] = await client.createOccurrence(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createOccurrence without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.CreateOccurrenceRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); + client.innerApiCalls.createOccurrence = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createOccurrence( + request, + (err?: Error|null, result?: protos.grafeas.v1.IOccurrence|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createOccurrence with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.CreateOccurrenceRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createOccurrence = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createOccurrence(request), expectedError); + assert((client.innerApiCalls.createOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('batchCreateOccurrences', () => { + it('invokes batchCreateOccurrences without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.BatchCreateOccurrencesResponse()); + client.innerApiCalls.batchCreateOccurrences = stubSimpleCall(expectedResponse); + const [response] = await client.batchCreateOccurrences(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchCreateOccurrences without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.BatchCreateOccurrencesResponse()); + client.innerApiCalls.batchCreateOccurrences = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchCreateOccurrences( + request, + (err?: Error|null, result?: protos.grafeas.v1.IBatchCreateOccurrencesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchCreateOccurrences with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchCreateOccurrences = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchCreateOccurrences(request), expectedError); + assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updateOccurrence', () => { + it('invokes updateOccurrence without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.UpdateOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); + client.innerApiCalls.updateOccurrence = stubSimpleCall(expectedResponse); + const [response] = await client.updateOccurrence(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateOccurrence without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.UpdateOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); + client.innerApiCalls.updateOccurrence = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateOccurrence( + request, + (err?: Error|null, result?: protos.grafeas.v1.IOccurrence|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateOccurrence with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.UpdateOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateOccurrence = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateOccurrence(request), expectedError); + assert((client.innerApiCalls.updateOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getOccurrenceNote', () => { + it('invokes getOccurrenceNote without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); + client.innerApiCalls.getOccurrenceNote = stubSimpleCall(expectedResponse); + const [response] = await client.getOccurrenceNote(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getOccurrenceNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getOccurrenceNote without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); + client.innerApiCalls.getOccurrenceNote = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOccurrenceNote( + request, + (err?: Error|null, result?: protos.grafeas.v1.INote|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getOccurrenceNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getOccurrenceNote with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getOccurrenceNote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getOccurrenceNote(request), expectedError); + assert((client.innerApiCalls.getOccurrenceNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getNote', () => { + it('invokes getNote without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.GetNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); + client.innerApiCalls.getNote = stubSimpleCall(expectedResponse); + const [response] = await client.getNote(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getNote without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.GetNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); + client.innerApiCalls.getNote = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getNote( + request, + (err?: Error|null, result?: protos.grafeas.v1.INote|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getNote with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.GetNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getNote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getNote(request), expectedError); + assert((client.innerApiCalls.getNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('deleteNote', () => { + it('invokes deleteNote without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.DeleteNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteNote = stubSimpleCall(expectedResponse); + const [response] = await client.deleteNote(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteNote without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.DeleteNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteNote = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteNote( + 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.deleteNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteNote with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.DeleteNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteNote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteNote(request), expectedError); + assert((client.innerApiCalls.deleteNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('createNote', () => { + it('invokes createNote without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.CreateNoteRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); + client.innerApiCalls.createNote = stubSimpleCall(expectedResponse); + const [response] = await client.createNote(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createNote without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.CreateNoteRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); + client.innerApiCalls.createNote = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createNote( + request, + (err?: Error|null, result?: protos.grafeas.v1.INote|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createNote with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.CreateNoteRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createNote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createNote(request), expectedError); + assert((client.innerApiCalls.createNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('batchCreateNotes', () => { + it('invokes batchCreateNotes without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.BatchCreateNotesResponse()); + client.innerApiCalls.batchCreateNotes = stubSimpleCall(expectedResponse); + const [response] = await client.batchCreateNotes(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchCreateNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchCreateNotes without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.BatchCreateNotesResponse()); + client.innerApiCalls.batchCreateNotes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchCreateNotes( + request, + (err?: Error|null, result?: protos.grafeas.v1.IBatchCreateNotesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchCreateNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchCreateNotes with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchCreateNotes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchCreateNotes(request), expectedError); + assert((client.innerApiCalls.batchCreateNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updateNote', () => { + it('invokes updateNote without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.UpdateNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); + client.innerApiCalls.updateNote = stubSimpleCall(expectedResponse); + const [response] = await client.updateNote(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateNote without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.UpdateNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); + client.innerApiCalls.updateNote = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateNote( + request, + (err?: Error|null, result?: protos.grafeas.v1.INote|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateNote with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.UpdateNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateNote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateNote(request), expectedError); + assert((client.innerApiCalls.updateNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listOccurrences', () => { + it('invokes listOccurrences without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + ]; + client.innerApiCalls.listOccurrences = stubSimpleCall(expectedResponse); + const [response] = await client.listOccurrences(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listOccurrences without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + ]; + client.innerApiCalls.listOccurrences = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOccurrences( + request, + (err?: Error|null, result?: protos.grafeas.v1.IOccurrence[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listOccurrences with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listOccurrences = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listOccurrences(request), expectedError); + assert((client.innerApiCalls.listOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listOccurrencesStream without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + ]; + client.descriptors.page.listOccurrences.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listOccurrencesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1.Occurrence[] = []; + stream.on('data', (response: protos.grafeas.v1.Occurrence) => { + 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.listOccurrences.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOccurrences, request)); + assert.strictEqual( + (client.descriptors.page.listOccurrences.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listOccurrencesStream with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listOccurrences.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listOccurrencesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1.Occurrence[] = []; + stream.on('data', (response: protos.grafeas.v1.Occurrence) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listOccurrences.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOccurrences, request)); + assert.strictEqual( + (client.descriptors.page.listOccurrences.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listOccurrences without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + ]; + client.descriptors.page.listOccurrences.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.grafeas.v1.IOccurrence[] = []; + const iterable = client.listOccurrencesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listOccurrences with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listOccurrences.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOccurrencesAsync(request); + await assert.rejects(async () => { + const responses: protos.grafeas.v1.IOccurrence[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listNotes', () => { + it('invokes listNotes without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Note()), + generateSampleMessage(new protos.grafeas.v1.Note()), + generateSampleMessage(new protos.grafeas.v1.Note()), + ]; + client.innerApiCalls.listNotes = stubSimpleCall(expectedResponse); + const [response] = await client.listNotes(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listNotes without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Note()), + generateSampleMessage(new protos.grafeas.v1.Note()), + generateSampleMessage(new protos.grafeas.v1.Note()), + ]; + client.innerApiCalls.listNotes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNotes( + request, + (err?: Error|null, result?: protos.grafeas.v1.INote[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listNotes with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listNotes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listNotes(request), expectedError); + assert((client.innerApiCalls.listNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listNotesStream without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Note()), + generateSampleMessage(new protos.grafeas.v1.Note()), + generateSampleMessage(new protos.grafeas.v1.Note()), + ]; + client.descriptors.page.listNotes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listNotesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1.Note[] = []; + stream.on('data', (response: protos.grafeas.v1.Note) => { + 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.listNotes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNotes, request)); + assert.strictEqual( + (client.descriptors.page.listNotes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listNotesStream with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listNotes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listNotesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1.Note[] = []; + stream.on('data', (response: protos.grafeas.v1.Note) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listNotes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNotes, request)); + assert.strictEqual( + (client.descriptors.page.listNotes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNotes without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Note()), + generateSampleMessage(new protos.grafeas.v1.Note()), + generateSampleMessage(new protos.grafeas.v1.Note()), + ]; + client.descriptors.page.listNotes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.grafeas.v1.INote[] = []; + const iterable = client.listNotesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNotes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNotes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNotes with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listNotes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNotesAsync(request); + await assert.rejects(async () => { + const responses: protos.grafeas.v1.INote[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNotes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNotes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listNoteOccurrences', () => { + it('invokes listNoteOccurrences without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + ]; + client.innerApiCalls.listNoteOccurrences = stubSimpleCall(expectedResponse); + const [response] = await client.listNoteOccurrences(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listNoteOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listNoteOccurrences without error using callback', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + ]; + client.innerApiCalls.listNoteOccurrences = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNoteOccurrences( + request, + (err?: Error|null, result?: protos.grafeas.v1.IOccurrence[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listNoteOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listNoteOccurrences with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listNoteOccurrences = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listNoteOccurrences(request), expectedError); + assert((client.innerApiCalls.listNoteOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listNoteOccurrencesStream without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + ]; + client.descriptors.page.listNoteOccurrences.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listNoteOccurrencesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1.Occurrence[] = []; + stream.on('data', (response: protos.grafeas.v1.Occurrence) => { + 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.listNoteOccurrences.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNoteOccurrences, request)); + assert.strictEqual( + (client.descriptors.page.listNoteOccurrences.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listNoteOccurrencesStream with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedError = new Error('expected'); + client.descriptors.page.listNoteOccurrences.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listNoteOccurrencesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1.Occurrence[] = []; + stream.on('data', (response: protos.grafeas.v1.Occurrence) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listNoteOccurrences.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNoteOccurrences, request)); + assert.strictEqual( + (client.descriptors.page.listNoteOccurrences.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNoteOccurrences without error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1.Occurrence()), + ]; + client.descriptors.page.listNoteOccurrences.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.grafeas.v1.IOccurrence[] = []; + const iterable = client.listNoteOccurrencesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNoteOccurrences with error', async () => { + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listNoteOccurrences.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNoteOccurrencesAsync(request); + await assert.rejects(async () => { + const responses: protos.grafeas.v1.IOccurrence[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('note', () => { + const fakePath = "/rendered/path/note"; + const expectedParameters = { + project: "projectValue", + note: "noteValue", + }; + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.notePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.notePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('notePath', () => { + const result = client.notePath("projectValue", "noteValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.notePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromNoteName', () => { + const result = client.matchProjectFromNoteName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.notePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchNoteFromNoteName', () => { + const result = client.matchNoteFromNoteName(fakePath); + assert.strictEqual(result, "noteValue"); + assert((client.pathTemplates.notePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('occurrence', () => { + const fakePath = "/rendered/path/occurrence"; + const expectedParameters = { + project: "projectValue", + occurrence: "occurrenceValue", + }; + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.occurrencePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.occurrencePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('occurrencePath', () => { + const result = client.occurrencePath("projectValue", "occurrenceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.occurrencePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromOccurrenceName', () => { + const result = client.matchProjectFromOccurrenceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.occurrencePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchOccurrenceFromOccurrenceName', () => { + const result = client.matchOccurrenceFromOccurrenceName(fakePath); + assert.strictEqual(result, "occurrenceValue"); + assert((client.pathTemplates.occurrencePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new grafeasModule.v1.GrafeasClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 0000000..f9beacf --- /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: 'containeranalysis', + filename: './containeranalysis.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v1beta1/.eslintignore b/owl-bot-staging/v1beta1/.eslintignore new file mode 100644 index 0000000..521dc25 --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintignore @@ -0,0 +1,6 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ diff --git a/owl-bot-staging/v1beta1/.eslintrc.json b/owl-bot-staging/v1beta1/.eslintrc.json new file mode 100644 index 0000000..7821534 --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1beta1/.gitignore b/owl-bot-staging/v1beta1/.gitignore new file mode 100644 index 0000000..5d32b23 --- /dev/null +++ b/owl-bot-staging/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1beta1/.jsdoc.js b/owl-bot-staging/v1beta1/.jsdoc.js new file mode 100644 index 0000000..cb937ac --- /dev/null +++ b/owl-bot-staging/v1beta1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2021 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/containeranalysis', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1beta1/.mocharc.js b/owl-bot-staging/v1beta1/.mocharc.js new file mode 100644 index 0000000..50bc7f7 --- /dev/null +++ b/owl-bot-staging/v1beta1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1beta1/.prettierrc.js b/owl-bot-staging/v1beta1/.prettierrc.js new file mode 100644 index 0000000..84f4713 --- /dev/null +++ b/owl-bot-staging/v1beta1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1beta1/README.md b/owl-bot-staging/v1beta1/README.md new file mode 100644 index 0000000..dc843b7 --- /dev/null +++ b/owl-bot-staging/v1beta1/README.md @@ -0,0 +1 @@ +Containeranalysis: Nodejs Client diff --git a/owl-bot-staging/v1beta1/linkinator.config.json b/owl-bot-staging/v1beta1/linkinator.config.json new file mode 100644 index 0000000..29a223b --- /dev/null +++ b/owl-bot-staging/v1beta1/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json new file mode 100644 index 0000000..ecba9da --- /dev/null +++ b/owl-bot-staging/v1beta1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/containeranalysis", + "version": "0.1.0", + "description": "Containeranalysis client for Node.js", + "repository": "googleapis/nodejs-containeranalysis", + "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 containeranalysis", + "containeranalysis", + "container analysis v1 beta1", + "grafeas v1 beta1" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.15.0" + }, + "devDependencies": { + "@types/mocha": "^8.2.2", + "@types/node": "^14.17.3", + "@types/sinon": "^10.0.2", + "c8": "^7.7.3", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.0", + "jsdoc-region-tag": "^1.1.0", + "linkinator": "^2.13.6", + "mocha": "^8.4.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.1", + "ts-loader": "^9.2.3", + "typescript": "^4.3.4", + "webpack": "^5.39.1", + "webpack-cli": "^4.7.2" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto new file mode 100644 index 0000000..0d3d6c9 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto @@ -0,0 +1,170 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.attestation; + +import "google/devtools/containeranalysis/v1beta1/common/common.proto"; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/attestation;attestation"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1.attestation"; +option objc_class_prefix = "GRA"; + +// An attestation wrapper with a PGP-compatible signature. This message only +// supports `ATTACHED` signatures, where the payload that is signed is included +// alongside the signature itself in the same file. +message PgpSignedAttestation { + // Required. The raw content of the signature, as output by GNU Privacy Guard + // (GPG) or equivalent. Since this message only supports attached signatures, + // the payload that was signed must be attached. While the signature format + // supported is dependent on the verification implementation, currently only + // ASCII-armored (`--armor` to gpg), non-clearsigned (`--sign` rather than + // `--clearsign` to gpg) are supported. Concretely, `gpg --sign --armor + // --output=signature.gpg payload.json` will create the signature content + // expected in this field in `signature.gpg` for the `payload.json` + // attestation payload. + string signature = 1; + + // Type (for example schema) of the attestation payload that was signed. + enum ContentType { + // `ContentType` is not set. + CONTENT_TYPE_UNSPECIFIED = 0; + // Atomic format attestation signature. See + // https://github.com/containers/image/blob/8a5d2f82a6e3263290c8e0276c3e0f64e77723e7/docs/atomic-signature.md + // The payload extracted from `signature` is a JSON blob conforming to the + // linked schema. + SIMPLE_SIGNING_JSON = 1; + } + + // Type (for example schema) of the attestation payload that was signed. + // The verifier must ensure that the provided type is one that the verifier + // supports, and that the attestation payload is a valid instantiation of that + // type (for example by validating a JSON schema). + ContentType content_type = 3; + + // This field is used by verifiers to select the public key used to validate + // the signature. Note that the policy of the verifier ultimately determines + // which public keys verify a signature based on the context of the + // verification. There is no guarantee validation will succeed if the + // verifier has no key matching this ID, even if it has a key under a + // different ID that would verify the signature. Note that this ID should also + // be present in the signature content above, but that is not expected to be + // used by the verifier. + oneof key_id { + // The cryptographic fingerprint of the key used to generate the signature, + // as output by, e.g. `gpg --list-keys`. This should be the version 4, full + // 160-bit fingerprint, expressed as a 40 character hexidecimal string. See + // https://tools.ietf.org/html/rfc4880#section-12.2 for details. + // Implementations may choose to acknowledge "LONG", "SHORT", or other + // abbreviated key IDs, but only the full fingerprint is guaranteed to work. + // In gpg, the full fingerprint can be retrieved from the `fpr` field + // returned when calling --list-keys with --with-colons. For example: + // ``` + // gpg --with-colons --with-fingerprint --force-v4-certs \ + // --list-keys attester@example.com + // tru::1:1513631572:0:3:1:5 + // pub:...... + // fpr:::::::::24FF6481B76AC91E66A00AC657A93A81EF3AE6FB: + // ``` + // Above, the fingerprint is `24FF6481B76AC91E66A00AC657A93A81EF3AE6FB`. + string pgp_key_id = 2; + } +} + +// An attestation wrapper that uses the Grafeas `Signature` message. +// This attestation must define the `serialized_payload` that the `signatures` +// verify and any metadata necessary to interpret that plaintext. The +// signatures should always be over the `serialized_payload` bytestring. +message GenericSignedAttestation { + // Type of the attestation plaintext that was signed. + enum ContentType { + // `ContentType` is not set. + CONTENT_TYPE_UNSPECIFIED = 0; + // Atomic format attestation signature. See + // https://github.com/containers/image/blob/8a5d2f82a6e3263290c8e0276c3e0f64e77723e7/docs/atomic-signature.md + // The payload extracted in `plaintext` is a JSON blob conforming to the + // linked schema. + SIMPLE_SIGNING_JSON = 1; + } + + // Type (for example schema) of the attestation payload that was signed. + // The verifier must ensure that the provided type is one that the verifier + // supports, and that the attestation payload is a valid instantiation of that + // type (for example by validating a JSON schema). + ContentType content_type = 1; + + // The serialized payload that is verified by one or more `signatures`. + // The encoding and semantic meaning of this payload must match what is set in + // `content_type`. + bytes serialized_payload = 2; + + // One or more signatures over `serialized_payload`. Verifier implementations + // should consider this attestation message verified if at least one + // `signature` verifies `serialized_payload`. See `Signature` in common.proto + // for more details on signature structure and verification. + repeated Signature signatures = 3; +} + +// Note kind that represents a logical attestation "role" or "authority". For +// example, an organization might have one `Authority` for "QA" and one for +// "build". This note is intended to act strictly as a grouping mechanism for +// the attached occurrences (Attestations). This grouping mechanism also +// provides a security boundary, since IAM ACLs gate the ability for a principle +// to attach an occurrence to a given note. It also provides a single point of +// lookup to find all attached attestation occurrences, even if they don't all +// live in the same project. +message Authority { + // This submessage provides human-readable hints about the purpose of the + // authority. Because the name of a note acts as its resource reference, it is + // important to disambiguate the canonical name of the Note (which might be a + // UUID for security purposes) from "readable" names more suitable for debug + // output. Note that these hints should not be used to look up authorities in + // security sensitive contexts, such as when looking up attestations to + // verify. + message Hint { + // Required. The human readable name of this attestation authority, for + // example "qa". + string human_readable_name = 1; + } + + // Hint hints at the purpose of the attestation authority. + Hint hint = 1; +} + +// Details of an attestation occurrence. +message Details { + // Required. Attestation for the resource. + Attestation attestation = 1; +} + +// Occurrence that represents a single "attestation". The authenticity of an +// attestation can be verified using the attached signature. If the verifier +// trusts the public key of the signer, then verifying the signature is +// sufficient to establish trust. In this circumstance, the authority to which +// this attestation is attached is primarily useful for look-up (how to find +// this attestation if you already know the authority and artifact to be +// verified) and intent (which authority was this attestation intended to sign +// for). +message Attestation { + // Required. The signature, generally over the `resource_url`, that verifies + // this attestation. The semantics of the signature veracity are ultimately + // determined by the verification engine. + oneof signature { + // A PGP signed attestation. + PgpSignedAttestation pgp_signed_attestation = 1; + GenericSignedAttestation generic_signed_attestation = 2; + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/common/common.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/common/common.proto new file mode 100644 index 0000000..bb97a31 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/common/common.proto @@ -0,0 +1,101 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/common;common"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1.common"; +option objc_class_prefix = "GRA"; + +// Kind represents the kinds of notes supported. +enum NoteKind { + // Unknown. + NOTE_KIND_UNSPECIFIED = 0; + // The note and occurrence represent a package vulnerability. + VULNERABILITY = 1; + // The note and occurrence assert build provenance. + BUILD = 2; + // This represents an image basis relationship. + IMAGE = 3; + // This represents a package installed via a package manager. + PACKAGE = 4; + // The note and occurrence track deployment events. + DEPLOYMENT = 5; + // The note and occurrence track the initial discovery status of a resource. + DISCOVERY = 6; + // This represents a logical "role" that can attest to artifacts. + ATTESTATION = 7; +} + +// Metadata for any related URL information. +message RelatedUrl { + // Specific URL associated with the resource. + string url = 1; + // Label to describe usage of the URL. + string label = 2; +} + +// Verifiers (e.g. Kritis implementations) MUST verify signatures +// with respect to the trust anchors defined in policy (e.g. a Kritis policy). +// Typically this means that the verifier has been configured with a map from +// `public_key_id` to public key material (and any required parameters, e.g. +// signing algorithm). +// +// In particular, verification implementations MUST NOT treat the signature +// `public_key_id` as anything more than a key lookup hint. The `public_key_id` +// DOES NOT validate or authenticate a public key; it only provides a mechanism +// for quickly selecting a public key ALREADY CONFIGURED on the verifier through +// a trusted channel. Verification implementations MUST reject signatures in any +// of the following circumstances: +// * The `public_key_id` is not recognized by the verifier. +// * The public key that `public_key_id` refers to does not verify the +// signature with respect to the payload. +// +// The `signature` contents SHOULD NOT be "attached" (where the payload is +// included with the serialized `signature` bytes). Verifiers MUST ignore any +// "attached" payload and only verify signatures with respect to explicitly +// provided payload (e.g. a `payload` field on the proto message that holds +// this Signature, or the canonical serialization of the proto message that +// holds this signature). +message Signature { + // The content of the signature, an opaque bytestring. + // The payload that this signature verifies MUST be unambiguously provided + // with the Signature during verification. A wrapper message might provide + // the payload explicitly. Alternatively, a message might have a canonical + // serialization that can always be unambiguously computed to derive the + // payload. + bytes signature = 1; + + // The identifier for the public key that verifies this signature. + // * The `public_key_id` is required. + // * The `public_key_id` MUST be an RFC3986 conformant URI. + // * When possible, the `public_key_id` SHOULD be an immutable reference, + // such as a cryptographic digest. + // + // Examples of valid `public_key_id`s: + // + // OpenPGP V4 public key fingerprint: + // * "openpgp4fpr:74FAF3B861BDA0870C7B6DEF607E48D2A663AEEA" + // See https://www.iana.org/assignments/uri-schemes/prov/openpgp4fpr for more + // details on this scheme. + // + // RFC6920 digest-named SubjectPublicKeyInfo (digest of the DER + // serialization): + // * "ni:///sha-256;cD9o9Cq6LG3jD0iKXqEi_vdjJGecm_iXkbqVoScViaU" + // * "nih:///sha-256;703f68f42aba2c6de30f488a5ea122fef76324679c9bf89791ba95a1271589a5" + string public_key_id = 2; +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto new file mode 100644 index 0000000..59f3ecd --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto @@ -0,0 +1,219 @@ +// 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.devtools.containeranalysis.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1;containeranalysis"; +option java_multiple_files = true; +option java_package = "com.google.containeranalysis.v1beta1"; +option objc_class_prefix = "GCA"; + +// Retrieves analysis results of Cloud components such as Docker container +// images. The Container Analysis API is an implementation of the +// [Grafeas](grafeas.io) API. +// +// Analysis results are stored as a series of occurrences. An `Occurrence` +// contains information about a specific analysis instance on a resource. An +// occurrence refers to a `Note`. A note contains details describing the +// analysis and is generally stored in a separate project, called a `Provider`. +// Multiple occurrences can refer to the same note. +// +// For example, an SSL vulnerability could affect multiple images. In this case, +// there would be one note for the vulnerability and an occurrence for each +// image with the vulnerability referring to that note. +service ContainerAnalysisV1Beta1 { + option (google.api.default_host) = "containeranalysis.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Sets the access control policy on the specified note or occurrence. + // Requires `containeranalysis.notes.setIamPolicy` or + // `containeranalysis.occurrences.setIamPolicy` permission if the resource is + // a note or an occurrence, respectively. + // + // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + // occurrences. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1beta1/{resource=projects/*/notes/*}:setIamPolicy" + body: "*" + additional_bindings { + post: "/v1beta1/{resource=projects/*/occurrences/*}:setIamPolicy" + body: "*" + } + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Gets the access control policy for a note or an occurrence resource. + // Requires `containeranalysis.notes.setIamPolicy` or + // `containeranalysis.occurrences.setIamPolicy` permission if the resource is + // a note or occurrence, respectively. + // + // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + // occurrences. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1beta1/{resource=projects/*/notes/*}:getIamPolicy" + body: "*" + additional_bindings { + post: "/v1beta1/{resource=projects/*/occurrences/*}:getIamPolicy" + body: "*" + } + }; + option (google.api.method_signature) = "resource"; + } + + // Returns the permissions that a caller has on the specified note or + // occurrence. Requires list permission on the project (for example, + // `containeranalysis.notes.list`). + // + // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + // occurrences. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v1beta1/{resource=projects/*/notes/*}:testIamPermissions" + body: "*" + additional_bindings { + post: "/v1beta1/{resource=projects/*/occurrences/*}:testIamPermissions" + body: "*" + } + }; + option (google.api.method_signature) = "resource,permissions"; + } + + // Gets the specified scan configuration. + rpc GetScanConfig(GetScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/scanConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists scan configurations for the specified project. + rpc ListScanConfigs(ListScanConfigsRequest) returns (ListScanConfigsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*}/scanConfigs" + }; + option (google.api.method_signature) = "parent,filter"; + } + + // Updates the specified scan configuration. + rpc UpdateScanConfig(UpdateScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + put: "/v1beta1/{name=projects/*/scanConfigs/*}" + body: "scan_config" + }; + option (google.api.method_signature) = "name,scan_config"; + } +} + +// A scan configuration specifies whether Cloud components in a project have a +// particular type of analysis being run. For example, it can configure whether +// vulnerability scanning is being done on Docker images or not. +message ScanConfig { + option (google.api.resource) = { + type: "containeranalysis.googleapis.com/ScanConfig" + pattern: "projects/{project}/scanConfigs/{scan_config}" + }; + + // Output only. The name of the scan configuration in the form of + // `projects/[PROJECT_ID]/scanConfigs/[SCAN_CONFIG_ID]`. + string name = 1; + + // Output only. A human-readable description of what the scan configuration + // does. + string description = 2; + + // Whether the scan is enabled. + bool enabled = 3; + + // Output only. The time this scan config was created. + google.protobuf.Timestamp create_time = 4; + + // Output only. The time this scan config was last updated. + google.protobuf.Timestamp update_time = 5; +} + +// Request to get a scan configuration. +message GetScanConfigRequest { + // Required. The name of the scan configuration in the form of + // `projects/[PROJECT_ID]/scanConfigs/[SCAN_CONFIG_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "containeranalysis.googleapis.com/ScanConfig" + } + ]; +} + +// Request to list scan configurations. +message ListScanConfigsRequest { + // Required. The name of the project to list scan configurations for in the form of + // `projects/[PROJECT_ID]`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The filter expression. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // The number of scan configs to return in the list. + int32 page_size = 3; + + // Token to provide to skip to a particular spot in the list. + string page_token = 4; +} + +// Response for listing scan configurations. +message ListScanConfigsResponse { + // The scan configurations requested. + repeated ScanConfig scan_configs = 1; + + // The next pagination token in the list response. It should be used as + // `page_token` for the following request. An empty value means no more + // results. + string next_page_token = 2; +} + +// A request to update a scan configuration. +message UpdateScanConfigRequest { + // Required. The name of the scan configuration in the form of + // `projects/[PROJECT_ID]/scanConfigs/[SCAN_CONFIG_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "containeranalysis.googleapis.com/ScanConfig" + } + ]; + + // Required. The updated scan configuration. + ScanConfig scan_config = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto new file mode 100644 index 0000000..3484441 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto @@ -0,0 +1,85 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.vulnerability; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/cvss;cvss"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1.vulnerability"; +option objc_class_prefix = "GRA"; + +// Common Vulnerability Scoring System version 3. +// For details, see https://www.first.org/cvss/specification-document +message CVSSv3 { + // The base score is a function of the base metric scores. + float base_score = 1; + + float exploitability_score = 2; + + float impact_score = 3; + + // Base Metrics + // Represents the intrinsic characteristics of a vulnerability that are + // constant over time and across user environments. + AttackVector attack_vector = 5; + AttackComplexity attack_complexity = 6; + PrivilegesRequired privileges_required = 7; + UserInteraction user_interaction = 8; + Scope scope = 9; + Impact confidentiality_impact = 10; + Impact integrity_impact = 11; + Impact availability_impact = 12; + + enum AttackVector { + ATTACK_VECTOR_UNSPECIFIED = 0; + ATTACK_VECTOR_NETWORK = 1; + ATTACK_VECTOR_ADJACENT = 2; + ATTACK_VECTOR_LOCAL = 3; + ATTACK_VECTOR_PHYSICAL = 4; + } + + enum AttackComplexity { + ATTACK_COMPLEXITY_UNSPECIFIED = 0; + ATTACK_COMPLEXITY_LOW = 1; + ATTACK_COMPLEXITY_HIGH = 2; + } + + enum PrivilegesRequired { + PRIVILEGES_REQUIRED_UNSPECIFIED = 0; + PRIVILEGES_REQUIRED_NONE = 1; + PRIVILEGES_REQUIRED_LOW = 2; + PRIVILEGES_REQUIRED_HIGH = 3; + } + + enum UserInteraction { + USER_INTERACTION_UNSPECIFIED = 0; + USER_INTERACTION_NONE = 1; + USER_INTERACTION_REQUIRED = 2; + } + + enum Scope { + SCOPE_UNSPECIFIED = 0; + SCOPE_UNCHANGED = 1; + SCOPE_CHANGED = 2; + } + + enum Impact { + IMPACT_UNSPECIFIED = 0; + IMPACT_HIGH = 1; + IMPACT_LOW = 2; + IMPACT_NONE = 3; + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto new file mode 100644 index 0000000..7bc8dc8 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto @@ -0,0 +1,74 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.deployment; + +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/deployment;deployment"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1.deployment"; +option objc_class_prefix = "GRA"; + +// An artifact that can be deployed in some runtime. +message Deployable { + // Required. Resource URI for the artifact being deployed. + repeated string resource_uri = 1; +} + +// Details of a deployment occurrence. +message Details { + // Required. Deployment history for the resource. + Deployment deployment = 1; +} + +// The period during which some deployable was active in a runtime. +message Deployment { + // Identity of the user that triggered this deployment. + string user_email = 1; + + // Required. Beginning of the lifetime of this deployment. + google.protobuf.Timestamp deploy_time = 2; + + // End of the lifetime of this deployment. + google.protobuf.Timestamp undeploy_time = 3; + + // Configuration used to create this deployment. + string config = 4; + + // Address of the runtime element hosting this deployment. + string address = 5; + + // Output only. Resource URI for the artifact being deployed taken from + // the deployable field with the same name. + repeated string resource_uri = 6; + + // Types of platforms. + enum Platform { + // Unknown. + PLATFORM_UNSPECIFIED = 0; + // Google Container Engine. + GKE = 1; + // Google App Engine: Flexible Environment. + FLEX = 2; + // Custom user-defined platform. + CUSTOM = 3; + } + // Platform hosting this deployment. + Platform platform = 7; + + // next_id = 8; +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto new file mode 100644 index 0000000..edfa043 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto @@ -0,0 +1,86 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.discovery; + +import "google/devtools/containeranalysis/v1beta1/common/common.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/discovery;discovery"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1.discovery"; +option objc_class_prefix = "GRA"; + +// A note that indicates a type of analysis a provider would perform. This note +// exists in a provider's project. A `Discovery` occurrence is created in a +// consumer's project at the start of analysis. +message Discovery { + // Required. Immutable. The kind of analysis that is handled by this + // discovery. + grafeas.v1beta1.NoteKind analysis_kind = 1; +} + +// Details of a discovery occurrence. +message Details { + // Required. Analysis status for the discovered resource. + Discovered discovered = 1; +} + +// Provides information about the analysis status of a discovered resource. +message Discovered { + // Whether the resource is continuously analyzed. + enum ContinuousAnalysis { + // Unknown. + CONTINUOUS_ANALYSIS_UNSPECIFIED = 0; + // The resource is continuously analyzed. + ACTIVE = 1; + // The resource is ignored for continuous analysis. + INACTIVE = 2; + } + + // Whether the resource is continuously analyzed. + ContinuousAnalysis continuous_analysis = 1; + + // The last time continuous analysis was done for this resource. + google.protobuf.Timestamp last_analysis_time = 2; + + // Analysis status for a resource. Currently for initial analysis only (not + // updated in continuous analysis). + enum AnalysisStatus { + // Unknown. + ANALYSIS_STATUS_UNSPECIFIED = 0; + // Resource is known but no action has been taken yet. + PENDING = 1; + // Resource is being analyzed. + SCANNING = 2; + // Analysis has finished successfully. + FINISHED_SUCCESS = 3; + // Analysis has finished unsuccessfully, the analysis itself is in a bad + // state. + FINISHED_FAILED = 4; + // The resource is known not to be supported + FINISHED_UNSUPPORTED = 5; + } + + // The status of discovery for the resource. + AnalysisStatus analysis_status = 3; + + // When an error is encountered this will contain a LocalizedMessage under + // details to show to the user. The LocalizedMessage is output only and + // populated by the API. + google.rpc.Status analysis_status_error = 4; +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto new file mode 100644 index 0000000..8952164 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto @@ -0,0 +1,506 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/devtools/containeranalysis/v1beta1/attestation/attestation.proto"; +import "google/devtools/containeranalysis/v1beta1/build/build.proto"; +import "google/devtools/containeranalysis/v1beta1/common/common.proto"; +import "google/devtools/containeranalysis/v1beta1/deployment/deployment.proto"; +import "google/devtools/containeranalysis/v1beta1/discovery/discovery.proto"; +import "google/devtools/containeranalysis/v1beta1/image/image.proto"; +import "google/devtools/containeranalysis/v1beta1/package/package.proto"; +import "google/devtools/containeranalysis/v1beta1/provenance/provenance.proto"; +import "google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas;grafeas"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1"; +option objc_class_prefix = "GRA"; + +// [Grafeas](grafeas.io) API. +// +// Retrieves analysis results of Cloud components such as Docker container +// images. +// +// Analysis results are stored as a series of occurrences. An `Occurrence` +// contains information about a specific analysis instance on a resource. An +// occurrence refers to a `Note`. A note contains details describing the +// analysis and is generally stored in a separate project, called a `Provider`. +// Multiple occurrences can refer to the same note. +// +// For example, an SSL vulnerability could affect multiple images. In this case, +// there would be one note for the vulnerability and an occurrence for each +// image with the vulnerability referring to that note. +service GrafeasV1Beta1 { + option (google.api.default_host) = "containeranalysis.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Gets the specified occurrence. + rpc GetOccurrence(GetOccurrenceRequest) returns (Occurrence) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/occurrences/*}" + }; + } + + // Lists occurrences for the specified project. + rpc ListOccurrences(ListOccurrencesRequest) + returns (ListOccurrencesResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*}/occurrences" + }; + } + + // Deletes the specified occurrence. For example, use this method to delete an + // occurrence when the occurrence is no longer applicable for the given + // resource. + rpc DeleteOccurrence(DeleteOccurrenceRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/occurrences/*}" + }; + } + + // Creates a new occurrence. + rpc CreateOccurrence(CreateOccurrenceRequest) returns (Occurrence) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*}/occurrences" + body: "occurrence" + }; + } + + // Creates new occurrences in batch. + rpc BatchCreateOccurrences(BatchCreateOccurrencesRequest) + returns (BatchCreateOccurrencesResponse) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*}/occurrences:batchCreate" + body: "*" + }; + } + + // Updates the specified occurrence. + rpc UpdateOccurrence(UpdateOccurrenceRequest) returns (Occurrence) { + option (google.api.http) = { + patch: "/v1beta1/{name=projects/*/occurrences/*}" + body: "occurrence" + }; + } + + // Gets the note attached to the specified occurrence. Consumer projects can + // use this method to get a note that belongs to a provider project. + rpc GetOccurrenceNote(GetOccurrenceNoteRequest) returns (Note) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/occurrences/*}/notes" + }; + } + + // Gets the specified note. + rpc GetNote(GetNoteRequest) returns (Note) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/notes/*}" + }; + } + + // Lists notes for the specified project. + rpc ListNotes(ListNotesRequest) returns (ListNotesResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*}/notes" + }; + } + + // Deletes the specified note. + rpc DeleteNote(DeleteNoteRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/notes/*}" + }; + } + + // Creates a new note. + rpc CreateNote(CreateNoteRequest) returns (Note) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*}/notes" + body: "note" + }; + } + + // Creates new notes in batch. + rpc BatchCreateNotes(BatchCreateNotesRequest) + returns (BatchCreateNotesResponse) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*}/notes:batchCreate" + body: "*" + }; + } + + // Updates the specified note. + rpc UpdateNote(UpdateNoteRequest) returns (Note) { + option (google.api.http) = { + patch: "/v1beta1/{name=projects/*/notes/*}" + body: "note" + }; + } + + // Lists occurrences referencing the specified note. Provider projects can use + // this method to get all occurrences across consumer projects referencing the + // specified note. + rpc ListNoteOccurrences(ListNoteOccurrencesRequest) + returns (ListNoteOccurrencesResponse) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/notes/*}/occurrences" + }; + } + + // Gets a summary of the number and severity of occurrences. + rpc GetVulnerabilityOccurrencesSummary( + GetVulnerabilityOccurrencesSummaryRequest) + returns (VulnerabilityOccurrencesSummary) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*}/occurrences:vulnerabilitySummary" + }; + } +} + +// An instance of an analysis type that has been found on a resource. +message Occurrence { + // Output only. The name of the occurrence in the form of + // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + string name = 1; + + // Required. Immutable. The resource for which the occurrence applies. + Resource resource = 2; + + // Required. Immutable. The analysis note associated with this occurrence, in + // the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. This field can be + // used as a filter in list requests. + string note_name = 3; + + // Output only. This explicitly denotes which of the occurrence details are + // specified. This field can be used as a filter in list requests. + grafeas.v1beta1.NoteKind kind = 4; + + // A description of actions that can be taken to remedy the note. + string remediation = 5; + + // Output only. The time this occurrence was created. + google.protobuf.Timestamp create_time = 6; + + // Output only. The time this occurrence was last updated. + google.protobuf.Timestamp update_time = 7; + + // Required. Immutable. Describes the details of the note kind found on this + // resource. + oneof details { + // Describes a security vulnerability. + grafeas.v1beta1.vulnerability.Details vulnerability = 8; + // Describes a verifiable build. + grafeas.v1beta1.build.Details build = 9; + // Describes how this resource derives from the basis in the associated + // note. + grafeas.v1beta1.image.Details derived_image = 10; + // Describes the installation of a package on the linked resource. + grafeas.v1beta1.package.Details installation = 11; + // Describes the deployment of an artifact on a runtime. + grafeas.v1beta1.deployment.Details deployment = 12; + // Describes when a resource was discovered. + grafeas.v1beta1.discovery.Details discovered = 13; + // Describes an attestation of an artifact. + grafeas.v1beta1.attestation.Details attestation = 14; + } + + // next_id = 15; +} + +// An entity that can have metadata. For example, a Docker image. +message Resource { + // The name of the resource. For example, the name of a Docker image - + // "Debian". + string name = 1; + // Required. The unique URI of the resource. For example, + // `https://gcr.io/project/image@sha256:foo` for a Docker image. + string uri = 2; + // The hash of the resource content. For example, the Docker digest. + grafeas.v1beta1.provenance.Hash content_hash = 3; + + // next_id = 4; +} + +// A type of analysis that can be done for a resource. +message Note { + // Output only. The name of the note in the form of + // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + string name = 1; + + // A one sentence description of this note. + string short_description = 2; + + // A detailed description of this note. + string long_description = 3; + + // Output only. The type of analysis. This field can be used as a filter in + // list requests. + grafeas.v1beta1.NoteKind kind = 4; + + // URLs associated with this note. + repeated grafeas.v1beta1.RelatedUrl related_url = 5; + + // Time of expiration for this note. Empty if note does not expire. + google.protobuf.Timestamp expiration_time = 6; + + // Output only. The time this note was created. This field can be used as a + // filter in list requests. + google.protobuf.Timestamp create_time = 7; + + // Output only. The time this note was last updated. This field can be used as + // a filter in list requests. + google.protobuf.Timestamp update_time = 8; + + // Other notes related to this note. + repeated string related_note_names = 9; + + // Required. Immutable. The type of analysis this note represents. + oneof type { + // A note describing a package vulnerability. + grafeas.v1beta1.vulnerability.Vulnerability vulnerability = 10; + // A note describing build provenance for a verifiable build. + grafeas.v1beta1.build.Build build = 11; + // A note describing a base image. + grafeas.v1beta1.image.Basis base_image = 12; + // A note describing a package hosted by various package managers. + grafeas.v1beta1.package.Package package = 13; + // A note describing something that can be deployed. + grafeas.v1beta1.deployment.Deployable deployable = 14; + // A note describing the initial analysis of a resource. + grafeas.v1beta1.discovery.Discovery discovery = 15; + // A note describing an attestation role. + grafeas.v1beta1.attestation.Authority attestation_authority = 16; + } + + // next_id = 17; +} + +// Request to get an occurrence. +message GetOccurrenceRequest { + // The name of the occurrence in the form of + // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + string name = 1; +} + +// Request to list occurrences. +message ListOccurrencesRequest { + // The name of the project to list occurrences for in the form of + // `projects/[PROJECT_ID]`. + string parent = 1; + + // The filter expression. + string filter = 2; + + // Number of occurrences to return in the list. + int32 page_size = 3; + + // Token to provide to skip to a particular spot in the list. + string page_token = 4; + + // next_id = 7; +} + +// Response for listing occurrences. +message ListOccurrencesResponse { + // The occurrences requested. + repeated Occurrence occurrences = 1; + // The next pagination token in the list response. It should be used as + // `page_token` for the following request. An empty value means no more + // results. + string next_page_token = 2; +} + +// Request to delete a occurrence. +message DeleteOccurrenceRequest { + // The name of the occurrence in the form of + // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + string name = 1; +} + +// Request to create a new occurrence. +message CreateOccurrenceRequest { + // The name of the project in the form of `projects/[PROJECT_ID]`, under which + // the occurrence is to be created. + string parent = 1; + // The occurrence to create. + Occurrence occurrence = 2; +} + +// Request to update an occurrence. +message UpdateOccurrenceRequest { + // The name of the occurrence in the form of + // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + string name = 1; + // The updated occurrence. + Occurrence occurrence = 2; + // The fields to update. + google.protobuf.FieldMask update_mask = 3; +} + +// Request to get a note. +message GetNoteRequest { + // The name of the note in the form of + // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + string name = 1; +} + +// Request to get the note to which the specified occurrence is attached. +message GetOccurrenceNoteRequest { + // The name of the occurrence in the form of + // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + string name = 1; +} + +// Request to list notes. +message ListNotesRequest { + // The name of the project to list notes for in the form of + // `projects/[PROJECT_ID]`. + string parent = 1; + // The filter expression. + string filter = 2; + // Number of notes to return in the list. + int32 page_size = 3; + // Token to provide to skip to a particular spot in the list. + string page_token = 4; +} + +// Response for listing notes. +message ListNotesResponse { + // The notes requested. + repeated Note notes = 1; + // The next pagination token in the list response. It should be used as + // `page_token` for the following request. An empty value means no more + // results. + string next_page_token = 2; +} + +// Request to delete a note. +message DeleteNoteRequest { + // The name of the note in the form of + // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + string name = 1; +} + +// Request to create a new note. +message CreateNoteRequest { + // The name of the project in the form of `projects/[PROJECT_ID]`, under which + // the note is to be created. + string parent = 1; + // The ID to use for this note. + string note_id = 2; + // The note to create. + Note note = 3; +} + +// Request to update a note. +message UpdateNoteRequest { + // The name of the note in the form of + // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + string name = 1; + // The updated note. + Note note = 2; + // The fields to update. + google.protobuf.FieldMask update_mask = 3; +} + +// Request to list occurrences for a note. +message ListNoteOccurrencesRequest { + // The name of the note to list occurrences for in the form of + // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + string name = 1; + // The filter expression. + string filter = 2; + // Number of occurrences to return in the list. + int32 page_size = 3; + // Token to provide to skip to a particular spot in the list. + string page_token = 4; +} + +// Response for listing occurrences for a note. +message ListNoteOccurrencesResponse { + // The occurrences attached to the specified note. + repeated Occurrence occurrences = 1; + // Token to provide to skip to a particular spot in the list. + string next_page_token = 2; +} + +// Request to create notes in batch. +message BatchCreateNotesRequest { + // The name of the project in the form of `projects/[PROJECT_ID]`, under which + // the notes are to be created. + string parent = 1; + + // The notes to create. + map notes = 2; +} + +// Response for creating notes in batch. +message BatchCreateNotesResponse { + // The notes that were created. + repeated Note notes = 1; +} + +// Request to create occurrences in batch. +message BatchCreateOccurrencesRequest { + // The name of the project in the form of `projects/[PROJECT_ID]`, under which + // the occurrences are to be created. + string parent = 1; + // The occurrences to create. + repeated Occurrence occurrences = 2; +} + +// Response for creating occurrences in batch. +message BatchCreateOccurrencesResponse { + // The occurrences that were created. + repeated Occurrence occurrences = 1; +} + +// Request to get a vulnerability summary for some set of occurrences. +message GetVulnerabilityOccurrencesSummaryRequest { + // The name of the project to get a vulnerability summary for in the form of + // `projects/[PROJECT_ID]`. + string parent = 1; + // The filter expression. + string filter = 2; +} + +// A summary of how many vulnerability occurrences there are per resource and +// severity type. +message VulnerabilityOccurrencesSummary { + // A listing by resource of the number of fixable and total vulnerabilities. + repeated FixableTotalByDigest counts = 1; + + // Per resource and severity counts of fixable and total vulnerabilities. + message FixableTotalByDigest { + // The affected resource. + Resource resource = 1; + // The severity for this count. SEVERITY_UNSPECIFIED indicates total across + // all severities. + grafeas.v1beta1.vulnerability.Severity severity = 2; + // The number of fixable vulnerabilities associated with this resource. + int64 fixable_count = 3; + // The total number of vulnerabilities associated with this resource. + int64 total_count = 4; + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/image/image.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/image/image.proto new file mode 100644 index 0000000..91ee33e --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/image/image.proto @@ -0,0 +1,145 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.image; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/image;image"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1.image"; +option objc_class_prefix = "GRA"; + +// Layer holds metadata specific to a layer of a Docker image. +message Layer { + // Instructions from Dockerfile. + enum Directive { + // Default value for unsupported/missing directive. + DIRECTIVE_UNSPECIFIED = 0; + + // https://docs.docker.com/engine/reference/builder/ + MAINTAINER = 1; + + // https://docs.docker.com/engine/reference/builder/ + RUN = 2; + + // https://docs.docker.com/engine/reference/builder/ + CMD = 3; + + // https://docs.docker.com/engine/reference/builder/ + LABEL = 4; + + // https://docs.docker.com/engine/reference/builder/ + EXPOSE = 5; + + // https://docs.docker.com/engine/reference/builder/ + ENV = 6; + + // https://docs.docker.com/engine/reference/builder/ + ADD = 7; + + // https://docs.docker.com/engine/reference/builder/ + COPY = 8; + + // https://docs.docker.com/engine/reference/builder/ + ENTRYPOINT = 9; + + // https://docs.docker.com/engine/reference/builder/ + VOLUME = 10; + + // https://docs.docker.com/engine/reference/builder/ + USER = 11; + + // https://docs.docker.com/engine/reference/builder/ + WORKDIR = 12; + + // https://docs.docker.com/engine/reference/builder/ + ARG = 13; + + // https://docs.docker.com/engine/reference/builder/ + ONBUILD = 14; + + // https://docs.docker.com/engine/reference/builder/ + STOPSIGNAL = 15; + + // https://docs.docker.com/engine/reference/builder/ + HEALTHCHECK = 16; + + // https://docs.docker.com/engine/reference/builder/ + SHELL = 17; + } + + // Required. The recovered Dockerfile directive used to construct this layer. + Directive directive = 1; + + // The recovered arguments to the Dockerfile directive. + string arguments = 2; +} + +// A set of properties that uniquely identify a given Docker image. +message Fingerprint { + // Required. The layer ID of the final layer in the Docker image's v1 + // representation. + string v1_name = 1; + + // Required. The ordered list of v2 blobs that represent a given image. + repeated string v2_blob = 2; + + // Output only. The name of the image's v2 blobs computed via: + // [bottom] := v2_blob[bottom] + // [N] := sha256(v2_blob[N] + " " + v2_name[N+1]) + // Only the name of the final blob is kept. + string v2_name = 3; +} + +// Basis describes the base image portion (Note) of the DockerImage +// relationship. Linked occurrences are derived from this or an +// equivalent image via: +// FROM +// Or an equivalent reference, e.g. a tag of the resource_url. +message Basis { + // Required. Immutable. The resource_url for the resource representing the + // basis of associated occurrence images. + string resource_url = 1; + + // Required. Immutable. The fingerprint of the base image. + Fingerprint fingerprint = 2; +} + +// Details of an image occurrence. +message Details { + // Required. Immutable. The child image derived from the base image. + Derived derived_image = 1; +} + +// Derived describes the derived image portion (Occurrence) of the DockerImage +// relationship. This image would be produced from a Dockerfile with FROM +// . +message Derived { + // Required. The fingerprint of the derived image. + Fingerprint fingerprint = 1; + + // Output only. The number of layers by which this image differs from the + // associated image basis. + int32 distance = 2; + + // This contains layer-specific metadata, if populated it has length + // "distance" and is ordered with [distance] being the layer immediately + // following the base image and [1] being the final layer. + repeated Layer layer_info = 3; + + // Output only. This contains the base image URL for the derived image + // occurrence. + string base_resource_url = 4; +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/package/package.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/package/package.proto new file mode 100644 index 0000000..59cac20 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/package/package.proto @@ -0,0 +1,127 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.package; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/package"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1.pkg"; +option objc_class_prefix = "GRA"; + +// Instruction set architectures supported by various package managers. +enum Architecture { + // Unknown architecture. + ARCHITECTURE_UNSPECIFIED = 0; + // X86 architecture. + X86 = 1; + // X64 architecture. + X64 = 2; +} + +// This represents a particular channel of distribution for a given package. +// E.g., Debian's jessie-backports dpkg mirror. +message Distribution { + // Required. The cpe_uri in [CPE format](https://cpe.mitre.org/specification/) + // denoting the package manager version distributing a package. + string cpe_uri = 1; + + // The CPU architecture for which packages in this distribution channel were + // built. + Architecture architecture = 2; + + // The latest available version of this package in this distribution channel. + Version latest_version = 3; + + // A freeform string denoting the maintainer of this package. + string maintainer = 4; + + // The distribution channel-specific homepage for this package. + string url = 5; + + // The distribution channel-specific description of this package. + string description = 6; +} + +// An occurrence of a particular package installation found within a system's +// filesystem. E.g., glibc was found in `/var/lib/dpkg/status`. +message Location { + // Required. The CPE URI in [CPE format](https://cpe.mitre.org/specification/) + // denoting the package manager version distributing a package. + string cpe_uri = 1; + + // The version installed at this location. + Version version = 2; + + // The path from which we gathered that this package/version is installed. + string path = 3; +} + +// This represents a particular package that is distributed over various +// channels. E.g., glibc (aka libc6) is distributed by many, at various +// versions. +message Package { + // Required. Immutable. The name of the package. + string name = 1; + + // The various channels by which a package is distributed. + repeated Distribution distribution = 10; +} + +// Details of a package occurrence. +message Details { + // Required. Where the package was installed. + Installation installation = 1; +} + +// This represents how a particular software package may be installed on a +// system. +message Installation { + // Output only. The name of the installed package. + string name = 1; + + // Required. All of the places within the filesystem versions of this package + // have been found. + repeated Location location = 2; +} + +// Version contains structured information about the version of a package. +message Version { + // Used to correct mistakes in the version numbering scheme. + int32 epoch = 1; + + // Required only when version kind is NORMAL. The main part of the version + // name. + string name = 2; + + // The iteration of the package build from the above version. + string revision = 3; + + // Whether this is an ordinary package version or a sentinel MIN/MAX version. + enum VersionKind { + // Unknown. + VERSION_KIND_UNSPECIFIED = 0; + // A standard package version. + NORMAL = 1; + // A special version representing negative infinity. + MINIMUM = 2; + // A special version representing positive infinity. + MAXIMUM = 3; + }; + + // Required. Distinguishes between sentinel MIN/MAX versions and normal + // versions. + VersionKind kind = 4; +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto new file mode 100644 index 0000000..761877c --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto @@ -0,0 +1,164 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.provenance; + +import "google/devtools/containeranalysis/v1beta1/source/source.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/provenance;provenance"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1.provenance"; +option objc_class_prefix = "GRA"; + +// Provenance of a build. Contains all information needed to verify the full +// details about the build from source to completion. +message BuildProvenance { + // Required. Unique identifier of the build. + string id = 1; + + // ID of the project. + string project_id = 2; + + // Commands requested by the build. + repeated Command commands = 3; + + // Output of the build. + repeated Artifact built_artifacts = 4; + + // Time at which the build was created. + google.protobuf.Timestamp create_time = 5; + + // Time at which execution of the build was started. + google.protobuf.Timestamp start_time = 6; + + // Time at which execution of the build was finished. + google.protobuf.Timestamp end_time = 7; + + // E-mail address of the user who initiated this build. Note that this was the + // user's e-mail address at the time the build was initiated; this address may + // not represent the same end-user for all time. + string creator = 8; + + // URI where any logs for this provenance were written. + string logs_uri = 9; + + // Details of the Source input to the build. + Source source_provenance = 10; + + // Trigger identifier if the build was triggered automatically; empty if not. + string trigger_id = 11; + + // Special options applied to this build. This is a catch-all field where + // build providers can enter any desired additional details. + map build_options = 12; + + // Version string of the builder at the time this build was executed. + string builder_version = 13; + + // next_id = 14 +} + +// Source describes the location of the source used for the build. +message Source { + // If provided, the input binary artifacts for the build came from this + // location. + string artifact_storage_source_uri = 1; + + // Hash(es) of the build source, which can be used to verify that the original + // source integrity was maintained in the build. + // + // The keys to this map are file paths used as build source and the values + // contain the hash values for those files. + // + // If the build source came in a single package such as a gzipped tarfile + // (.tar.gz), the FileHash will be for the single path to that file. + map file_hashes = 2; + + // If provided, the source code used for the build came from this location. + grafeas.v1beta1.source.SourceContext context = 3; + + // If provided, some of the source code used for the build may be found in + // these locations, in the case where the source repository had multiple + // remotes or submodules. This list will not include the context specified in + // the context field. + repeated grafeas.v1beta1.source.SourceContext additional_contexts = 4; +} + +// Container message for hashes of byte content of files, used in source +// messages to verify integrity of source input to the build. +message FileHashes { + // Required. Collection of file hashes. + repeated Hash file_hash = 1; +} + +// Container message for hash values. +message Hash { + // Specifies the hash algorithm. + enum HashType { + // Unknown. + HASH_TYPE_UNSPECIFIED = 0; + // A SHA-256 hash. + SHA256 = 1; + } + + // Required. The type of hash that was performed. + HashType type = 1; + // Required. The hash value. + bytes value = 2; +} + +// Command describes a step performed as part of the build pipeline. +message Command { + // Required. Name of the command, as presented on the command line, or if the + // command is packaged as a Docker container, as presented to `docker pull`. + string name = 1; + + // Environment variables set before running this command. + repeated string env = 2; + + // Command-line arguments used when executing this command. + repeated string args = 3; + + // Working directory (relative to project source root) used when running this + // command. + string dir = 4; + + // Optional unique identifier for this command, used in wait_for to reference + // this command as a dependency. + string id = 5; + + // The ID(s) of the command(s) that this command depends on. + repeated string wait_for = 6; +} + +// Artifact describes a build product. +message Artifact { + // Hash or checksum value of a binary, or Docker Registry 2.0 digest of a + // container. + string checksum = 1; + + // Artifact ID, if any; for container images, this will be a URL by digest + // like `gcr.io/projectID/imagename@sha256:123456`. + string id = 2; + + // Related artifact names. This may be the path to a binary or jar file, or in + // the case of a container build, the name used to push the container image to + // Google Container Registry, as presented to `docker push`. Note that a + // single Artifact ID can have multiple names, for example if two tags are + // applied to one image. + repeated string names = 3; +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/source/source.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/source/source.proto new file mode 100644 index 0000000..01be060 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/source/source.proto @@ -0,0 +1,134 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.source; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/source;source"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1.source"; +option objc_class_prefix = "GRA"; + +// A SourceContext is a reference to a tree of files. A SourceContext together +// with a path point to a unique revision of a single file or directory. +message SourceContext { + // A SourceContext can refer any one of the following types of repositories. + oneof context { + // A SourceContext referring to a revision in a Google Cloud Source Repo. + CloudRepoSourceContext cloud_repo = 1; + + // A SourceContext referring to a Gerrit project. + GerritSourceContext gerrit = 2; + + // A SourceContext referring to any third party Git repo (e.g., GitHub). + GitSourceContext git = 3; + } + + // Labels with user defined metadata. + map labels = 4; +} + +// An alias to a repo revision. +message AliasContext { + // The type of an alias. + enum Kind { + // Unknown. + KIND_UNSPECIFIED = 0; + // Git tag. + FIXED = 1; + // Git branch. + MOVABLE = 2; + // Used to specify non-standard aliases. For example, if a Git repo has a + // ref named "refs/foo/bar". + OTHER = 4; + } + + // The alias kind. + Kind kind = 1; + + // The alias name. + string name = 2; +} + +// A CloudRepoSourceContext denotes a particular revision in a Google Cloud +// Source Repo. +message CloudRepoSourceContext { + // The ID of the repo. + RepoId repo_id = 1; + + // A revision in a Cloud Repo can be identified by either its revision ID or + // its alias. + oneof revision { + // A revision ID. + string revision_id = 2; + + // An alias, which may be a branch or tag. + AliasContext alias_context = 3; + } +} + +// A SourceContext referring to a Gerrit project. +message GerritSourceContext { + // The URI of a running Gerrit instance. + string host_uri = 1; + + // The full project name within the host. Projects may be nested, so + // "project/subproject" is a valid project name. The "repo name" is the + // hostURI/project. + string gerrit_project = 2; + + // A revision in a Gerrit project can be identified by either its revision ID + // or its alias. + oneof revision { + // A revision (commit) ID. + string revision_id = 3; + + // An alias, which may be a branch or tag. + AliasContext alias_context = 4; + } +} + +// A GitSourceContext denotes a particular revision in a third party Git +// repository (e.g., GitHub). +message GitSourceContext { + // Git repository URL. + string url = 1; + + // Git commit hash. + string revision_id = 2; +} + +// A unique identifier for a Cloud Repo. +message RepoId { + // A cloud repo can be identified by either its project ID and repository name + // combination, or its globally unique identifier. + oneof id { + // A combination of a project ID and a repo name. + ProjectRepoId project_repo_id = 1; + + // A server-assigned, globally unique identifier. + string uid = 2; + } +} + +// Selects a repo using a Google Cloud Platform project ID (e.g., +// winged-cargo-31) and a repo name within that project. +message ProjectRepoId { + // The ID of the project. + string project_id = 1; + + // The name of the repo. Leave empty for the default repo. + string repo_name = 2; +} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto new file mode 100644 index 0000000..d83c7e4 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto @@ -0,0 +1,203 @@ +// Copyright 2018 The Grafeas Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.vulnerability; + +import "google/protobuf/timestamp.proto"; +import "google/devtools/containeranalysis/v1beta1/common/common.proto"; +import "google/devtools/containeranalysis/v1beta1/cvss/cvss.proto"; +import "google/devtools/containeranalysis/v1beta1/package/package.proto"; + +option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/vulnerability;vulnerability"; +option java_multiple_files = true; +option java_package = "io.grafeas.v1beta1.vulnerability"; +option objc_class_prefix = "GRA"; + +// Note provider-assigned severity/impact ranking. +enum Severity { + // Unknown. + SEVERITY_UNSPECIFIED = 0; + // Minimal severity. + MINIMAL = 1; + // Low severity. + LOW = 2; + // Medium severity. + MEDIUM = 3; + // High severity. + HIGH = 4; + // Critical severity. + CRITICAL = 5; +} + +// Vulnerability provides metadata about a security vulnerability in a Note. +message Vulnerability { + // The CVSS score for this vulnerability. + float cvss_score = 1; + + // Note provider assigned impact of the vulnerability. + Severity severity = 2; + + // All information about the package to specifically identify this + // vulnerability. One entry per (version range and cpe_uri) the package + // vulnerability has manifested in. + repeated Detail details = 3; + + // Identifies all appearances of this vulnerability in the package for a + // specific distro/location. For example: glibc in + // cpe:/o:debian:debian_linux:8 for versions 2.1 - 2.2 + message Detail { + // Required. The CPE URI in + // [cpe format](https://cpe.mitre.org/specification/) in which the + // vulnerability manifests. Examples include distro or storage location for + // vulnerable jar. + string cpe_uri = 1; + + // Required. The name of the package where the vulnerability was found. + string package = 2; + + // The min version of the package in which the vulnerability exists. + grafeas.v1beta1.package.Version min_affected_version = 3; + + // The max version of the package in which the vulnerability exists. + grafeas.v1beta1.package.Version max_affected_version = 4; + + // The severity (eg: distro assigned severity) for this vulnerability. + string severity_name = 5; + + // A vendor-specific description of this note. + string description = 6; + + // The fix for this specific package version. + VulnerabilityLocation fixed_location = 7; + + // The type of package; whether native or non native(ruby gems, node.js + // packages etc). + string package_type = 8; + + // Whether this detail is obsolete. Occurrences are expected not to point to + // obsolete details. + bool is_obsolete = 9; + + // The time this information was last changed at the source. This is an + // upstream timestamp from the underlying information source - e.g. Ubuntu + // security tracker. + google.protobuf.Timestamp source_update_time = 10; + } + + // The full description of the CVSSv3. + CVSSv3 cvss_v3 = 4; + + // Windows details get their own format because the information format and + // model don't match a normal detail. Specifically Windows updates are done as + // patches, thus Windows vulnerabilities really are a missing package, rather + // than a package being at an incorrect version. + repeated WindowsDetail windows_details = 5; + + message WindowsDetail { + // Required. The CPE URI in + // [cpe format](https://cpe.mitre.org/specification/) in which the + // vulnerability manifests. Examples include distro or storage location for + // vulnerable jar. + string cpe_uri = 1; + + // Required. The name of the vulnerability. + string name = 2; + + // The description of the vulnerability. + string description = 3; + + // Required. The names of the KBs which have hotfixes to mitigate this + // vulnerability. Note that there may be multiple hotfixes (and thus + // multiple KBs) that mitigate a given vulnerability. Currently any listed + // kb's presence is considered a fix. + repeated KnowledgeBase fixing_kbs = 4; + + message KnowledgeBase { + // The KB name (generally of the form KB[0-9]+ i.e. KB123456). + string name = 1; + // A link to the KB in the Windows update catalog - + // https://www.catalog.update.microsoft.com/ + string url = 2; + } + } + + // The time this information was last changed at the source. This is an + // upstream timestamp from the underlying information source - e.g. Ubuntu + // security tracker. + google.protobuf.Timestamp source_update_time = 6; + + // Next free ID is 7. +} + +// Details of a vulnerability Occurrence. +message Details { + // The type of package; whether native or non native(ruby gems, node.js + // packages etc) + string type = 1; + + // Output only. The note provider assigned Severity of the vulnerability. + Severity severity = 2; + + // Output only. The CVSS score of this vulnerability. CVSS score is on a + // scale of 0-10 where 0 indicates low severity and 10 indicates high + // severity. + float cvss_score = 3; + + // Required. The set of affected locations and their fixes (if available) + // within the associated resource. + repeated PackageIssue package_issue = 4; + + // Output only. A one sentence description of this vulnerability. + string short_description = 5; + + // Output only. A detailed description of this vulnerability. + string long_description = 6; + + // Output only. URLs related to this vulnerability. + repeated grafeas.v1beta1.RelatedUrl related_urls = 7; + + // The distro assigned severity for this vulnerability when it is + // available, and note provider assigned severity when distro has not yet + // assigned a severity for this vulnerability. + Severity effective_severity = 8; +} + +// This message wraps a location affected by a vulnerability and its +// associated fix (if one is available). +message PackageIssue { + // Required. The location of the vulnerability. + VulnerabilityLocation affected_location = 1; + + // The location of the available fix for vulnerability. + VulnerabilityLocation fixed_location = 2; + + // Deprecated, use Details.effective_severity instead + // The severity (e.g., distro assigned severity) for this vulnerability. + string severity_name = 3; +} + +// The location of the vulnerability. +message VulnerabilityLocation { + // Required. The CPE URI in [cpe format](https://cpe.mitre.org/specification/) + // format. Examples include distro or storage location for vulnerable jar. + string cpe_uri = 1; + + // Required. The package being described. + string package = 2; + + // Required. The version of the package being described. + grafeas.v1beta1.package.Version version = 3; +} diff --git a/owl-bot-staging/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts new file mode 100644 index 0000000..d3f5d83 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/index.ts @@ -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. ** + +import * as v1beta1 from './v1beta1'; +const ContainerAnalysisV1Beta1Client = v1beta1.ContainerAnalysisV1Beta1Client; +type ContainerAnalysisV1Beta1Client = v1beta1.ContainerAnalysisV1Beta1Client; +const GrafeasV1Beta1Client = v1beta1.GrafeasV1Beta1Client; +type GrafeasV1Beta1Client = v1beta1.GrafeasV1Beta1Client; +export {v1beta1, ContainerAnalysisV1Beta1Client, GrafeasV1Beta1Client}; +export default {v1beta1, ContainerAnalysisV1Beta1Client, GrafeasV1Beta1Client}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client.ts new file mode 100644 index 0000000..0bcd7d1 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client.ts @@ -0,0 +1,959 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/container_analysis_v1_beta1_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './container_analysis_v1_beta1_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Retrieves analysis results of Cloud components such as Docker container + * images. The Container Analysis API is an implementation of the + * [Grafeas](grafeas.io) API. + * + * Analysis results are stored as a series of occurrences. An `Occurrence` + * contains information about a specific analysis instance on a resource. An + * occurrence refers to a `Note`. A note contains details describing the + * analysis and is generally stored in a separate project, called a `Provider`. + * Multiple occurrences can refer to the same note. + * + * For example, an SSL vulnerability could affect multiple images. In this case, + * there would be one note for the vulnerability and an occurrence for each + * image with the vulnerability referring to that note. + * @class + * @memberof v1beta1 + */ +export class ContainerAnalysisV1Beta1Client { + 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}; + containerAnalysisV1Beta1Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ContainerAnalysisV1Beta1Client. + * + * @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 ContainerAnalysisV1Beta1Client; + 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 = { + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + scanConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/scanConfigs/{scan_config}' + ), + }; + + // 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') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1', 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.containerAnalysisV1Beta1Stub) { + return this.containerAnalysisV1Beta1Stub; + } + + // Put together the "service stub" for + // google.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1. + this.containerAnalysisV1Beta1Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1, + 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 containerAnalysisV1Beta1StubMethods = + ['setIamPolicy', 'getIamPolicy', 'testIamPermissions', 'getScanConfig', 'listScanConfigs', 'updateScanConfig']; + for (const methodName of containerAnalysisV1Beta1StubMethods) { + const callPromise = this.containerAnalysisV1Beta1Stub.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.containerAnalysisV1Beta1Stub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'containeranalysis.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 'containeranalysis.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 -- + // ------------------- + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Sets the access control policy on the specified note or occurrence. + * Requires `containeranalysis.notes.setIamPolicy` or + * `containeranalysis.occurrences.setIamPolicy` permission if the resource is + * a note or an occurrence, respectively. + * + * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + * occurrences. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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.setIamPolicy(request); + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets the access control policy for a note or an occurrence resource. + * Requires `containeranalysis.notes.setIamPolicy` or + * `containeranalysis.occurrences.setIamPolicy` permission if the resource is + * a note or occurrence, respectively. + * + * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + * occurrences. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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.getIamPolicy(request); + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; +/** + * Returns the permissions that a caller has on the specified note or + * occurrence. Requires list permission on the project (for example, + * `containeranalysis.notes.list`). + * + * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + * occurrences. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * 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.testIamPermissions(request); + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + getScanConfig( + request?: protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest|undefined, {}|undefined + ]>; + getScanConfig( + request: protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): void; + getScanConfig( + request: protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, + callback: Callback< + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets the specified scan configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the scan configuration in the form of + * `projects/[PROJECT_ID]/scanConfigs/[SCAN_CONFIG_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ScanConfig]{@link google.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest|undefined, {}|undefined + ]>; + updateScanConfig( + request: protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): void; + updateScanConfig( + request: protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, + callback: Callback< + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates the specified scan configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the scan configuration in the form of + * `projects/[PROJECT_ID]/scanConfigs/[SCAN_CONFIG_ID]`. + * @param {google.devtools.containeranalysis.v1beta1.ScanConfig} request.scanConfig + * Required. The updated scan configuration. + * @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.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.devtools.containeranalysis.v1beta1.IScanConfig, + protos.google.devtools.containeranalysis.v1beta1.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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateScanConfig(request, options, callback); + } + + listScanConfigs( + request?: protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, + options?: CallOptions): + Promise<[ + protos.google.devtools.containeranalysis.v1beta1.IScanConfig[], + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest|null, + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsResponse + ]>; + listScanConfigs( + request: protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsResponse|null|undefined, + protos.google.devtools.containeranalysis.v1beta1.IScanConfig>): void; + listScanConfigs( + request: protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, + callback: PaginationCallback< + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsResponse|null|undefined, + protos.google.devtools.containeranalysis.v1beta1.IScanConfig>): void; +/** + * Lists scan configurations for the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project to list scan configurations for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * Required. The filter expression. + * @param {number} request.pageSize + * The number of scan configs to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsResponse|null|undefined, + protos.google.devtools.containeranalysis.v1beta1.IScanConfig>, + callback?: PaginationCallback< + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsResponse|null|undefined, + protos.google.devtools.containeranalysis.v1beta1.IScanConfig>): + Promise<[ + protos.google.devtools.containeranalysis.v1beta1.IScanConfig[], + protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest|null, + protos.google.devtools.containeranalysis.v1beta1.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 name of the project to list scan configurations for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * Required. The filter expression. + * @param {number} request.pageSize + * The number of scan configs to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.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 name of the project to list scan configurations for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * Required. The filter expression. + * @param {number} request.pageSize + * The number of scan configs to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.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; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified 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; + } + + /** + * 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.containerAnalysisV1Beta1Stub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client_config.json new file mode 100644 index 0000000..56b0712 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1": { + "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": { + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetScanConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListScanConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateScanConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_proto_list.json new file mode 100644 index 0000000..9ad38a4 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/build/build.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/common/common.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/image/image.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/package/package.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/source/source.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto" +] diff --git a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 0000000..da6fa7b --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,263 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.devtools.containeranalysis.v1beta1", + "libraryPackage": "@google-cloud/containeranalysis", + "services": { + "ContainerAnalysisV1Beta1": { + "clients": { + "grpc": { + "libraryClient": "ContainerAnalysisV1Beta1Client", + "rpcs": { + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "GetScanConfig": { + "methods": [ + "getScanConfig" + ] + }, + "UpdateScanConfig": { + "methods": [ + "updateScanConfig" + ] + }, + "ListScanConfigs": { + "methods": [ + "listScanConfigs", + "listScanConfigsStream", + "listScanConfigsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ContainerAnalysisV1Beta1Client", + "rpcs": { + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "GetScanConfig": { + "methods": [ + "getScanConfig" + ] + }, + "UpdateScanConfig": { + "methods": [ + "updateScanConfig" + ] + }, + "ListScanConfigs": { + "methods": [ + "listScanConfigs", + "listScanConfigsStream", + "listScanConfigsAsync" + ] + } + } + } + } + }, + "GrafeasV1Beta1": { + "clients": { + "grpc": { + "libraryClient": "GrafeasV1Beta1Client", + "rpcs": { + "GetOccurrence": { + "methods": [ + "getOccurrence" + ] + }, + "DeleteOccurrence": { + "methods": [ + "deleteOccurrence" + ] + }, + "CreateOccurrence": { + "methods": [ + "createOccurrence" + ] + }, + "BatchCreateOccurrences": { + "methods": [ + "batchCreateOccurrences" + ] + }, + "UpdateOccurrence": { + "methods": [ + "updateOccurrence" + ] + }, + "GetOccurrenceNote": { + "methods": [ + "getOccurrenceNote" + ] + }, + "GetNote": { + "methods": [ + "getNote" + ] + }, + "DeleteNote": { + "methods": [ + "deleteNote" + ] + }, + "CreateNote": { + "methods": [ + "createNote" + ] + }, + "BatchCreateNotes": { + "methods": [ + "batchCreateNotes" + ] + }, + "UpdateNote": { + "methods": [ + "updateNote" + ] + }, + "GetVulnerabilityOccurrencesSummary": { + "methods": [ + "getVulnerabilityOccurrencesSummary" + ] + }, + "ListOccurrences": { + "methods": [ + "listOccurrences", + "listOccurrencesStream", + "listOccurrencesAsync" + ] + }, + "ListNotes": { + "methods": [ + "listNotes", + "listNotesStream", + "listNotesAsync" + ] + }, + "ListNoteOccurrences": { + "methods": [ + "listNoteOccurrences", + "listNoteOccurrencesStream", + "listNoteOccurrencesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "GrafeasV1Beta1Client", + "rpcs": { + "GetOccurrence": { + "methods": [ + "getOccurrence" + ] + }, + "DeleteOccurrence": { + "methods": [ + "deleteOccurrence" + ] + }, + "CreateOccurrence": { + "methods": [ + "createOccurrence" + ] + }, + "BatchCreateOccurrences": { + "methods": [ + "batchCreateOccurrences" + ] + }, + "UpdateOccurrence": { + "methods": [ + "updateOccurrence" + ] + }, + "GetOccurrenceNote": { + "methods": [ + "getOccurrenceNote" + ] + }, + "GetNote": { + "methods": [ + "getNote" + ] + }, + "DeleteNote": { + "methods": [ + "deleteNote" + ] + }, + "CreateNote": { + "methods": [ + "createNote" + ] + }, + "BatchCreateNotes": { + "methods": [ + "batchCreateNotes" + ] + }, + "UpdateNote": { + "methods": [ + "updateNote" + ] + }, + "GetVulnerabilityOccurrencesSummary": { + "methods": [ + "getVulnerabilityOccurrencesSummary" + ] + }, + "ListOccurrences": { + "methods": [ + "listOccurrences", + "listOccurrencesStream", + "listOccurrencesAsync" + ] + }, + "ListNotes": { + "methods": [ + "listNotes", + "listNotesStream", + "listNotesAsync" + ] + }, + "ListNoteOccurrences": { + "methods": [ + "listNoteOccurrences", + "listNoteOccurrencesStream", + "listNoteOccurrencesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client.ts new file mode 100644 index 0000000..8dfb10a --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client.ts @@ -0,0 +1,1800 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/grafeas_v1_beta1_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './grafeas_v1_beta1_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * [Grafeas](grafeas.io) API. + * + * Retrieves analysis results of Cloud components such as Docker container + * images. + * + * Analysis results are stored as a series of occurrences. An `Occurrence` + * contains information about a specific analysis instance on a resource. An + * occurrence refers to a `Note`. A note contains details describing the + * analysis and is generally stored in a separate project, called a `Provider`. + * Multiple occurrences can refer to the same note. + * + * For example, an SSL vulnerability could affect multiple images. In this case, + * there would be one note for the vulnerability and an occurrence for each + * image with the vulnerability referring to that note. + * @class + * @memberof v1beta1 + */ +export class GrafeasV1Beta1Client { + 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}; + grafeasV1Beta1Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of GrafeasV1Beta1Client. + * + * @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 GrafeasV1Beta1Client; + 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 = { + scanConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/scanConfigs/{scan_config}' + ), + }; + + // 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 = { + listOccurrences: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'occurrences'), + listNotes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'notes'), + listNoteOccurrences: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'occurrences') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.devtools.containeranalysis.v1beta1.GrafeasV1Beta1', 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.grafeasV1Beta1Stub) { + return this.grafeasV1Beta1Stub; + } + + // Put together the "service stub" for + // google.devtools.containeranalysis.v1beta1.GrafeasV1Beta1. + this.grafeasV1Beta1Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.devtools.containeranalysis.v1beta1.GrafeasV1Beta1') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.devtools.containeranalysis.v1beta1.GrafeasV1Beta1, + 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 grafeasV1Beta1StubMethods = + ['getOccurrence', 'listOccurrences', 'deleteOccurrence', 'createOccurrence', 'batchCreateOccurrences', 'updateOccurrence', 'getOccurrenceNote', 'getNote', 'listNotes', 'deleteNote', 'createNote', 'batchCreateNotes', 'updateNote', 'listNoteOccurrences', 'getVulnerabilityOccurrencesSummary']; + for (const methodName of grafeasV1Beta1StubMethods) { + const callPromise = this.grafeasV1Beta1Stub.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.grafeasV1Beta1Stub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'containeranalysis.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 'containeranalysis.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 -- + // ------------------- + getOccurrence( + request?: protos.grafeas.v1beta1.IGetOccurrenceRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IGetOccurrenceRequest|undefined, {}|undefined + ]>; + getOccurrence( + request: protos.grafeas.v1beta1.IGetOccurrenceRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IGetOccurrenceRequest|null|undefined, + {}|null|undefined>): void; + getOccurrence( + request: protos.grafeas.v1beta1.IGetOccurrenceRequest, + callback: Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IGetOccurrenceRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets the specified occurrence. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the occurrence in the form of + * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Occurrence]{@link grafeas.v1beta1.Occurrence}. + * 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.getOccurrence(request); + */ + getOccurrence( + request?: protos.grafeas.v1beta1.IGetOccurrenceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IGetOccurrenceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IGetOccurrenceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IGetOccurrenceRequest|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.getOccurrence(request, options, callback); + } + deleteOccurrence( + request?: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteOccurrenceRequest|undefined, {}|undefined + ]>; + deleteOccurrence( + request: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteOccurrenceRequest|null|undefined, + {}|null|undefined>): void; + deleteOccurrence( + request: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteOccurrenceRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes the specified occurrence. For example, use this method to delete an + * occurrence when the occurrence is no longer applicable for the given + * resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the occurrence in the form of + * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteOccurrence(request); + */ + deleteOccurrence( + request?: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteOccurrenceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteOccurrenceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteOccurrenceRequest|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.deleteOccurrence(request, options, callback); + } + createOccurrence( + request?: protos.grafeas.v1beta1.ICreateOccurrenceRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.ICreateOccurrenceRequest|undefined, {}|undefined + ]>; + createOccurrence( + request: protos.grafeas.v1beta1.ICreateOccurrenceRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.ICreateOccurrenceRequest|null|undefined, + {}|null|undefined>): void; + createOccurrence( + request: protos.grafeas.v1beta1.ICreateOccurrenceRequest, + callback: Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.ICreateOccurrenceRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new occurrence. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project in the form of `projects/[PROJECT_ID]`, under which + * the occurrence is to be created. + * @param {grafeas.v1beta1.Occurrence} request.occurrence + * The occurrence to create. + * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence}. + * 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.createOccurrence(request); + */ + createOccurrence( + request?: protos.grafeas.v1beta1.ICreateOccurrenceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.ICreateOccurrenceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.ICreateOccurrenceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.ICreateOccurrenceRequest|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.createOccurrence(request, options, callback); + } + batchCreateOccurrences( + request?: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|undefined, {}|undefined + ]>; + batchCreateOccurrences( + request: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|null|undefined, + {}|null|undefined>): void; + batchCreateOccurrences( + request: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, + callback: Callback< + protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates new occurrences in batch. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project in the form of `projects/[PROJECT_ID]`, under which + * the occurrences are to be created. + * @param {number[]} request.occurrences + * The occurrences to create. + * @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 [BatchCreateOccurrencesResponse]{@link grafeas.v1beta1.BatchCreateOccurrencesResponse}. + * 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.batchCreateOccurrences(request); + */ + batchCreateOccurrences( + request?: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, + protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|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.batchCreateOccurrences(request, options, callback); + } + updateOccurrence( + request?: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IUpdateOccurrenceRequest|undefined, {}|undefined + ]>; + updateOccurrence( + request: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IUpdateOccurrenceRequest|null|undefined, + {}|null|undefined>): void; + updateOccurrence( + request: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, + callback: Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IUpdateOccurrenceRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates the specified occurrence. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the occurrence in the form of + * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + * @param {grafeas.v1beta1.Occurrence} request.occurrence + * The updated occurrence. + * @param {google.protobuf.FieldMask} request.updateMask + * The fields to update. + * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence}. + * 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.updateOccurrence(request); + */ + updateOccurrence( + request?: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IUpdateOccurrenceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IUpdateOccurrenceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1beta1.IOccurrence, + protos.grafeas.v1beta1.IUpdateOccurrenceRequest|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.updateOccurrence(request, options, callback); + } + getOccurrenceNote( + request?: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|undefined, {}|undefined + ]>; + getOccurrenceNote( + request: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|null|undefined, + {}|null|undefined>): void; + getOccurrenceNote( + request: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, + callback: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets the note attached to the specified occurrence. Consumer projects can + * use this method to get a note that belongs to a provider project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the occurrence in the form of + * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Note]{@link grafeas.v1beta1.Note}. + * 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.getOccurrenceNote(request); + */ + getOccurrenceNote( + request?: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|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.getOccurrenceNote(request, options, callback); + } + getNote( + request?: protos.grafeas.v1beta1.IGetNoteRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetNoteRequest|undefined, {}|undefined + ]>; + getNote( + request: protos.grafeas.v1beta1.IGetNoteRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetNoteRequest|null|undefined, + {}|null|undefined>): void; + getNote( + request: protos.grafeas.v1beta1.IGetNoteRequest, + callback: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetNoteRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets the specified note. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the note in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Note]{@link grafeas.v1beta1.Note}. + * 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.getNote(request); + */ + getNote( + request?: protos.grafeas.v1beta1.IGetNoteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetNoteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetNoteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IGetNoteRequest|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.getNote(request, options, callback); + } + deleteNote( + request?: protos.grafeas.v1beta1.IDeleteNoteRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteNoteRequest|undefined, {}|undefined + ]>; + deleteNote( + request: protos.grafeas.v1beta1.IDeleteNoteRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteNoteRequest|null|undefined, + {}|null|undefined>): void; + deleteNote( + request: protos.grafeas.v1beta1.IDeleteNoteRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteNoteRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes the specified note. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the note in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteNote(request); + */ + deleteNote( + request?: protos.grafeas.v1beta1.IDeleteNoteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteNoteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteNoteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.grafeas.v1beta1.IDeleteNoteRequest|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.deleteNote(request, options, callback); + } + createNote( + request?: protos.grafeas.v1beta1.ICreateNoteRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.ICreateNoteRequest|undefined, {}|undefined + ]>; + createNote( + request: protos.grafeas.v1beta1.ICreateNoteRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.ICreateNoteRequest|null|undefined, + {}|null|undefined>): void; + createNote( + request: protos.grafeas.v1beta1.ICreateNoteRequest, + callback: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.ICreateNoteRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new note. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project in the form of `projects/[PROJECT_ID]`, under which + * the note is to be created. + * @param {string} request.noteId + * The ID to use for this note. + * @param {grafeas.v1beta1.Note} request.note + * The note to create. + * @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 [Note]{@link grafeas.v1beta1.Note}. + * 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.createNote(request); + */ + createNote( + request?: protos.grafeas.v1beta1.ICreateNoteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.ICreateNoteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.ICreateNoteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.ICreateNoteRequest|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.createNote(request, options, callback); + } + batchCreateNotes( + request?: protos.grafeas.v1beta1.IBatchCreateNotesRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.IBatchCreateNotesResponse, + protos.grafeas.v1beta1.IBatchCreateNotesRequest|undefined, {}|undefined + ]>; + batchCreateNotes( + request: protos.grafeas.v1beta1.IBatchCreateNotesRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1beta1.IBatchCreateNotesResponse, + protos.grafeas.v1beta1.IBatchCreateNotesRequest|null|undefined, + {}|null|undefined>): void; + batchCreateNotes( + request: protos.grafeas.v1beta1.IBatchCreateNotesRequest, + callback: Callback< + protos.grafeas.v1beta1.IBatchCreateNotesResponse, + protos.grafeas.v1beta1.IBatchCreateNotesRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates new notes in batch. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project in the form of `projects/[PROJECT_ID]`, under which + * the notes are to be created. + * @param {number[]} request.notes + * The notes to create. + * @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 [BatchCreateNotesResponse]{@link grafeas.v1beta1.BatchCreateNotesResponse}. + * 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.batchCreateNotes(request); + */ + batchCreateNotes( + request?: protos.grafeas.v1beta1.IBatchCreateNotesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1beta1.IBatchCreateNotesResponse, + protos.grafeas.v1beta1.IBatchCreateNotesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1beta1.IBatchCreateNotesResponse, + protos.grafeas.v1beta1.IBatchCreateNotesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1beta1.IBatchCreateNotesResponse, + protos.grafeas.v1beta1.IBatchCreateNotesRequest|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.batchCreateNotes(request, options, callback); + } + updateNote( + request?: protos.grafeas.v1beta1.IUpdateNoteRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IUpdateNoteRequest|undefined, {}|undefined + ]>; + updateNote( + request: protos.grafeas.v1beta1.IUpdateNoteRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IUpdateNoteRequest|null|undefined, + {}|null|undefined>): void; + updateNote( + request: protos.grafeas.v1beta1.IUpdateNoteRequest, + callback: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IUpdateNoteRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates the specified note. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the note in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {grafeas.v1beta1.Note} request.note + * The updated note. + * @param {google.protobuf.FieldMask} request.updateMask + * The fields to update. + * @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 [Note]{@link grafeas.v1beta1.Note}. + * 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.updateNote(request); + */ + updateNote( + request?: protos.grafeas.v1beta1.IUpdateNoteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IUpdateNoteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IUpdateNoteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1beta1.INote, + protos.grafeas.v1beta1.IUpdateNoteRequest|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.updateNote(request, options, callback); + } + getVulnerabilityOccurrencesSummary( + request?: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, + protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|undefined, {}|undefined + ]>; + getVulnerabilityOccurrencesSummary( + request: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, + options: CallOptions, + callback: Callback< + protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, + protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, + {}|null|undefined>): void; + getVulnerabilityOccurrencesSummary( + request: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, + callback: Callback< + protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, + protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a summary of the number and severity of occurrences. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project to get a vulnerability summary for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @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 [VulnerabilityOccurrencesSummary]{@link grafeas.v1beta1.VulnerabilityOccurrencesSummary}. + * 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.getVulnerabilityOccurrencesSummary(request); + */ + getVulnerabilityOccurrencesSummary( + request?: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, + protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, + protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, + protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|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.getVulnerabilityOccurrencesSummary(request, options, callback); + } + + listOccurrences( + request?: protos.grafeas.v1beta1.IListOccurrencesRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.IOccurrence[], + protos.grafeas.v1beta1.IListOccurrencesRequest|null, + protos.grafeas.v1beta1.IListOccurrencesResponse + ]>; + listOccurrences( + request: protos.grafeas.v1beta1.IListOccurrencesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.grafeas.v1beta1.IListOccurrencesRequest, + protos.grafeas.v1beta1.IListOccurrencesResponse|null|undefined, + protos.grafeas.v1beta1.IOccurrence>): void; + listOccurrences( + request: protos.grafeas.v1beta1.IListOccurrencesRequest, + callback: PaginationCallback< + protos.grafeas.v1beta1.IListOccurrencesRequest, + protos.grafeas.v1beta1.IListOccurrencesResponse|null|undefined, + protos.grafeas.v1beta1.IOccurrence>): void; +/** + * Lists occurrences for the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project to list occurrences for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence}. + * 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 `listOccurrencesAsync()` + * 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. + */ + listOccurrences( + request?: protos.grafeas.v1beta1.IListOccurrencesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.grafeas.v1beta1.IListOccurrencesRequest, + protos.grafeas.v1beta1.IListOccurrencesResponse|null|undefined, + protos.grafeas.v1beta1.IOccurrence>, + callback?: PaginationCallback< + protos.grafeas.v1beta1.IListOccurrencesRequest, + protos.grafeas.v1beta1.IListOccurrencesResponse|null|undefined, + protos.grafeas.v1beta1.IOccurrence>): + Promise<[ + protos.grafeas.v1beta1.IOccurrence[], + protos.grafeas.v1beta1.IListOccurrencesRequest|null, + protos.grafeas.v1beta1.IListOccurrencesResponse + ]>|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.listOccurrences(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 + * The name of the project to list occurrences for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence} 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 `listOccurrencesAsync()` + * 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. + */ + listOccurrencesStream( + request?: protos.grafeas.v1beta1.IListOccurrencesRequest, + 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.listOccurrences.createStream( + this.innerApiCalls.listOccurrences as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listOccurrences`, 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 + * The name of the project to list occurrences for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 + * [Occurrence]{@link grafeas.v1beta1.Occurrence}. 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.listOccurrencesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listOccurrencesAsync( + request?: protos.grafeas.v1beta1.IListOccurrencesRequest, + 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.listOccurrences.asyncIterate( + this.innerApiCalls['listOccurrences'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listNotes( + request?: protos.grafeas.v1beta1.IListNotesRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.INote[], + protos.grafeas.v1beta1.IListNotesRequest|null, + protos.grafeas.v1beta1.IListNotesResponse + ]>; + listNotes( + request: protos.grafeas.v1beta1.IListNotesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.grafeas.v1beta1.IListNotesRequest, + protos.grafeas.v1beta1.IListNotesResponse|null|undefined, + protos.grafeas.v1beta1.INote>): void; + listNotes( + request: protos.grafeas.v1beta1.IListNotesRequest, + callback: PaginationCallback< + protos.grafeas.v1beta1.IListNotesRequest, + protos.grafeas.v1beta1.IListNotesResponse|null|undefined, + protos.grafeas.v1beta1.INote>): void; +/** + * Lists notes for the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the project to list notes for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of notes to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Note]{@link grafeas.v1beta1.Note}. + * 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 `listNotesAsync()` + * 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. + */ + listNotes( + request?: protos.grafeas.v1beta1.IListNotesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.grafeas.v1beta1.IListNotesRequest, + protos.grafeas.v1beta1.IListNotesResponse|null|undefined, + protos.grafeas.v1beta1.INote>, + callback?: PaginationCallback< + protos.grafeas.v1beta1.IListNotesRequest, + protos.grafeas.v1beta1.IListNotesResponse|null|undefined, + protos.grafeas.v1beta1.INote>): + Promise<[ + protos.grafeas.v1beta1.INote[], + protos.grafeas.v1beta1.IListNotesRequest|null, + protos.grafeas.v1beta1.IListNotesResponse + ]>|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.listNotes(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 + * The name of the project to list notes for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of notes to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Note]{@link grafeas.v1beta1.Note} 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 `listNotesAsync()` + * 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. + */ + listNotesStream( + request?: protos.grafeas.v1beta1.IListNotesRequest, + 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.listNotes.createStream( + this.innerApiCalls.listNotes as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listNotes`, 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 + * The name of the project to list notes for in the form of + * `projects/[PROJECT_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of notes to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 + * [Note]{@link grafeas.v1beta1.Note}. 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.listNotesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listNotesAsync( + request?: protos.grafeas.v1beta1.IListNotesRequest, + 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.listNotes.asyncIterate( + this.innerApiCalls['listNotes'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listNoteOccurrences( + request?: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + options?: CallOptions): + Promise<[ + protos.grafeas.v1beta1.IOccurrence[], + protos.grafeas.v1beta1.IListNoteOccurrencesRequest|null, + protos.grafeas.v1beta1.IListNoteOccurrencesResponse + ]>; + listNoteOccurrences( + request: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + protos.grafeas.v1beta1.IListNoteOccurrencesResponse|null|undefined, + protos.grafeas.v1beta1.IOccurrence>): void; + listNoteOccurrences( + request: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + callback: PaginationCallback< + protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + protos.grafeas.v1beta1.IListNoteOccurrencesResponse|null|undefined, + protos.grafeas.v1beta1.IOccurrence>): void; +/** + * Lists occurrences referencing the specified note. Provider projects can use + * this method to get all occurrences across consumer projects referencing the + * specified note. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the note to list occurrences for in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence}. + * 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 `listNoteOccurrencesAsync()` + * 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. + */ + listNoteOccurrences( + request?: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + protos.grafeas.v1beta1.IListNoteOccurrencesResponse|null|undefined, + protos.grafeas.v1beta1.IOccurrence>, + callback?: PaginationCallback< + protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + protos.grafeas.v1beta1.IListNoteOccurrencesResponse|null|undefined, + protos.grafeas.v1beta1.IOccurrence>): + Promise<[ + protos.grafeas.v1beta1.IOccurrence[], + protos.grafeas.v1beta1.IListNoteOccurrencesRequest|null, + protos.grafeas.v1beta1.IListNoteOccurrencesResponse + ]>|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.listNoteOccurrences(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.name + * The name of the note to list occurrences for in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence} 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 `listNoteOccurrencesAsync()` + * 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. + */ + listNoteOccurrencesStream( + request?: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + 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({ + 'name': request.name || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listNoteOccurrences.createStream( + this.innerApiCalls.listNoteOccurrences as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listNoteOccurrences`, 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.name + * The name of the note to list occurrences for in the form of + * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. + * @param {string} request.filter + * The filter expression. + * @param {number} request.pageSize + * Number of occurrences to return in the list. + * @param {string} request.pageToken + * Token to provide to skip to a particular spot in the list. + * @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 + * [Occurrence]{@link grafeas.v1beta1.Occurrence}. 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.listNoteOccurrencesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listNoteOccurrencesAsync( + request?: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + 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({ + 'name': request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listNoteOccurrences.asyncIterate( + this.innerApiCalls['listNoteOccurrences'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * 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; + } + + /** + * 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.grafeasV1Beta1Stub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client_config.json new file mode 100644 index 0000000..8c9edc4 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client_config.json @@ -0,0 +1,86 @@ +{ + "interfaces": { + "google.devtools.containeranalysis.v1beta1.GrafeasV1Beta1": { + "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": { + "GetOccurrence": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListOccurrences": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteOccurrence": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateOccurrence": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "BatchCreateOccurrences": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateOccurrence": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetOccurrenceNote": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNote": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListNotes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteNote": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateNote": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "BatchCreateNotes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateNote": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListNoteOccurrences": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetVulnerabilityOccurrencesSummary": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_proto_list.json new file mode 100644 index 0000000..9ad38a4 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_proto_list.json @@ -0,0 +1,15 @@ +[ + "../../protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/build/build.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/common/common.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/image/image.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/package/package.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/source/source.proto", + "../../protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto" +] diff --git a/owl-bot-staging/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/v1beta1/src/v1beta1/index.ts new file mode 100644 index 0000000..500064b --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,20 @@ +// 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 {ContainerAnalysisV1Beta1Client} from './container_analysis_v1_beta1_client'; +export {GrafeasV1Beta1Client} from './grafeas_v1_beta1_client'; diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..e267adc --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// 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 containeranalysis = require('@google-cloud/containeranalysis'); + +function main() { + const containerAnalysisV1Beta1Client = new containeranalysis.ContainerAnalysisV1Beta1Client(); + const grafeasV1Beta1Client = new containeranalysis.GrafeasV1Beta1Client(); +} + +main(); diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..057cc77 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// 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 {ContainerAnalysisV1Beta1Client, GrafeasV1Beta1Client} from '@google-cloud/containeranalysis'; + +// check that the client class type name can be used +function doStuffWithContainerAnalysisV1Beta1Client(client: ContainerAnalysisV1Beta1Client) { + client.close(); +} +function doStuffWithGrafeasV1Beta1Client(client: GrafeasV1Beta1Client) { + client.close(); +} + +function main() { + // check that the client instance can be created + const containerAnalysisV1Beta1Client = new ContainerAnalysisV1Beta1Client(); + doStuffWithContainerAnalysisV1Beta1Client(containerAnalysisV1Beta1Client); + // check that the client instance can be created + const grafeasV1Beta1Client = new GrafeasV1Beta1Client(); + doStuffWithGrafeasV1Beta1Client(grafeasV1Beta1Client); +} + +main(); diff --git a/owl-bot-staging/v1beta1/system-test/install.ts b/owl-bot-staging/v1beta1/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1beta1/test/gapic_container_analysis_v1_beta1_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_container_analysis_v1_beta1_v1beta1.ts new file mode 100644 index 0000000..43bd76c --- /dev/null +++ b/owl-bot-staging/v1beta1/test/gapic_container_analysis_v1_beta1_v1beta1.ts @@ -0,0 +1,880 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 containeranalysisv1beta1Module from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta1.ContainerAnalysisV1Beta1Client', () => { + it('has servicePath', () => { + const servicePath = containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.containerAnalysisV1Beta1Stub, undefined); + await client.initialize(); + assert(client.containerAnalysisV1Beta1Stub); + }); + + it('has close method', () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + 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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + 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('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getScanConfig', () => { + it('invokes getScanConfig without error', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()); + client.innerApiCalls.getScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScanConfig( + request, + (err?: Error|null, result?: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.UpdateScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.UpdateScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()); + client.innerApiCalls.updateScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateScanConfig( + request, + (err?: Error|null, result?: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.UpdateScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "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('listScanConfigs', () => { + it('invokes listScanConfigs without error', async () => { + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + ]; + client.innerApiCalls.listScanConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listScanConfigs( + request, + (err?: Error|null, result?: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + ]; + client.descriptors.page.listScanConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listScanConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.devtools.containeranalysis.v1beta1.ScanConfig[] = []; + stream.on('data', (response: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.ScanConfig[] = []; + stream.on('data', (response: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), + ]; + client.descriptors.page.listScanConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.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('Path templates', () => { + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + 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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ + 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)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1beta1/test/gapic_grafeas_v1_beta1_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_grafeas_v1_beta1_v1beta1.ts new file mode 100644 index 0000000..f97e985 --- /dev/null +++ b/owl-bot-staging/v1beta1/test/gapic_grafeas_v1_beta1_v1beta1.ts @@ -0,0 +1,1882 @@ +// 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 grafeasv1beta1Module from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta1.GrafeasV1Beta1Client', () => { + it('has servicePath', () => { + const servicePath = grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.grafeasV1Beta1Stub, undefined); + await client.initialize(); + assert(client.grafeasV1Beta1Stub); + }); + + it('has close method', () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + 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 grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + 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('getOccurrence', () => { + it('invokes getOccurrence without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); + client.innerApiCalls.getOccurrence = stubSimpleCall(expectedResponse); + const [response] = await client.getOccurrence(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getOccurrence without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); + client.innerApiCalls.getOccurrence = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOccurrence( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.IOccurrence|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getOccurrence with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getOccurrence = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getOccurrence(request), expectedError); + assert((client.innerApiCalls.getOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('deleteOccurrence', () => { + it('invokes deleteOccurrence without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteOccurrence = stubSimpleCall(expectedResponse); + const [response] = await client.deleteOccurrence(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteOccurrence without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteOccurrence = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteOccurrence( + 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.deleteOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteOccurrence with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteOccurrence = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteOccurrence(request), expectedError); + assert((client.innerApiCalls.deleteOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('createOccurrence', () => { + it('invokes createOccurrence without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateOccurrenceRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); + client.innerApiCalls.createOccurrence = stubSimpleCall(expectedResponse); + const [response] = await client.createOccurrence(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createOccurrence without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateOccurrenceRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); + client.innerApiCalls.createOccurrence = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createOccurrence( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.IOccurrence|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createOccurrence with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateOccurrenceRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createOccurrence = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createOccurrence(request), expectedError); + assert((client.innerApiCalls.createOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('batchCreateOccurrences', () => { + it('invokes batchCreateOccurrences without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateOccurrencesResponse()); + client.innerApiCalls.batchCreateOccurrences = stubSimpleCall(expectedResponse); + const [response] = await client.batchCreateOccurrences(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchCreateOccurrences without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateOccurrencesResponse()); + client.innerApiCalls.batchCreateOccurrences = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchCreateOccurrences( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchCreateOccurrences with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchCreateOccurrences = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchCreateOccurrences(request), expectedError); + assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updateOccurrence', () => { + it('invokes updateOccurrence without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); + client.innerApiCalls.updateOccurrence = stubSimpleCall(expectedResponse); + const [response] = await client.updateOccurrence(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateOccurrence without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); + client.innerApiCalls.updateOccurrence = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateOccurrence( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.IOccurrence|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateOccurrence with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateOccurrenceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateOccurrence = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateOccurrence(request), expectedError); + assert((client.innerApiCalls.updateOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getOccurrenceNote', () => { + it('invokes getOccurrenceNote without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); + client.innerApiCalls.getOccurrenceNote = stubSimpleCall(expectedResponse); + const [response] = await client.getOccurrenceNote(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getOccurrenceNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getOccurrenceNote without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); + client.innerApiCalls.getOccurrenceNote = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOccurrenceNote( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.INote|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getOccurrenceNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getOccurrenceNote with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getOccurrenceNote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getOccurrenceNote(request), expectedError); + assert((client.innerApiCalls.getOccurrenceNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getNote', () => { + it('invokes getNote without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); + client.innerApiCalls.getNote = stubSimpleCall(expectedResponse); + const [response] = await client.getNote(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getNote without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); + client.innerApiCalls.getNote = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getNote( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.INote|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getNote with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getNote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getNote(request), expectedError); + assert((client.innerApiCalls.getNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('deleteNote', () => { + it('invokes deleteNote without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteNote = stubSimpleCall(expectedResponse); + const [response] = await client.deleteNote(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteNote without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteNote = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteNote( + 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.deleteNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteNote with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteNote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteNote(request), expectedError); + assert((client.innerApiCalls.deleteNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('createNote', () => { + it('invokes createNote without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateNoteRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); + client.innerApiCalls.createNote = stubSimpleCall(expectedResponse); + const [response] = await client.createNote(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createNote without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateNoteRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); + client.innerApiCalls.createNote = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createNote( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.INote|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createNote with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateNoteRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createNote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createNote(request), expectedError); + assert((client.innerApiCalls.createNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('batchCreateNotes', () => { + it('invokes batchCreateNotes without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateNotesResponse()); + client.innerApiCalls.batchCreateNotes = stubSimpleCall(expectedResponse); + const [response] = await client.batchCreateNotes(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchCreateNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchCreateNotes without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateNotesResponse()); + client.innerApiCalls.batchCreateNotes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchCreateNotes( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.IBatchCreateNotesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchCreateNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchCreateNotes with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchCreateNotes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchCreateNotes(request), expectedError); + assert((client.innerApiCalls.batchCreateNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updateNote', () => { + it('invokes updateNote without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); + client.innerApiCalls.updateNote = stubSimpleCall(expectedResponse); + const [response] = await client.updateNote(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateNote without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); + client.innerApiCalls.updateNote = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateNote( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.INote|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateNote with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateNoteRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateNote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateNote(request), expectedError); + assert((client.innerApiCalls.updateNote as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getVulnerabilityOccurrencesSummary', () => { + it('invokes getVulnerabilityOccurrencesSummary without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetVulnerabilityOccurrencesSummaryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.VulnerabilityOccurrencesSummary()); + client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCall(expectedResponse); + const [response] = await client.getVulnerabilityOccurrencesSummary(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getVulnerabilityOccurrencesSummary without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetVulnerabilityOccurrencesSummaryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.VulnerabilityOccurrencesSummary()); + client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getVulnerabilityOccurrencesSummary( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getVulnerabilityOccurrencesSummary with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.GetVulnerabilityOccurrencesSummaryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getVulnerabilityOccurrencesSummary(request), expectedError); + assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listOccurrences', () => { + it('invokes listOccurrences without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + ]; + client.innerApiCalls.listOccurrences = stubSimpleCall(expectedResponse); + const [response] = await client.listOccurrences(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listOccurrences without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + ]; + client.innerApiCalls.listOccurrences = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOccurrences( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.IOccurrence[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listOccurrences with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listOccurrences = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listOccurrences(request), expectedError); + assert((client.innerApiCalls.listOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listOccurrencesStream without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + ]; + client.descriptors.page.listOccurrences.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listOccurrencesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1beta1.Occurrence[] = []; + stream.on('data', (response: protos.grafeas.v1beta1.Occurrence) => { + 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.listOccurrences.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOccurrences, request)); + assert.strictEqual( + (client.descriptors.page.listOccurrences.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listOccurrencesStream with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listOccurrences.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listOccurrencesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1beta1.Occurrence[] = []; + stream.on('data', (response: protos.grafeas.v1beta1.Occurrence) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listOccurrences.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listOccurrences, request)); + assert.strictEqual( + (client.descriptors.page.listOccurrences.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listOccurrences without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + ]; + client.descriptors.page.listOccurrences.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.grafeas.v1beta1.IOccurrence[] = []; + const iterable = client.listOccurrencesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listOccurrences with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listOccurrences.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOccurrencesAsync(request); + await assert.rejects(async () => { + const responses: protos.grafeas.v1beta1.IOccurrence[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listNotes', () => { + it('invokes listNotes without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + ]; + client.innerApiCalls.listNotes = stubSimpleCall(expectedResponse); + const [response] = await client.listNotes(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listNotes without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + ]; + client.innerApiCalls.listNotes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNotes( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.INote[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listNotes with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listNotes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listNotes(request), expectedError); + assert((client.innerApiCalls.listNotes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listNotesStream without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + ]; + client.descriptors.page.listNotes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listNotesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1beta1.Note[] = []; + stream.on('data', (response: protos.grafeas.v1beta1.Note) => { + 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.listNotes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNotes, request)); + assert.strictEqual( + (client.descriptors.page.listNotes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listNotesStream with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listNotes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listNotesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1beta1.Note[] = []; + stream.on('data', (response: protos.grafeas.v1beta1.Note) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listNotes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNotes, request)); + assert.strictEqual( + (client.descriptors.page.listNotes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNotes without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + generateSampleMessage(new protos.grafeas.v1beta1.Note()), + ]; + client.descriptors.page.listNotes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.grafeas.v1beta1.INote[] = []; + const iterable = client.listNotesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNotes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNotes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNotes with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listNotes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNotesAsync(request); + await assert.rejects(async () => { + const responses: protos.grafeas.v1beta1.INote[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNotes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNotes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listNoteOccurrences', () => { + it('invokes listNoteOccurrences without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + ]; + client.innerApiCalls.listNoteOccurrences = stubSimpleCall(expectedResponse); + const [response] = await client.listNoteOccurrences(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listNoteOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listNoteOccurrences without error using callback', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + ]; + client.innerApiCalls.listNoteOccurrences = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNoteOccurrences( + request, + (err?: Error|null, result?: protos.grafeas.v1beta1.IOccurrence[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listNoteOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listNoteOccurrences with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listNoteOccurrences = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listNoteOccurrences(request), expectedError); + assert((client.innerApiCalls.listNoteOccurrences as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listNoteOccurrencesStream without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + ]; + client.descriptors.page.listNoteOccurrences.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listNoteOccurrencesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1beta1.Occurrence[] = []; + stream.on('data', (response: protos.grafeas.v1beta1.Occurrence) => { + 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.listNoteOccurrences.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNoteOccurrences, request)); + assert.strictEqual( + (client.descriptors.page.listNoteOccurrences.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listNoteOccurrencesStream with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedError = new Error('expected'); + client.descriptors.page.listNoteOccurrences.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listNoteOccurrencesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.grafeas.v1beta1.Occurrence[] = []; + stream.on('data', (response: protos.grafeas.v1beta1.Occurrence) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listNoteOccurrences.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNoteOccurrences, request)); + assert.strictEqual( + (client.descriptors.page.listNoteOccurrences.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNoteOccurrences without error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedResponse = [ + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), + ]; + client.descriptors.page.listNoteOccurrences.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.grafeas.v1beta1.IOccurrence[] = []; + const iterable = client.listNoteOccurrencesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNoteOccurrences with error', async () => { + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listNoteOccurrences.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNoteOccurrencesAsync(request); + await assert.rejects(async () => { + const responses: protos.grafeas.v1beta1.IOccurrence[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('scanConfig', () => { + const fakePath = "/rendered/path/scanConfig"; + const expectedParameters = { + project: "projectValue", + scan_config: "scanConfigValue", + }; + const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ + 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)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1beta1/tsconfig.json b/owl-bot-staging/v1beta1/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1beta1/webpack.config.js b/owl-bot-staging/v1beta1/webpack.config.js new file mode 100644 index 0000000..f9beacf --- /dev/null +++ b/owl-bot-staging/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'containeranalysis', + filename: './containeranalysis.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From 82a71988d2c5314bc490f8f63015d0a2b61f0663 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 22 Jun 2021 01:10:32 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md --- owl-bot-staging/v1/.eslintignore | 6 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 10 - owl-bot-staging/v1/package.json | 65 - .../v1/containeranalysis.proto | 162 -- .../v1/protos/grafeas/v1/attestation.proto | 73 - .../v1/protos/grafeas/v1/build.proto | 50 - .../v1/protos/grafeas/v1/common.proto | 103 - .../v1/protos/grafeas/v1/cvss.proto | 85 - .../v1/protos/grafeas/v1/deployment.proto | 66 - .../v1/protos/grafeas/v1/discovery.proto | 83 - .../v1/protos/grafeas/v1/grafeas.proto | 531 ----- .../v1/protos/grafeas/v1/image.proto | 83 - .../v1/protos/grafeas/v1/package.proto | 124 -- .../v1/protos/grafeas/v1/provenance.proto | 265 --- .../v1/protos/grafeas/v1/upgrade.proto | 114 - .../v1/protos/grafeas/v1/vulnerability.proto | 226 -- owl-bot-staging/v1/src/index.ts | 27 - .../v1/src/v1/container_analysis_client.ts | 731 ------- .../v1/container_analysis_client_config.json | 42 - .../src/v1/container_analysis_proto_list.json | 15 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 229 -- owl-bot-staging/v1/src/v1/grafeas_client.ts | 1795 ---------------- .../v1/src/v1/grafeas_client_config.json | 82 - .../v1/src/v1/grafeas_proto_list.json | 15 - owl-bot-staging/v1/src/v1/index.ts | 20 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - owl-bot-staging/v1/system-test/install.ts | 49 - .../v1/test/gapic_container_analysis_v1.ts | 565 ----- owl-bot-staging/v1/test/gapic_grafeas_v1.ts | 1866 ---------------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1beta1/.eslintignore | 6 - owl-bot-staging/v1beta1/.eslintrc.json | 3 - owl-bot-staging/v1beta1/.gitignore | 14 - owl-bot-staging/v1beta1/.jsdoc.js | 55 - owl-bot-staging/v1beta1/.mocharc.js | 33 - owl-bot-staging/v1beta1/.prettierrc.js | 22 - owl-bot-staging/v1beta1/README.md | 1 - .../v1beta1/linkinator.config.json | 10 - owl-bot-staging/v1beta1/package.json | 65 - .../v1beta1/attestation/attestation.proto | 170 -- .../v1beta1/common/common.proto | 101 - .../v1beta1/containeranalysis.proto | 219 -- .../containeranalysis/v1beta1/cvss/cvss.proto | 85 - .../v1beta1/deployment/deployment.proto | 74 - .../v1beta1/discovery/discovery.proto | 86 - .../v1beta1/grafeas/grafeas.proto | 506 ----- .../v1beta1/image/image.proto | 145 -- .../v1beta1/package/package.proto | 127 -- .../v1beta1/provenance/provenance.proto | 164 -- .../v1beta1/source/source.proto | 134 -- .../v1beta1/vulnerability/vulnerability.proto | 203 -- owl-bot-staging/v1beta1/src/index.ts | 27 - .../container_analysis_v1_beta1_client.ts | 959 --------- ...ainer_analysis_v1_beta1_client_config.json | 50 - ...ontainer_analysis_v1_beta1_proto_list.json | 15 - .../v1beta1/src/v1beta1/gapic_metadata.json | 263 --- .../src/v1beta1/grafeas_v1_beta1_client.ts | 1800 ---------------- .../grafeas_v1_beta1_client_config.json | 86 - .../v1beta1/grafeas_v1_beta1_proto_list.json | 15 - owl-bot-staging/v1beta1/src/v1beta1/index.ts | 20 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1beta1/system-test/install.ts | 49 - ...pic_container_analysis_v1_beta1_v1beta1.ts | 880 -------- .../test/gapic_grafeas_v1_beta1_v1beta1.ts | 1882 ----------------- owl-bot-staging/v1beta1/tsconfig.json | 19 - owl-bot-staging/v1beta1/webpack.config.js | 64 - src/v1/container_analysis_client.ts | 16 +- .../container_analysis_v1_beta1_client.ts | 24 +- src/v1beta1/grafeas_v1_beta1_client.ts | 60 +- 78 files changed, 50 insertions(+), 16227 deletions(-) delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/devtools/containeranalysis/v1/containeranalysis.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/attestation.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/build.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/common.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/cvss.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/deployment.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/discovery.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/grafeas.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/image.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/package.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/provenance.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/upgrade.proto delete mode 100644 owl-bot-staging/v1/protos/grafeas/v1/vulnerability.proto delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/container_analysis_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/container_analysis_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/container_analysis_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/grafeas_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/grafeas_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/grafeas_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_container_analysis_v1.ts delete mode 100644 owl-bot-staging/v1/test/gapic_grafeas_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1beta1/.gitignore delete mode 100644 owl-bot-staging/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1beta1/README.md delete mode 100644 owl-bot-staging/v1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1beta1/package.json delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/common/common.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/image/image.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/package/package.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/source/source.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto delete mode 100644 owl-bot-staging/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client_config.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_proto_list.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client_config.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_proto_list.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1beta1/test/gapic_container_analysis_v1_beta1_v1beta1.ts delete mode 100644 owl-bot-staging/v1beta1/test/gapic_grafeas_v1_beta1_v1beta1.ts delete mode 100644 owl-bot-staging/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index 521dc25..0000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 7821534..0000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b23..0000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index cb937ac..0000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2021 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/containeranalysis', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 50bc7f7..0000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 84f4713..0000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index dc843b7..0000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Containeranalysis: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index 29a223b..0000000 --- a/owl-bot-staging/v1/linkinator.config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io" - ], - "silent": true, - "concurrency": 10 -} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 5e3eb9c..0000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/containeranalysis", - "version": "0.1.0", - "description": "Containeranalysis client for Node.js", - "repository": "googleapis/nodejs-containeranalysis", - "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 containeranalysis", - "containeranalysis", - "container analysis", - "grafeas" - ], - "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.15.0" - }, - "devDependencies": { - "@types/mocha": "^8.2.2", - "@types/node": "^14.17.3", - "@types/sinon": "^10.0.2", - "c8": "^7.7.3", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.0", - "jsdoc-region-tag": "^1.1.0", - "linkinator": "^2.13.6", - "mocha": "^8.4.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^11.1.1", - "ts-loader": "^9.2.3", - "typescript": "^4.3.4", - "webpack": "^5.39.1", - "webpack-cli": "^4.7.2" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1/protos/google/devtools/containeranalysis/v1/containeranalysis.proto b/owl-bot-staging/v1/protos/google/devtools/containeranalysis/v1/containeranalysis.proto deleted file mode 100644 index 2bd968c..0000000 --- a/owl-bot-staging/v1/protos/google/devtools/containeranalysis/v1/containeranalysis.proto +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.devtools.containeranalysis.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/protobuf/timestamp.proto"; -import "grafeas/v1/vulnerability.proto"; - -option csharp_namespace = "Google.Cloud.DevTools.ContainerAnalysis.V1"; -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1;containeranalysis"; -option java_multiple_files = true; -option java_package = "com.google.containeranalysis.v1"; -option objc_class_prefix = "GCA"; -option ruby_package = "Google::Cloud::ContainerAnalysis::V1"; -option php_namespace = "Google\\Cloud\\ContainerAnalysis\\V1"; - -// Retrieves analysis results of Cloud components such as Docker container -// images. The Container Analysis API is an implementation of the -// [Grafeas](https://grafeas.io) API. -// -// Analysis results are stored as a series of occurrences. An `Occurrence` -// contains information about a specific analysis instance on a resource. An -// occurrence refers to a `Note`. A note contains details describing the -// analysis and is generally stored in a separate project, called a `Provider`. -// Multiple occurrences can refer to the same note. -// -// For example, an SSL vulnerability could affect multiple images. In this case, -// there would be one note for the vulnerability and an occurrence for each -// image with the vulnerability referring to that note. -service ContainerAnalysis { - option (google.api.default_host) = "containeranalysis.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Sets the access control policy on the specified note or occurrence. - // Requires `containeranalysis.notes.setIamPolicy` or - // `containeranalysis.occurrences.setIamPolicy` permission if the resource is - // a note or an occurrence, respectively. - // - // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - // occurrences. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/notes/*}:setIamPolicy" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/occurrences/*}:setIamPolicy" - body: "*" - } - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Gets the access control policy for a note or an occurrence resource. - // Requires `containeranalysis.notes.setIamPolicy` or - // `containeranalysis.occurrences.setIamPolicy` permission if the resource is - // a note or occurrence, respectively. - // - // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - // occurrences. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/notes/*}:getIamPolicy" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/occurrences/*}:getIamPolicy" - body: "*" - } - }; - option (google.api.method_signature) = "resource"; - } - - // Returns the permissions that a caller has on the specified note or - // occurrence. Requires list permission on the project (for example, - // `containeranalysis.notes.list`). - // - // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - // occurrences. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) - returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/notes/*}:testIamPermissions" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/occurrences/*}:testIamPermissions" - body: "*" - } - }; - option (google.api.method_signature) = "resource,permissions"; - } - - // Gets a summary of the number and severity of occurrences. - rpc GetVulnerabilityOccurrencesSummary( - GetVulnerabilityOccurrencesSummaryRequest) - returns (VulnerabilityOccurrencesSummary) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/occurrences:vulnerabilitySummary" - }; - option (google.api.method_signature) = "parent,filter"; - } -} - -// Request to get a vulnerability summary for some set of occurrences. -message GetVulnerabilityOccurrencesSummaryRequest { - // The name of the project to get a vulnerability summary for in the form of - // `projects/[PROJECT_ID]`. - string parent = 1 [ - (google.api.resource_reference).type = - "cloudresourcemanager.googleapis.com/Project", - (google.api.field_behavior) = REQUIRED - ]; - - // The filter expression. - string filter = 2; -} - -// A summary of how many vulnerability occurrences there are per resource and -// severity type. -message VulnerabilityOccurrencesSummary { - // Per resource and severity counts of fixable and total vulnerabilities. - message FixableTotalByDigest { - // The affected resource. - string resource_uri = 1; - - // The severity for this count. SEVERITY_UNSPECIFIED indicates total across - // all severities. - grafeas.v1.Severity severity = 2; - - // The number of fixable vulnerabilities associated with this resource. - int64 fixable_count = 3; - - // The total number of vulnerabilities associated with this resource. - int64 total_count = 4; - } - - // A listing by resource of the number of fixable and total vulnerabilities. - repeated FixableTotalByDigest counts = 1; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/attestation.proto b/owl-bot-staging/v1/protos/grafeas/v1/attestation.proto deleted file mode 100644 index 61423d3..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/attestation.proto +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -import "grafeas/v1/common.proto"; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// An attestation wrapper with a PGP-compatible signature. This message only -// supports `ATTACHED` signatures, where the payload that is signed is included -// alongside the signature itself in the same file. - -// Note kind that represents a logical attestation "role" or "authority". For -// example, an organization might have one `Authority` for "QA" and one for -// "build". This note is intended to act strictly as a grouping mechanism for -// the attached occurrences (Attestations). This grouping mechanism also -// provides a security boundary, since IAM ACLs gate the ability for a principle -// to attach an occurrence to a given note. It also provides a single point of -// lookup to find all attached attestation occurrences, even if they don't all -// live in the same project. -message AttestationNote { - // This submessage provides human-readable hints about the purpose of the - // authority. Because the name of a note acts as its resource reference, it is - // important to disambiguate the canonical name of the Note (which might be a - // UUID for security purposes) from "readable" names more suitable for debug - // output. Note that these hints should not be used to look up authorities in - // security sensitive contexts, such as when looking up attestations to - // verify. - message Hint { - // Required. The human readable name of this attestation authority, for - // example "qa". - string human_readable_name = 1; - } - - // Hint hints at the purpose of the attestation authority. - Hint hint = 1; -} - -// Occurrence that represents a single "attestation". The authenticity of an -// attestation can be verified using the attached signature. If the verifier -// trusts the public key of the signer, then verifying the signature is -// sufficient to establish trust. In this circumstance, the authority to which -// this attestation is attached is primarily useful for lookup (how to find -// this attestation if you already know the authority and artifact to be -// verified) and intent (for which authority this attestation was intended to -// sign. -message AttestationOccurrence { - // Required. The serialized payload that is verified by one or more - // `signatures`. - bytes serialized_payload = 1; - // One or more signatures over `serialized_payload`. Verifier implementations - // should consider this attestation message verified if at least one - // `signature` verifies `serialized_payload`. See `Signature` in common.proto - // for more details on signature structure and verification. - repeated Signature signatures = 2; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/build.proto b/owl-bot-staging/v1/protos/grafeas/v1/build.proto deleted file mode 100644 index c0e9c75..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/build.proto +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -import "grafeas/v1/provenance.proto"; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// Note holding the version of the provider's builder and the signature of the -// provenance message in the build details occurrence. -message BuildNote { - // Required. Immutable. Version of the builder which produced this build. - string builder_version = 1; -} - -// Details of a build occurrence. -message BuildOccurrence { - // Required. The actual provenance for the build. - grafeas.v1.BuildProvenance provenance = 1; - - // Serialized JSON representation of the provenance, used in generating the - // build signature in the corresponding build note. After verifying the - // signature, `provenance_bytes` can be unmarshalled and compared to the - // provenance to confirm that it is unchanged. A base64-encoded string - // representation of the provenance bytes is used for the signature in order - // to interoperate with openssl which expects this format for signature - // verification. - // - // The serialized form is captured both to avoid ambiguity in how the - // provenance is marshalled to json as well to prevent incompatibilities with - // future changes. - string provenance_bytes = 2; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/common.proto b/owl-bot-staging/v1/protos/grafeas/v1/common.proto deleted file mode 100644 index db780bb..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/common.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// Kind represents the kinds of notes supported. -enum NoteKind { - // Unknown. - NOTE_KIND_UNSPECIFIED = 0; - // The note and occurrence represent a package vulnerability. - VULNERABILITY = 1; - // The note and occurrence assert build provenance. - BUILD = 2; - // This represents an image basis relationship. - IMAGE = 3; - // This represents a package installed via a package manager. - PACKAGE = 4; - // The note and occurrence track deployment events. - DEPLOYMENT = 5; - // The note and occurrence track the initial discovery status of a resource. - DISCOVERY = 6; - // This represents a logical "role" that can attest to artifacts. - ATTESTATION = 7; - // This represents an available package upgrade. - UPGRADE = 8; -} - -// Metadata for any related URL information. -message RelatedUrl { - // Specific URL associated with the resource. - string url = 1; - // Label to describe usage of the URL. - string label = 2; -} - -// Verifiers (e.g. Kritis implementations) MUST verify signatures -// with respect to the trust anchors defined in policy (e.g. a Kritis policy). -// Typically this means that the verifier has been configured with a map from -// `public_key_id` to public key material (and any required parameters, e.g. -// signing algorithm). -// -// In particular, verification implementations MUST NOT treat the signature -// `public_key_id` as anything more than a key lookup hint. The `public_key_id` -// DOES NOT validate or authenticate a public key; it only provides a mechanism -// for quickly selecting a public key ALREADY CONFIGURED on the verifier through -// a trusted channel. Verification implementations MUST reject signatures in any -// of the following circumstances: -// * The `public_key_id` is not recognized by the verifier. -// * The public key that `public_key_id` refers to does not verify the -// signature with respect to the payload. -// -// The `signature` contents SHOULD NOT be "attached" (where the payload is -// included with the serialized `signature` bytes). Verifiers MUST ignore any -// "attached" payload and only verify signatures with respect to explicitly -// provided payload (e.g. a `payload` field on the proto message that holds -// this Signature, or the canonical serialization of the proto message that -// holds this signature). -message Signature { - // The content of the signature, an opaque bytestring. - // The payload that this signature verifies MUST be unambiguously provided - // with the Signature during verification. A wrapper message might provide - // the payload explicitly. Alternatively, a message might have a canonical - // serialization that can always be unambiguously computed to derive the - // payload. - bytes signature = 1; - - // The identifier for the public key that verifies this signature. - // * The `public_key_id` is required. - // * The `public_key_id` MUST be an RFC3986 conformant URI. - // * When possible, the `public_key_id` SHOULD be an immutable reference, - // such as a cryptographic digest. - // - // Examples of valid `public_key_id`s: - // - // OpenPGP V4 public key fingerprint: - // * "openpgp4fpr:74FAF3B861BDA0870C7B6DEF607E48D2A663AEEA" - // See https://www.iana.org/assignments/uri-schemes/prov/openpgp4fpr for more - // details on this scheme. - // - // RFC6920 digest-named SubjectPublicKeyInfo (digest of the DER - // serialization): - // * "ni:///sha-256;cD9o9Cq6LG3jD0iKXqEi_vdjJGecm_iXkbqVoScViaU" - // * "nih:///sha-256;703f68f42aba2c6de30f488a5ea122fef76324679c9bf89791ba95a1271589a5" - string public_key_id = 2; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/cvss.proto b/owl-bot-staging/v1/protos/grafeas/v1/cvss.proto deleted file mode 100644 index b41cd63..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/cvss.proto +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// Common Vulnerability Scoring System version 3. -// For details, see https://www.first.org/cvss/specification-document -message CVSSv3 { - // The base score is a function of the base metric scores. - float base_score = 1; - - float exploitability_score = 2; - - float impact_score = 3; - - // Base Metrics - // Represents the intrinsic characteristics of a vulnerability that are - // constant over time and across user environments. - AttackVector attack_vector = 5; - AttackComplexity attack_complexity = 6; - PrivilegesRequired privileges_required = 7; - UserInteraction user_interaction = 8; - Scope scope = 9; - Impact confidentiality_impact = 10; - Impact integrity_impact = 11; - Impact availability_impact = 12; - - enum AttackVector { - ATTACK_VECTOR_UNSPECIFIED = 0; - ATTACK_VECTOR_NETWORK = 1; - ATTACK_VECTOR_ADJACENT = 2; - ATTACK_VECTOR_LOCAL = 3; - ATTACK_VECTOR_PHYSICAL = 4; - } - - enum AttackComplexity { - ATTACK_COMPLEXITY_UNSPECIFIED = 0; - ATTACK_COMPLEXITY_LOW = 1; - ATTACK_COMPLEXITY_HIGH = 2; - } - - enum PrivilegesRequired { - PRIVILEGES_REQUIRED_UNSPECIFIED = 0; - PRIVILEGES_REQUIRED_NONE = 1; - PRIVILEGES_REQUIRED_LOW = 2; - PRIVILEGES_REQUIRED_HIGH = 3; - } - - enum UserInteraction { - USER_INTERACTION_UNSPECIFIED = 0; - USER_INTERACTION_NONE = 1; - USER_INTERACTION_REQUIRED = 2; - } - - enum Scope { - SCOPE_UNSPECIFIED = 0; - SCOPE_UNCHANGED = 1; - SCOPE_CHANGED = 2; - } - - enum Impact { - IMPACT_UNSPECIFIED = 0; - IMPACT_HIGH = 1; - IMPACT_LOW = 2; - IMPACT_NONE = 3; - } -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/deployment.proto b/owl-bot-staging/v1/protos/grafeas/v1/deployment.proto deleted file mode 100644 index 5204004..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/deployment.proto +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// An artifact that can be deployed in some runtime. -message DeploymentNote { - // Required. Resource URI for the artifact being deployed. - repeated string resource_uri = 1; -} - -// The period during which some deployable was active in a runtime. -message DeploymentOccurrence { - // Identity of the user that triggered this deployment. - string user_email = 1; - - // Required. Beginning of the lifetime of this deployment. - google.protobuf.Timestamp deploy_time = 2; - - // End of the lifetime of this deployment. - google.protobuf.Timestamp undeploy_time = 3; - - // Configuration used to create this deployment. - string config = 4; - - // Address of the runtime element hosting this deployment. - string address = 5; - - // Output only. Resource URI for the artifact being deployed taken from - // the deployable field with the same name. - repeated string resource_uri = 6; - - // Types of platforms. - enum Platform { - // Unknown. - PLATFORM_UNSPECIFIED = 0; - // Google Container Engine. - GKE = 1; - // Google App Engine: Flexible Environment. - FLEX = 2; - // Custom user-defined platform. - CUSTOM = 3; - } - // Platform hosting this deployment. - Platform platform = 7; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/discovery.proto b/owl-bot-staging/v1/protos/grafeas/v1/discovery.proto deleted file mode 100644 index e079925..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/discovery.proto +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "grafeas/v1/common.proto"; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// A note that indicates a type of analysis a provider would perform. This note -// exists in a provider's project. A `Discovery` occurrence is created in a -// consumer's project at the start of analysis. -message DiscoveryNote { - // Required. Immutable. The kind of analysis that is handled by this - // discovery. - grafeas.v1.NoteKind analysis_kind = 1; -} - -// Provides information about the analysis status of a discovered resource. -message DiscoveryOccurrence { - // Whether the resource is continuously analyzed. - enum ContinuousAnalysis { - // Unknown. - CONTINUOUS_ANALYSIS_UNSPECIFIED = 0; - // The resource is continuously analyzed. - ACTIVE = 1; - // The resource is ignored for continuous analysis. - INACTIVE = 2; - } - - // Whether the resource is continuously analyzed. - ContinuousAnalysis continuous_analysis = 1; - - // Analysis status for a resource. Currently for initial analysis only (not - // updated in continuous analysis). - enum AnalysisStatus { - // Unknown. - ANALYSIS_STATUS_UNSPECIFIED = 0; - // Resource is known but no action has been taken yet. - PENDING = 1; - // Resource is being analyzed. - SCANNING = 2; - // Analysis has finished successfully. - FINISHED_SUCCESS = 3; - // Analysis has finished unsuccessfully, the analysis itself is in a bad - // state. - FINISHED_FAILED = 4; - // The resource is known not to be supported - FINISHED_UNSUPPORTED = 5; - } - - // The status of discovery for the resource. - AnalysisStatus analysis_status = 2; - - // When an error is encountered this will contain a LocalizedMessage under - // details to show to the user. The LocalizedMessage is output only and - // populated by the API. - google.rpc.Status analysis_status_error = 3; - - // The CPE of the resource being scanned. - string cpe = 4; - - // The last time this resource was scanned. - google.protobuf.Timestamp last_scan_time = 5; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/grafeas.proto b/owl-bot-staging/v1/protos/grafeas/v1/grafeas.proto deleted file mode 100644 index 57b2fc2..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/grafeas.proto +++ /dev/null @@ -1,531 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "grafeas/v1/attestation.proto"; -import "grafeas/v1/build.proto"; -import "grafeas/v1/common.proto"; -import "grafeas/v1/deployment.proto"; -import "grafeas/v1/discovery.proto"; -import "grafeas/v1/image.proto"; -import "grafeas/v1/package.proto"; -import "grafeas/v1/upgrade.proto"; -import "grafeas/v1/vulnerability.proto"; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; -option (google.api.resource_definition) = { - type: "grafeas.io/Project" - pattern: "projects/{project}" -}; - -// [Grafeas](https://grafeas.io) API. -// -// Retrieves analysis results of Cloud components such as Docker container -// images. -// -// Analysis results are stored as a series of occurrences. An `Occurrence` -// contains information about a specific analysis instance on a resource. An -// occurrence refers to a `Note`. A note contains details describing the -// analysis and is generally stored in a separate project, called a `Provider`. -// Multiple occurrences can refer to the same note. -// -// For example, an SSL vulnerability could affect multiple images. In this case, -// there would be one note for the vulnerability and an occurrence for each -// image with the vulnerability referring to that note. -service Grafeas { - option (google.api.default_host) = "containeranalysis.googleapis.com"; - - // Gets the specified occurrence. - rpc GetOccurrence(GetOccurrenceRequest) returns (Occurrence) { - option (google.api.http) = { - get: "/v1/{name=projects/*/occurrences/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists occurrences for the specified project. - rpc ListOccurrences(ListOccurrencesRequest) - returns (ListOccurrencesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/occurrences" - }; - option (google.api.method_signature) = "parent,filter"; - } - - // Deletes the specified occurrence. For example, use this method to delete an - // occurrence when the occurrence is no longer applicable for the given - // resource. - rpc DeleteOccurrence(DeleteOccurrenceRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/occurrences/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new occurrence. - rpc CreateOccurrence(CreateOccurrenceRequest) returns (Occurrence) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/occurrences" - body: "occurrence" - }; - option (google.api.method_signature) = "parent,occurrence"; - } - - // Creates new occurrences in batch. - rpc BatchCreateOccurrences(BatchCreateOccurrencesRequest) - returns (BatchCreateOccurrencesResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/occurrences:batchCreate" - body: "*" - }; - option (google.api.method_signature) = "parent,occurrences"; - } - - // Updates the specified occurrence. - rpc UpdateOccurrence(UpdateOccurrenceRequest) returns (Occurrence) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/occurrences/*}" - body: "occurrence" - }; - option (google.api.method_signature) = "name,occurrence,update_mask"; - } - - // Gets the note attached to the specified occurrence. Consumer projects can - // use this method to get a note that belongs to a provider project. - rpc GetOccurrenceNote(GetOccurrenceNoteRequest) returns (Note) { - option (google.api.http) = { - get: "/v1/{name=projects/*/occurrences/*}/notes" - }; - option (google.api.method_signature) = "name"; - } - - // Gets the specified note. - rpc GetNote(GetNoteRequest) returns (Note) { - option (google.api.http) = { - get: "/v1/{name=projects/*/notes/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists notes for the specified project. - rpc ListNotes(ListNotesRequest) returns (ListNotesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/notes" - }; - option (google.api.method_signature) = "parent,filter"; - } - - // Deletes the specified note. - rpc DeleteNote(DeleteNoteRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/notes/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new note. - rpc CreateNote(CreateNoteRequest) returns (Note) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/notes" - body: "note" - }; - option (google.api.method_signature) = "parent,note_id,note"; - } - - // Creates new notes in batch. - rpc BatchCreateNotes(BatchCreateNotesRequest) - returns (BatchCreateNotesResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/notes:batchCreate" - body: "*" - }; - option (google.api.method_signature) = "parent,notes"; - } - - // Updates the specified note. - rpc UpdateNote(UpdateNoteRequest) returns (Note) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/notes/*}" - body: "note" - }; - option (google.api.method_signature) = "name,note,update_mask"; - } - - // Lists occurrences referencing the specified note. Provider projects can use - // this method to get all occurrences across consumer projects referencing the - // specified note. - rpc ListNoteOccurrences(ListNoteOccurrencesRequest) - returns (ListNoteOccurrencesResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/notes/*}/occurrences" - }; - option (google.api.method_signature) = "name,filter"; - } -} - -// An instance of an analysis type that has been found on a resource. -message Occurrence { - option (google.api.resource) = { - type: "grafeas.io/Occurrence" - pattern: "projects/{project}/occurrences/{occurrence}" - }; - - // Output only. The name of the occurrence in the form of - // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - string name = 1; - - // Required. Immutable. A URI that represents the resource for which the - // occurrence applies. For example, - // `https://gcr.io/project/image@sha256:123abc` for a Docker image. - string resource_uri = 2; - - // Required. Immutable. The analysis note associated with this occurrence, in - // the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. This field can be - // used as a filter in list requests. - string note_name = 3; - - // Output only. This explicitly denotes which of the occurrence details are - // specified. This field can be used as a filter in list requests. - grafeas.v1.NoteKind kind = 4; - - // A description of actions that can be taken to remedy the note. - string remediation = 5; - - // Output only. The time this occurrence was created. - google.protobuf.Timestamp create_time = 6; - - // Output only. The time this occurrence was last updated. - google.protobuf.Timestamp update_time = 7; - - // Required. Immutable. Describes the details of the note kind found on this - // resource. - oneof details { - // Describes a security vulnerability. - grafeas.v1.VulnerabilityOccurrence vulnerability = 8; - // Describes a verifiable build. - grafeas.v1.BuildOccurrence build = 9; - // Describes how this resource derives from the basis in the associated - // note. - grafeas.v1.ImageOccurrence image = 10; - // Describes the installation of a package on the linked resource. - grafeas.v1.PackageOccurrence package = 11; - // Describes the deployment of an artifact on a runtime. - grafeas.v1.DeploymentOccurrence deployment = 12; - // Describes when a resource was discovered. - grafeas.v1.DiscoveryOccurrence discovery = 13; - // Describes an attestation of an artifact. - grafeas.v1.AttestationOccurrence attestation = 14; - // Describes an available package upgrade on the linked resource. - grafeas.v1.UpgradeOccurrence upgrade = 15; - } -} - -// A type of analysis that can be done for a resource. -message Note { - option (google.api.resource) = { - type: "grafeas.io/Note" - pattern: "projects/{project}/notes/{note}" - }; - - // Output only. The name of the note in the form of - // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - string name = 1; - - // A one sentence description of this note. - string short_description = 2; - - // A detailed description of this note. - string long_description = 3; - - // Output only. The type of analysis. This field can be used as a filter in - // list requests. - grafeas.v1.NoteKind kind = 4; - - // URLs associated with this note. - repeated grafeas.v1.RelatedUrl related_url = 5; - - // Time of expiration for this note. Empty if note does not expire. - google.protobuf.Timestamp expiration_time = 6; - - // Output only. The time this note was created. This field can be used as a - // filter in list requests. - google.protobuf.Timestamp create_time = 7; - - // Output only. The time this note was last updated. This field can be used as - // a filter in list requests. - google.protobuf.Timestamp update_time = 8; - - // Other notes related to this note. - repeated string related_note_names = 9; - - // Required. Immutable. The type of analysis this note represents. - oneof type { - // A note describing a package vulnerability. - grafeas.v1.VulnerabilityNote vulnerability = 10; - // A note describing build provenance for a verifiable build. - grafeas.v1.BuildNote build = 11; - // A note describing a base image. - grafeas.v1.ImageNote image = 12; - // A note describing a package hosted by various package managers. - grafeas.v1.PackageNote package = 13; - // A note describing something that can be deployed. - grafeas.v1.DeploymentNote deployment = 14; - // A note describing the initial analysis of a resource. - grafeas.v1.DiscoveryNote discovery = 15; - // A note describing an attestation role. - grafeas.v1.AttestationNote attestation = 16; - // A note describing available package upgrades. - grafeas.v1.UpgradeNote upgrade = 17; - } -} - -// Request to get an occurrence. -message GetOccurrenceRequest { - // The name of the occurrence in the form of - // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Occurrence" - ]; -} - -// Request to list occurrences. -message ListOccurrencesRequest { - // The name of the project to list occurrences for in the form of - // `projects/[PROJECT_ID]`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Project" - ]; - - // The filter expression. - string filter = 2; - - // Number of occurrences to return in the list. Must be positive. Max allowed - // page size is 1000. If not specified, page size defaults to 20. - int32 page_size = 3; - - // Token to provide to skip to a particular spot in the list. - string page_token = 4; -} - -// Response for listing occurrences. -message ListOccurrencesResponse { - // The occurrences requested. - repeated Occurrence occurrences = 1; - // The next pagination token in the list response. It should be used as - // `page_token` for the following request. An empty value means no more - // results. - string next_page_token = 2; -} - -// Request to delete an occurrence. -message DeleteOccurrenceRequest { - // The name of the occurrence in the form of - // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Occurrence" - ]; -} - -// Request to create a new occurrence. -message CreateOccurrenceRequest { - // The name of the project in the form of `projects/[PROJECT_ID]`, under which - // the occurrence is to be created. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Project" - ]; - // The occurrence to create. - Occurrence occurrence = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request to update an occurrence. -message UpdateOccurrenceRequest { - // The name of the occurrence in the form of - // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Occurrence" - ]; - // The updated occurrence. - Occurrence occurrence = 2 [(google.api.field_behavior) = REQUIRED]; - // The fields to update. - google.protobuf.FieldMask update_mask = 3; -} - -// Request to get a note. -message GetNoteRequest { - // The name of the note in the form of - // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Note" - ]; -} - -// Request to get the note to which the specified occurrence is attached. -message GetOccurrenceNoteRequest { - // The name of the occurrence in the form of - // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Occurrence" - ]; -} - -// Request to list notes. -message ListNotesRequest { - // The name of the project to list notes for in the form of - // `projects/[PROJECT_ID]`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Project" - ]; - - // The filter expression. - string filter = 2; - - // Number of notes to return in the list. Must be positive. Max allowed page - // size is 1000. If not specified, page size defaults to 20. - int32 page_size = 3; - - // Token to provide to skip to a particular spot in the list. - string page_token = 4; -} - -// Response for listing notes. -message ListNotesResponse { - // The notes requested. - repeated Note notes = 1; - // The next pagination token in the list response. It should be used as - // `page_token` for the following request. An empty value means no more - // results. - string next_page_token = 2; -} - -// Request to delete a note. -message DeleteNoteRequest { - // The name of the note in the form of - // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Note" - ]; -} - -// Request to create a new note. -message CreateNoteRequest { - // The name of the project in the form of `projects/[PROJECT_ID]`, under which - // the note is to be created. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Project" - ]; - // The ID to use for this note. - string note_id = 2 [(google.api.field_behavior) = REQUIRED]; - // The note to create. - Note note = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request to update a note. -message UpdateNoteRequest { - // The name of the note in the form of - // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Note" - ]; - // The updated note. - Note note = 2 [(google.api.field_behavior) = REQUIRED]; - // The fields to update. - google.protobuf.FieldMask update_mask = 3; -} - -// Request to list occurrences for a note. -message ListNoteOccurrencesRequest { - // The name of the note to list occurrences for in the form of - // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Note" - ]; - // The filter expression. - string filter = 2; - // Number of occurrences to return in the list. - int32 page_size = 3; - // Token to provide to skip to a particular spot in the list. - string page_token = 4; -} - -// Response for listing occurrences for a note. -message ListNoteOccurrencesResponse { - // The occurrences attached to the specified note. - repeated Occurrence occurrences = 1; - // Token to provide to skip to a particular spot in the list. - string next_page_token = 2; -} - -// Request to create notes in batch. -message BatchCreateNotesRequest { - // The name of the project in the form of `projects/[PROJECT_ID]`, under which - // the notes are to be created. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Project" - ]; - - // The notes to create. Max allowed length is 1000. - map notes = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response for creating notes in batch. -message BatchCreateNotesResponse { - // The notes that were created. - repeated Note notes = 1; -} - -// Request to create occurrences in batch. -message BatchCreateOccurrencesRequest { - // The name of the project in the form of `projects/[PROJECT_ID]`, under which - // the occurrences are to be created. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "grafeas.io/Project" - ]; - - // The occurrences to create. Max allowed length is 1000. - repeated Occurrence occurrences = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response for creating occurrences in batch. -message BatchCreateOccurrencesResponse { - // The occurrences that were created. - repeated Occurrence occurrences = 1; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/image.proto b/owl-bot-staging/v1/protos/grafeas/v1/image.proto deleted file mode 100644 index 9ac162c..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/image.proto +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// Layer holds metadata specific to a layer of a Docker image. -message Layer { - // Required. The recovered Dockerfile directive used to construct this layer. - // See https://docs.docker.com/engine/reference/builder/ for more information. - string directive = 1; - - // The recovered arguments to the Dockerfile directive. - string arguments = 2; -} - -// A set of properties that uniquely identify a given Docker image. -message Fingerprint { - // Required. The layer ID of the final layer in the Docker image's v1 - // representation. - string v1_name = 1; - - // Required. The ordered list of v2 blobs that represent a given image. - repeated string v2_blob = 2; - - // Output only. The name of the image's v2 blobs computed via: - // [bottom] := v2_blob[bottom] - // [N] := sha256(v2_blob[N] + " " + v2_name[N+1]) - // Only the name of the final blob is kept. - string v2_name = 3; -} - -// Basis describes the base image portion (Note) of the DockerImage -// relationship. Linked occurrences are derived from this or an equivalent image -// via: -// FROM -// Or an equivalent reference, e.g., a tag of the resource_url. -message ImageNote { - // Required. Immutable. The resource_url for the resource representing the - // basis of associated occurrence images. - string resource_url = 1; - - // Required. Immutable. The fingerprint of the base image. - Fingerprint fingerprint = 2; -} - -// Details of the derived image portion of the DockerImage relationship. This -// image would be produced from a Dockerfile with FROM . -message ImageOccurrence { - // Required. The fingerprint of the derived image. - Fingerprint fingerprint = 1; - - // Output only. The number of layers by which this image differs from the - // associated image basis. - int32 distance = 2; - - // This contains layer-specific metadata, if populated it has length - // "distance" and is ordered with [distance] being the layer immediately - // following the base image and [1] being the final layer. - repeated Layer layer_info = 3; - - // Output only. This contains the base image URL for the derived image - // occurrence. - string base_resource_url = 4; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/package.proto b/owl-bot-staging/v1/protos/grafeas/v1/package.proto deleted file mode 100644 index b04686d..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/package.proto +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// Instruction set architectures supported by various package managers. -enum Architecture { - // Unknown architecture. - ARCHITECTURE_UNSPECIFIED = 0; - // X86 architecture. - X86 = 1; - // X64 architecture. - X64 = 2; -} - -// This represents a particular channel of distribution for a given package. -// E.g., Debian's jessie-backports dpkg mirror. -message Distribution { - // Required. The cpe_uri in [CPE format](https://cpe.mitre.org/specification/) - // denoting the package manager version distributing a package. - string cpe_uri = 1; - - // The CPU architecture for which packages in this distribution channel were - // built. - Architecture architecture = 2; - - // The latest available version of this package in this distribution channel. - Version latest_version = 3; - - // A freeform string denoting the maintainer of this package. - string maintainer = 4; - - // The distribution channel-specific homepage for this package. - string url = 5; - - // The distribution channel-specific description of this package. - string description = 6; -} - -// An occurrence of a particular package installation found within a system's -// filesystem. E.g., glibc was found in `/var/lib/dpkg/status`. -message Location { - // Required. The CPE URI in [CPE format](https://cpe.mitre.org/specification/) - // denoting the package manager version distributing a package. - string cpe_uri = 1; - - // The version installed at this location. - Version version = 2; - - // The path from which we gathered that this package/version is installed. - string path = 3; -} - -// This represents a particular package that is distributed over various -// channels. E.g., glibc (aka libc6) is distributed by many, at various -// versions. -message PackageNote { - // Required. Immutable. The name of the package. - string name = 1; - - // The various channels by which a package is distributed. - repeated Distribution distribution = 10; -} - -// Details on how a particular software package was installed on a system. -message PackageOccurrence { - // Output only. The name of the installed package. - string name = 1; - - // Required. All of the places within the filesystem versions of this package - // have been found. - repeated Location location = 2; -} - -// Version contains structured information about the version of a package. -message Version { - // Used to correct mistakes in the version numbering scheme. - int32 epoch = 1; - - // Required only when version kind is NORMAL. The main part of the version - // name. - string name = 2; - - // The iteration of the package build from the above version. - string revision = 3; - - // Whether this is an ordinary package version or a sentinel MIN/MAX version. - enum VersionKind { - // Unknown. - VERSION_KIND_UNSPECIFIED = 0; - // A standard package version. - NORMAL = 1; - // A special version representing negative infinity. - MINIMUM = 2; - // A special version representing positive infinity. - MAXIMUM = 3; - }; - - // Required. Distinguishes between sentinel MIN/MAX versions and normal - // versions. - VersionKind kind = 4; - - // Human readable version string. This string is of the form - // :- and is only set when kind is NORMAL. - string full_name = 5; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/provenance.proto b/owl-bot-staging/v1/protos/grafeas/v1/provenance.proto deleted file mode 100644 index 06b1097..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/provenance.proto +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// Provenance of a build. Contains all information needed to verify the full -// details about the build from source to completion. -message BuildProvenance { - // Required. Unique identifier of the build. - string id = 1; - - // ID of the project. - string project_id = 2; - - // Commands requested by the build. - repeated Command commands = 3; - - // Output of the build. - repeated Artifact built_artifacts = 4; - - // Time at which the build was created. - google.protobuf.Timestamp create_time = 5; - - // Time at which execution of the build was started. - google.protobuf.Timestamp start_time = 6; - - // Time at which execution of the build was finished. - google.protobuf.Timestamp end_time = 7; - - // E-mail address of the user who initiated this build. Note that this was the - // user's e-mail address at the time the build was initiated; this address may - // not represent the same end-user for all time. - string creator = 8; - - // URI where any logs for this provenance were written. - string logs_uri = 9; - - // Details of the Source input to the build. - Source source_provenance = 10; - - // Trigger identifier if the build was triggered automatically; empty if not. - string trigger_id = 11; - - // Special options applied to this build. This is a catch-all field where - // build providers can enter any desired additional details. - map build_options = 12; - - // Version string of the builder at the time this build was executed. - string builder_version = 13; -} - -// Source describes the location of the source used for the build. -message Source { - // If provided, the input binary artifacts for the build came from this - // location. - string artifact_storage_source_uri = 1; - - // Hash(es) of the build source, which can be used to verify that the original - // source integrity was maintained in the build. - // - // The keys to this map are file paths used as build source and the values - // contain the hash values for those files. - // - // If the build source came in a single package such as a gzipped tarfile - // (.tar.gz), the FileHash will be for the single path to that file. - map file_hashes = 2; - - // If provided, the source code used for the build came from this location. - SourceContext context = 3; - - // If provided, some of the source code used for the build may be found in - // these locations, in the case where the source repository had multiple - // remotes or submodules. This list will not include the context specified in - // the context field. - repeated SourceContext additional_contexts = 4; -} - -// Container message for hashes of byte content of files, used in source -// messages to verify integrity of source input to the build. -message FileHashes { - // Required. Collection of file hashes. - repeated Hash file_hash = 1; -} - -// Container message for hash values. -message Hash { - // Required. The type of hash that was performed, e.g. "SHA-256". - string type = 1; - // Required. The hash value. - bytes value = 2; -} - -// Command describes a step performed as part of the build pipeline. -message Command { - // Required. Name of the command, as presented on the command line, or if the - // command is packaged as a Docker container, as presented to `docker pull`. - string name = 1; - - // Environment variables set before running this command. - repeated string env = 2; - - // Command-line arguments used when executing this command. - repeated string args = 3; - - // Working directory (relative to project source root) used when running this - // command. - string dir = 4; - - // Optional unique identifier for this command, used in wait_for to reference - // this command as a dependency. - string id = 5; - - // The ID(s) of the command(s) that this command depends on. - repeated string wait_for = 6; -} - -// Artifact describes a build product. -message Artifact { - // Hash or checksum value of a binary, or Docker Registry 2.0 digest of a - // container. - string checksum = 1; - - // Artifact ID, if any; for container images, this will be a URL by digest - // like `gcr.io/projectID/imagename@sha256:123456`. - string id = 2; - - // Related artifact names. This may be the path to a binary or jar file, or in - // the case of a container build, the name used to push the container image to - // Google Container Registry, as presented to `docker push`. Note that a - // single Artifact ID can have multiple names, for example if two tags are - // applied to one image. - repeated string names = 3; -} - -// A SourceContext is a reference to a tree of files. A SourceContext together -// with a path point to a unique revision of a single file or directory. -message SourceContext { - // A SourceContext can refer any one of the following types of repositories. - oneof context { - // A SourceContext referring to a revision in a Google Cloud Source Repo. - CloudRepoSourceContext cloud_repo = 1; - - // A SourceContext referring to a Gerrit project. - GerritSourceContext gerrit = 2; - - // A SourceContext referring to any third party Git repo (e.g., GitHub). - GitSourceContext git = 3; - } - - // Labels with user defined metadata. - map labels = 4; -} - -// An alias to a repo revision. -message AliasContext { - // The type of an alias. - enum Kind { - // Unknown. - KIND_UNSPECIFIED = 0; - // Git tag. - FIXED = 1; - // Git branch. - MOVABLE = 2; - // Used to specify non-standard aliases. For example, if a Git repo has a - // ref named "refs/foo/bar". - OTHER = 4; - } - - // The alias kind. - Kind kind = 1; - - // The alias name. - string name = 2; -} - -// A CloudRepoSourceContext denotes a particular revision in a Google Cloud -// Source Repo. -message CloudRepoSourceContext { - // The ID of the repo. - RepoId repo_id = 1; - - // A revision in a Cloud Repo can be identified by either its revision ID or - // its alias. - oneof revision { - // A revision ID. - string revision_id = 2; - - // An alias, which may be a branch or tag. - AliasContext alias_context = 3; - } -} - -// A SourceContext referring to a Gerrit project. -message GerritSourceContext { - // The URI of a running Gerrit instance. - string host_uri = 1; - - // The full project name within the host. Projects may be nested, so - // "project/subproject" is a valid project name. The "repo name" is the - // hostURI/project. - string gerrit_project = 2; - - // A revision in a Gerrit project can be identified by either its revision ID - // or its alias. - oneof revision { - // A revision (commit) ID. - string revision_id = 3; - - // An alias, which may be a branch or tag. - AliasContext alias_context = 4; - } -} - -// A GitSourceContext denotes a particular revision in a third party Git -// repository (e.g., GitHub). -message GitSourceContext { - // Git repository URL. - string url = 1; - - // Git commit hash. - string revision_id = 2; -} - -// A unique identifier for a Cloud Repo. -message RepoId { - // A cloud repo can be identified by either its project ID and repository name - // combination, or its globally unique identifier. - oneof id { - // A combination of a project ID and a repo name. - ProjectRepoId project_repo_id = 1; - - // A server-assigned, globally unique identifier. - string uid = 2; - } -} - -// Selects a repo using a Google Cloud Platform project ID (e.g., -// winged-cargo-31) and a repo name within that project. -message ProjectRepoId { - // The ID of the project. - string project_id = 1; - - // The name of the repo. Leave empty for the default repo. - string repo_name = 2; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/upgrade.proto b/owl-bot-staging/v1/protos/grafeas/v1/upgrade.proto deleted file mode 100644 index 89d3892..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/upgrade.proto +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -import "google/protobuf/timestamp.proto"; -import "grafeas/v1/package.proto"; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// An Upgrade Note represents a potential upgrade of a package to a given -// version. For each package version combination (i.e. bash 4.0, bash 4.1, -// bash 4.1.2), there will be an Upgrade Note. For Windows, windows_update field -// represents the information related to the update. -message UpgradeNote { - // Required for non-Windows OS. The package this Upgrade is for. - string package = 1; - // Required for non-Windows OS. The version of the package in machine + human - // readable form. - grafeas.v1.Version version = 2; - // Metadata about the upgrade for each specific operating system. - repeated UpgradeDistribution distributions = 3; - // Required for Windows OS. Represents the metadata about the Windows update. - WindowsUpdate windows_update = 4; -} - -// The Upgrade Distribution represents metadata about the Upgrade for each -// operating system (CPE). Some distributions have additional metadata around -// updates, classifying them into various categories and severities. -message UpgradeDistribution { - // Required - The specific operating system this metadata applies to. See - // https://cpe.mitre.org/specification/. - string cpe_uri = 1; - // The operating system classification of this Upgrade, as specified by the - // upstream operating system upgrade feed. For Windows the classification is - // one of the category_ids listed at - // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ff357803(v=vs.85) - string classification = 2; - // The severity as specified by the upstream operating system. - string severity = 3; - // The cve tied to this Upgrade. - repeated string cve = 4; -} - -// Windows Update represents the metadata about the update for the Windows -// operating system. The fields in this message come from the Windows Update API -// documented at -// https://docs.microsoft.com/en-us/windows/win32/api/wuapi/nn-wuapi-iupdate. -message WindowsUpdate { - // The unique identifier of the update. - message Identity { - // The revision independent identifier of the update. - string update_id = 1; - // The revision number of the update. - int32 revision = 2; - } - // Required - The unique identifier for the update. - Identity identity = 1; - // The localized title of the update. - string title = 2; - // The localized description of the update. - string description = 3; - // The category to which the update belongs. - message Category { - // The identifier of the category. - string category_id = 1; - // The localized name of the category. - string name = 2; - } - // The list of categories to which the update belongs. - repeated Category categories = 4; - // The Microsoft Knowledge Base article IDs that are associated with the - // update. - repeated string kb_article_ids = 5; - // The hyperlink to the support information for the update. - string support_url = 6; - // The last published timestamp of the update. - google.protobuf.Timestamp last_published_timestamp = 7; -} - -// An Upgrade Occurrence represents that a specific resource_url could install a -// specific upgrade. This presence is supplied via local sources (i.e. it is -// present in the mirror and the running system has noticed its availability). -// For Windows, both distribution and windows_update contain information for the -// Windows update. -message UpgradeOccurrence { - // Required for non-Windows OS. The package this Upgrade is for. - string package = 1; - // Required for non-Windows OS. The version of the package in a machine + - // human readable form. - grafeas.v1.Version parsed_version = 3; - // Metadata about the upgrade for available for the specific operating system - // for the resource_url. This allows efficient filtering, as well as - // making it easier to use the occurrence. - UpgradeDistribution distribution = 4; - // Required for Windows OS. Represents the metadata about the Windows update. - WindowsUpdate windows_update = 5; -} diff --git a/owl-bot-staging/v1/protos/grafeas/v1/vulnerability.proto b/owl-bot-staging/v1/protos/grafeas/v1/vulnerability.proto deleted file mode 100644 index 6c94cdf..0000000 --- a/owl-bot-staging/v1/protos/grafeas/v1/vulnerability.proto +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2019 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1; - -import "google/protobuf/timestamp.proto"; -import "grafeas/v1/common.proto"; -import "grafeas/v1/cvss.proto"; -import "grafeas/v1/package.proto"; - -option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1"; -option objc_class_prefix = "GRA"; - -// Note provider assigned severity/impact ranking. -enum Severity { - // Unknown. - SEVERITY_UNSPECIFIED = 0; - // Minimal severity. - MINIMAL = 1; - // Low severity. - LOW = 2; - // Medium severity. - MEDIUM = 3; - // High severity. - HIGH = 4; - // Critical severity. - CRITICAL = 5; -} - -// A security vulnerability that can be found in resources. -message VulnerabilityNote { - // The CVSS score of this vulnerability. CVSS score is on a scale of 0 - 10 - // where 0 indicates low severity and 10 indicates high severity. - float cvss_score = 1; - - // The note provider assigned severity of this vulnerability. - Severity severity = 2; - - // Details of all known distros and packages affected by this vulnerability. - repeated Detail details = 3; - - // A detail for a distro and package affected by this vulnerability and its - // associated fix (if one is available). - message Detail { - // The distro assigned severity of this vulnerability. - string severity_name = 1; - - // A vendor-specific description of this vulnerability. - string description = 2; - - // The type of package; whether native or non native (e.g., ruby gems, - // node.js packages, etc.). - string package_type = 3; - - // Required. The [CPE URI](https://cpe.mitre.org/specification/) this - // vulnerability affects. - string affected_cpe_uri = 4; - - // Required. The package this vulnerability affects. - string affected_package = 5; - - // The version number at the start of an interval in which this - // vulnerability exists. A vulnerability can affect a package between - // version numbers that are disjoint sets of intervals (example: - // [1.0.0-1.1.0], [2.4.6-2.4.8] and [4.5.6-4.6.8]) each of which will be - // represented in its own Detail. If a specific affected version is provided - // by a vulnerability database, affected_version_start and - // affected_version_end will be the same in that Detail. - grafeas.v1.Version affected_version_start = 6; - - // The version number at the end of an interval in which this vulnerability - // exists. A vulnerability can affect a package between version numbers - // that are disjoint sets of intervals (example: [1.0.0-1.1.0], - // [2.4.6-2.4.8] and [4.5.6-4.6.8]) each of which will be represented in its - // own Detail. If a specific affected version is provided by a vulnerability - // database, affected_version_start and affected_version_end will be the - // same in that Detail. - grafeas.v1.Version affected_version_end = 7; - - // The distro recommended [CPE URI](https://cpe.mitre.org/specification/) - // to update to that contains a fix for this vulnerability. It is possible - // for this to be different from the affected_cpe_uri. - string fixed_cpe_uri = 8; - - // The distro recommended package to update to that contains a fix for this - // vulnerability. It is possible for this to be different from the - // affected_package. - string fixed_package = 9; - - // The distro recommended version to update to that contains a - // fix for this vulnerability. Setting this to VersionKind.MAXIMUM means no - // such version is yet available. - grafeas.v1.Version fixed_version = 10; - - // Whether this detail is obsolete. Occurrences are expected not to point to - // obsolete details. - bool is_obsolete = 11; - - // The time this information was last changed at the source. This is an - // upstream timestamp from the underlying information source - e.g. Ubuntu - // security tracker. - google.protobuf.Timestamp source_update_time = 12; - } - - // The full description of the CVSSv3 for this vulnerability. - CVSSv3 cvss_v3 = 4; - - // Windows details get their own format because the information format and - // model don't match a normal detail. Specifically Windows updates are done as - // patches, thus Windows vulnerabilities really are a missing package, rather - // than a package being at an incorrect version. - repeated WindowsDetail windows_details = 5; - - message WindowsDetail { - // Required. The [CPE URI](https://cpe.mitre.org/specification/) this - // vulnerability affects. - string cpe_uri = 1; - - // Required. The name of this vulnerability. - string name = 2; - - // The description of this vulnerability. - string description = 3; - - // Required. The names of the KBs which have hotfixes to mitigate this - // vulnerability. Note that there may be multiple hotfixes (and thus - // multiple KBs) that mitigate a given vulnerability. Currently any listed - // KBs presence is considered a fix. - repeated KnowledgeBase fixing_kbs = 4; - - message KnowledgeBase { - // The KB name (generally of the form KB[0-9]+ (e.g., KB123456)). - string name = 1; - // A link to the KB in the [Windows update catalog] - // (https://www.catalog.update.microsoft.com/). - string url = 2; - } - } - - // The time this information was last changed at the source. This is an - // upstream timestamp from the underlying information source - e.g. Ubuntu - // security tracker. - google.protobuf.Timestamp source_update_time = 6; -} - -// An occurrence of a severity vulnerability on a resource. -message VulnerabilityOccurrence { - // The type of package; whether native or non native (e.g., ruby gems, node.js - // packages, etc.). - string type = 1; - - // Output only. The note provider assigned severity of this vulnerability. - Severity severity = 2; - - // Output only. The CVSS score of this vulnerability. CVSS score is on a - // scale of 0 - 10 where 0 indicates low severity and 10 indicates high - // severity. - float cvss_score = 3; - - // Required. The set of affected locations and their fixes (if available) - // within the associated resource. - repeated PackageIssue package_issue = 4; - - // A detail for a distro and package this vulnerability occurrence was found - // in and its associated fix (if one is available). - message PackageIssue { - // Required. The [CPE URI](https://cpe.mitre.org/specification/) this - // vulnerability was found in. - string affected_cpe_uri = 1; - - // Required. The package this vulnerability was found in. - string affected_package = 2; - - // Required. The version of the package that is installed on the resource - // affected by this vulnerability. - grafeas.v1.Version affected_version = 3; - - // The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability - // was fixed in. It is possible for this to be different from the - // affected_cpe_uri. - string fixed_cpe_uri = 4; - - // The package this vulnerability was fixed in. It is possible for this to - // be different from the affected_package. - string fixed_package = 5; - - // Required. The version of the package this vulnerability was fixed in. - // Setting this to VersionKind.MAXIMUM means no fix is yet available. - grafeas.v1.Version fixed_version = 6; - - // Output only. Whether a fix is available for this package. - bool fix_available = 7; - } - - // Output only. A one sentence description of this vulnerability. - string short_description = 5; - - // Output only. A detailed description of this vulnerability. - string long_description = 6; - - // Output only. URLs related to this vulnerability. - repeated grafeas.v1.RelatedUrl related_urls = 7; - - // The distro assigned severity for this vulnerability when it is available, - // otherwise this is the note provider assigned severity. - Severity effective_severity = 8; - - // Output only. Whether at least one of the affected packages has a fix - // available. - bool fix_available = 9; -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index d2d5b9d..0000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const ContainerAnalysisClient = v1.ContainerAnalysisClient; -type ContainerAnalysisClient = v1.ContainerAnalysisClient; -const GrafeasClient = v1.GrafeasClient; -type GrafeasClient = v1.GrafeasClient; -export {v1, ContainerAnalysisClient, GrafeasClient}; -export default {v1, ContainerAnalysisClient, GrafeasClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/container_analysis_client.ts b/owl-bot-staging/v1/src/v1/container_analysis_client.ts deleted file mode 100644 index 43c05ea..0000000 --- a/owl-bot-staging/v1/src/v1/container_analysis_client.ts +++ /dev/null @@ -1,731 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/container_analysis_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './container_analysis_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Retrieves analysis results of Cloud components such as Docker container - * images. The Container Analysis API is an implementation of the - * [Grafeas](https://grafeas.io) API. - * - * Analysis results are stored as a series of occurrences. An `Occurrence` - * contains information about a specific analysis instance on a resource. An - * occurrence refers to a `Note`. A note contains details describing the - * analysis and is generally stored in a separate project, called a `Provider`. - * Multiple occurrences can refer to the same note. - * - * For example, an SSL vulnerability could affect multiple images. In this case, - * there would be one note for the vulnerability and an occurrence for each - * image with the vulnerability referring to that note. - * @class - * @memberof v1 - */ -export class ContainerAnalysisClient { - 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}; - containerAnalysisStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ContainerAnalysisClient. - * - * @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 ContainerAnalysisClient; - 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 = { - notePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/notes/{note}' - ), - occurrencePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/occurrences/{occurrence}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.devtools.containeranalysis.v1.ContainerAnalysis', 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.containerAnalysisStub) { - return this.containerAnalysisStub; - } - - // Put together the "service stub" for - // google.devtools.containeranalysis.v1.ContainerAnalysis. - this.containerAnalysisStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.devtools.containeranalysis.v1.ContainerAnalysis') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.devtools.containeranalysis.v1.ContainerAnalysis, - 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 containerAnalysisStubMethods = - ['setIamPolicy', 'getIamPolicy', 'testIamPermissions', 'getVulnerabilityOccurrencesSummary']; - for (const methodName of containerAnalysisStubMethods) { - const callPromise = this.containerAnalysisStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.containerAnalysisStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'containeranalysis.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 'containeranalysis.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 -- - // ------------------- - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Sets the access control policy on the specified note or occurrence. - * Requires `containeranalysis.notes.setIamPolicy` or - * `containeranalysis.occurrences.setIamPolicy` permission if the resource is - * a note or an occurrence, respectively. - * - * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - * occurrences. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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.setIamPolicy(request); - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets the access control policy for a note or an occurrence resource. - * Requires `containeranalysis.notes.setIamPolicy` or - * `containeranalysis.occurrences.setIamPolicy` permission if the resource is - * a note or occurrence, respectively. - * - * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - * occurrences. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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.getIamPolicy(request); - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; -/** - * Returns the permissions that a caller has on the specified note or - * occurrence. Requires list permission on the project (for example, - * `containeranalysis.notes.list`). - * - * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - * occurrences. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * 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.testIamPermissions(request); - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - getVulnerabilityOccurrencesSummary( - request?: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, - options?: CallOptions): - Promise<[ - protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, - protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|undefined, {}|undefined - ]>; - getVulnerabilityOccurrencesSummary( - request: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, - options: CallOptions, - callback: Callback< - protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, - protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, - {}|null|undefined>): void; - getVulnerabilityOccurrencesSummary( - request: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, - callback: Callback< - protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, - protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets a summary of the number and severity of occurrences. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project to get a vulnerability summary for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @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 [VulnerabilityOccurrencesSummary]{@link google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary}. - * 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.getVulnerabilityOccurrencesSummary(request); - */ - getVulnerabilityOccurrencesSummary( - request?: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, - protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, - protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary, - protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest|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.getVulnerabilityOccurrencesSummary(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified note resource name string. - * - * @param {string} project - * @param {string} note - * @returns {string} Resource name string. - */ - notePath(project:string,note:string) { - return this.pathTemplates.notePathTemplate.render({ - project: project, - note: note, - }); - } - - /** - * Parse the project from Note resource. - * - * @param {string} noteName - * A fully-qualified path representing Note resource. - * @returns {string} A string representing the project. - */ - matchProjectFromNoteName(noteName: string) { - return this.pathTemplates.notePathTemplate.match(noteName).project; - } - - /** - * Parse the note from Note resource. - * - * @param {string} noteName - * A fully-qualified path representing Note resource. - * @returns {string} A string representing the note. - */ - matchNoteFromNoteName(noteName: string) { - return this.pathTemplates.notePathTemplate.match(noteName).note; - } - - /** - * Return a fully-qualified occurrence resource name string. - * - * @param {string} project - * @param {string} occurrence - * @returns {string} Resource name string. - */ - occurrencePath(project:string,occurrence:string) { - return this.pathTemplates.occurrencePathTemplate.render({ - project: project, - occurrence: occurrence, - }); - } - - /** - * Parse the project from Occurrence resource. - * - * @param {string} occurrenceName - * A fully-qualified path representing Occurrence resource. - * @returns {string} A string representing the project. - */ - matchProjectFromOccurrenceName(occurrenceName: string) { - return this.pathTemplates.occurrencePathTemplate.match(occurrenceName).project; - } - - /** - * Parse the occurrence from Occurrence resource. - * - * @param {string} occurrenceName - * A fully-qualified path representing Occurrence resource. - * @returns {string} A string representing the occurrence. - */ - matchOccurrenceFromOccurrenceName(occurrenceName: string) { - return this.pathTemplates.occurrencePathTemplate.match(occurrenceName).occurrence; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.containerAnalysisStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/container_analysis_client_config.json b/owl-bot-staging/v1/src/v1/container_analysis_client_config.json deleted file mode 100644 index 244cccc..0000000 --- a/owl-bot-staging/v1/src/v1/container_analysis_client_config.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "interfaces": { - "google.devtools.containeranalysis.v1.ContainerAnalysis": { - "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": { - "SetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetVulnerabilityOccurrencesSummary": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/container_analysis_proto_list.json b/owl-bot-staging/v1/src/v1/container_analysis_proto_list.json deleted file mode 100644 index e44e771..0000000 --- a/owl-bot-staging/v1/src/v1/container_analysis_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/devtools/containeranalysis/v1/containeranalysis.proto", - "../../protos/grafeas/v1/attestation.proto", - "../../protos/grafeas/v1/build.proto", - "../../protos/grafeas/v1/common.proto", - "../../protos/grafeas/v1/cvss.proto", - "../../protos/grafeas/v1/deployment.proto", - "../../protos/grafeas/v1/discovery.proto", - "../../protos/grafeas/v1/grafeas.proto", - "../../protos/grafeas/v1/image.proto", - "../../protos/grafeas/v1/package.proto", - "../../protos/grafeas/v1/provenance.proto", - "../../protos/grafeas/v1/upgrade.proto", - "../../protos/grafeas/v1/vulnerability.proto" -] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 322e34e..0000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,229 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.devtools.containeranalysis.v1", - "libraryPackage": "@google-cloud/containeranalysis", - "services": { - "ContainerAnalysis": { - "clients": { - "grpc": { - "libraryClient": "ContainerAnalysisClient", - "rpcs": { - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "GetVulnerabilityOccurrencesSummary": { - "methods": [ - "getVulnerabilityOccurrencesSummary" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ContainerAnalysisClient", - "rpcs": { - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "GetVulnerabilityOccurrencesSummary": { - "methods": [ - "getVulnerabilityOccurrencesSummary" - ] - } - } - } - } - }, - "Grafeas": { - "clients": { - "grpc": { - "libraryClient": "GrafeasClient", - "rpcs": { - "GetOccurrence": { - "methods": [ - "getOccurrence" - ] - }, - "DeleteOccurrence": { - "methods": [ - "deleteOccurrence" - ] - }, - "CreateOccurrence": { - "methods": [ - "createOccurrence" - ] - }, - "BatchCreateOccurrences": { - "methods": [ - "batchCreateOccurrences" - ] - }, - "UpdateOccurrence": { - "methods": [ - "updateOccurrence" - ] - }, - "GetOccurrenceNote": { - "methods": [ - "getOccurrenceNote" - ] - }, - "GetNote": { - "methods": [ - "getNote" - ] - }, - "DeleteNote": { - "methods": [ - "deleteNote" - ] - }, - "CreateNote": { - "methods": [ - "createNote" - ] - }, - "BatchCreateNotes": { - "methods": [ - "batchCreateNotes" - ] - }, - "UpdateNote": { - "methods": [ - "updateNote" - ] - }, - "ListOccurrences": { - "methods": [ - "listOccurrences", - "listOccurrencesStream", - "listOccurrencesAsync" - ] - }, - "ListNotes": { - "methods": [ - "listNotes", - "listNotesStream", - "listNotesAsync" - ] - }, - "ListNoteOccurrences": { - "methods": [ - "listNoteOccurrences", - "listNoteOccurrencesStream", - "listNoteOccurrencesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "GrafeasClient", - "rpcs": { - "GetOccurrence": { - "methods": [ - "getOccurrence" - ] - }, - "DeleteOccurrence": { - "methods": [ - "deleteOccurrence" - ] - }, - "CreateOccurrence": { - "methods": [ - "createOccurrence" - ] - }, - "BatchCreateOccurrences": { - "methods": [ - "batchCreateOccurrences" - ] - }, - "UpdateOccurrence": { - "methods": [ - "updateOccurrence" - ] - }, - "GetOccurrenceNote": { - "methods": [ - "getOccurrenceNote" - ] - }, - "GetNote": { - "methods": [ - "getNote" - ] - }, - "DeleteNote": { - "methods": [ - "deleteNote" - ] - }, - "CreateNote": { - "methods": [ - "createNote" - ] - }, - "BatchCreateNotes": { - "methods": [ - "batchCreateNotes" - ] - }, - "UpdateNote": { - "methods": [ - "updateNote" - ] - }, - "ListOccurrences": { - "methods": [ - "listOccurrences", - "listOccurrencesStream", - "listOccurrencesAsync" - ] - }, - "ListNotes": { - "methods": [ - "listNotes", - "listNotesStream", - "listNotesAsync" - ] - }, - "ListNoteOccurrences": { - "methods": [ - "listNoteOccurrences", - "listNoteOccurrencesStream", - "listNoteOccurrencesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/grafeas_client.ts b/owl-bot-staging/v1/src/v1/grafeas_client.ts deleted file mode 100644 index 892da48..0000000 --- a/owl-bot-staging/v1/src/v1/grafeas_client.ts +++ /dev/null @@ -1,1795 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/grafeas_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './grafeas_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * [Grafeas](https://grafeas.io) API. - * - * Retrieves analysis results of Cloud components such as Docker container - * images. - * - * Analysis results are stored as a series of occurrences. An `Occurrence` - * contains information about a specific analysis instance on a resource. An - * occurrence refers to a `Note`. A note contains details describing the - * analysis and is generally stored in a separate project, called a `Provider`. - * Multiple occurrences can refer to the same note. - * - * For example, an SSL vulnerability could affect multiple images. In this case, - * there would be one note for the vulnerability and an occurrence for each - * image with the vulnerability referring to that note. - * @class - * @memberof v1 - */ -export class GrafeasClient { - 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}; - grafeasStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of GrafeasClient. - * - * @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 GrafeasClient; - 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 = { - notePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/notes/{note}' - ), - occurrencePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/occurrences/{occurrence}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listOccurrences: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'occurrences'), - listNotes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'notes'), - listNoteOccurrences: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'occurrences') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.devtools.containeranalysis.v1.Grafeas', 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.grafeasStub) { - return this.grafeasStub; - } - - // Put together the "service stub" for - // google.devtools.containeranalysis.v1.Grafeas. - this.grafeasStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.devtools.containeranalysis.v1.Grafeas') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.devtools.containeranalysis.v1.Grafeas, - 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 grafeasStubMethods = - ['getOccurrence', 'listOccurrences', 'deleteOccurrence', 'createOccurrence', 'batchCreateOccurrences', 'updateOccurrence', 'getOccurrenceNote', 'getNote', 'listNotes', 'deleteNote', 'createNote', 'batchCreateNotes', 'updateNote', 'listNoteOccurrences']; - for (const methodName of grafeasStubMethods) { - const callPromise = this.grafeasStub.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.grafeasStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'containeranalysis.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 'containeranalysis.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 []; - } - - 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 -- - // ------------------- - getOccurrence( - request?: protos.grafeas.v1.IGetOccurrenceRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IGetOccurrenceRequest|undefined, {}|undefined - ]>; - getOccurrence( - request: protos.grafeas.v1.IGetOccurrenceRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IGetOccurrenceRequest|null|undefined, - {}|null|undefined>): void; - getOccurrence( - request: protos.grafeas.v1.IGetOccurrenceRequest, - callback: Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IGetOccurrenceRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets the specified occurrence. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the occurrence in the form of - * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Occurrence]{@link grafeas.v1.Occurrence}. - * 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.getOccurrence(request); - */ - getOccurrence( - request?: protos.grafeas.v1.IGetOccurrenceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IGetOccurrenceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IGetOccurrenceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IGetOccurrenceRequest|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.getOccurrence(request, options, callback); - } - deleteOccurrence( - request?: protos.grafeas.v1.IDeleteOccurrenceRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteOccurrenceRequest|undefined, {}|undefined - ]>; - deleteOccurrence( - request: protos.grafeas.v1.IDeleteOccurrenceRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteOccurrenceRequest|null|undefined, - {}|null|undefined>): void; - deleteOccurrence( - request: protos.grafeas.v1.IDeleteOccurrenceRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteOccurrenceRequest|null|undefined, - {}|null|undefined>): void; -/** - * Deletes the specified occurrence. For example, use this method to delete an - * occurrence when the occurrence is no longer applicable for the given - * resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the occurrence in the form of - * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.deleteOccurrence(request); - */ - deleteOccurrence( - request?: protos.grafeas.v1.IDeleteOccurrenceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteOccurrenceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteOccurrenceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteOccurrenceRequest|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.deleteOccurrence(request, options, callback); - } - createOccurrence( - request?: protos.grafeas.v1.ICreateOccurrenceRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.ICreateOccurrenceRequest|undefined, {}|undefined - ]>; - createOccurrence( - request: protos.grafeas.v1.ICreateOccurrenceRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.ICreateOccurrenceRequest|null|undefined, - {}|null|undefined>): void; - createOccurrence( - request: protos.grafeas.v1.ICreateOccurrenceRequest, - callback: Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.ICreateOccurrenceRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new occurrence. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project in the form of `projects/[PROJECT_ID]`, under which - * the occurrence is to be created. - * @param {grafeas.v1.Occurrence} request.occurrence - * The occurrence to create. - * @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 [Occurrence]{@link grafeas.v1.Occurrence}. - * 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.createOccurrence(request); - */ - createOccurrence( - request?: protos.grafeas.v1.ICreateOccurrenceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.ICreateOccurrenceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.ICreateOccurrenceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.ICreateOccurrenceRequest|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.createOccurrence(request, options, callback); - } - batchCreateOccurrences( - request?: protos.grafeas.v1.IBatchCreateOccurrencesRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1.IBatchCreateOccurrencesRequest|undefined, {}|undefined - ]>; - batchCreateOccurrences( - request: protos.grafeas.v1.IBatchCreateOccurrencesRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1.IBatchCreateOccurrencesRequest|null|undefined, - {}|null|undefined>): void; - batchCreateOccurrences( - request: protos.grafeas.v1.IBatchCreateOccurrencesRequest, - callback: Callback< - protos.grafeas.v1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1.IBatchCreateOccurrencesRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates new occurrences in batch. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project in the form of `projects/[PROJECT_ID]`, under which - * the occurrences are to be created. - * @param {number[]} request.occurrences - * The occurrences to create. Max allowed length is 1000. - * @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 [BatchCreateOccurrencesResponse]{@link grafeas.v1.BatchCreateOccurrencesResponse}. - * 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.batchCreateOccurrences(request); - */ - batchCreateOccurrences( - request?: protos.grafeas.v1.IBatchCreateOccurrencesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1.IBatchCreateOccurrencesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1.IBatchCreateOccurrencesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1.IBatchCreateOccurrencesRequest|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.batchCreateOccurrences(request, options, callback); - } - updateOccurrence( - request?: protos.grafeas.v1.IUpdateOccurrenceRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IUpdateOccurrenceRequest|undefined, {}|undefined - ]>; - updateOccurrence( - request: protos.grafeas.v1.IUpdateOccurrenceRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IUpdateOccurrenceRequest|null|undefined, - {}|null|undefined>): void; - updateOccurrence( - request: protos.grafeas.v1.IUpdateOccurrenceRequest, - callback: Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IUpdateOccurrenceRequest|null|undefined, - {}|null|undefined>): void; -/** - * Updates the specified occurrence. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the occurrence in the form of - * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - * @param {grafeas.v1.Occurrence} request.occurrence - * The updated occurrence. - * @param {google.protobuf.FieldMask} request.updateMask - * The fields to update. - * @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 [Occurrence]{@link grafeas.v1.Occurrence}. - * 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.updateOccurrence(request); - */ - updateOccurrence( - request?: protos.grafeas.v1.IUpdateOccurrenceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IUpdateOccurrenceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IUpdateOccurrenceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1.IOccurrence, - protos.grafeas.v1.IUpdateOccurrenceRequest|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.updateOccurrence(request, options, callback); - } - getOccurrenceNote( - request?: protos.grafeas.v1.IGetOccurrenceNoteRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetOccurrenceNoteRequest|undefined, {}|undefined - ]>; - getOccurrenceNote( - request: protos.grafeas.v1.IGetOccurrenceNoteRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetOccurrenceNoteRequest|null|undefined, - {}|null|undefined>): void; - getOccurrenceNote( - request: protos.grafeas.v1.IGetOccurrenceNoteRequest, - callback: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetOccurrenceNoteRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets the note attached to the specified occurrence. Consumer projects can - * use this method to get a note that belongs to a provider project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the occurrence in the form of - * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Note]{@link grafeas.v1.Note}. - * 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.getOccurrenceNote(request); - */ - getOccurrenceNote( - request?: protos.grafeas.v1.IGetOccurrenceNoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetOccurrenceNoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetOccurrenceNoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetOccurrenceNoteRequest|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.getOccurrenceNote(request, options, callback); - } - getNote( - request?: protos.grafeas.v1.IGetNoteRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetNoteRequest|undefined, {}|undefined - ]>; - getNote( - request: protos.grafeas.v1.IGetNoteRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetNoteRequest|null|undefined, - {}|null|undefined>): void; - getNote( - request: protos.grafeas.v1.IGetNoteRequest, - callback: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetNoteRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets the specified note. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the note in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Note]{@link grafeas.v1.Note}. - * 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.getNote(request); - */ - getNote( - request?: protos.grafeas.v1.IGetNoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetNoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetNoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1.INote, - protos.grafeas.v1.IGetNoteRequest|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.getNote(request, options, callback); - } - deleteNote( - request?: protos.grafeas.v1.IDeleteNoteRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteNoteRequest|undefined, {}|undefined - ]>; - deleteNote( - request: protos.grafeas.v1.IDeleteNoteRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteNoteRequest|null|undefined, - {}|null|undefined>): void; - deleteNote( - request: protos.grafeas.v1.IDeleteNoteRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteNoteRequest|null|undefined, - {}|null|undefined>): void; -/** - * Deletes the specified note. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the note in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.deleteNote(request); - */ - deleteNote( - request?: protos.grafeas.v1.IDeleteNoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteNoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteNoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.grafeas.v1.IDeleteNoteRequest|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.deleteNote(request, options, callback); - } - createNote( - request?: protos.grafeas.v1.ICreateNoteRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.INote, - protos.grafeas.v1.ICreateNoteRequest|undefined, {}|undefined - ]>; - createNote( - request: protos.grafeas.v1.ICreateNoteRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.ICreateNoteRequest|null|undefined, - {}|null|undefined>): void; - createNote( - request: protos.grafeas.v1.ICreateNoteRequest, - callback: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.ICreateNoteRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new note. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project in the form of `projects/[PROJECT_ID]`, under which - * the note is to be created. - * @param {string} request.noteId - * The ID to use for this note. - * @param {grafeas.v1.Note} request.note - * The note to create. - * @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 [Note]{@link grafeas.v1.Note}. - * 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.createNote(request); - */ - createNote( - request?: protos.grafeas.v1.ICreateNoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.ICreateNoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.ICreateNoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1.INote, - protos.grafeas.v1.ICreateNoteRequest|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.createNote(request, options, callback); - } - batchCreateNotes( - request?: protos.grafeas.v1.IBatchCreateNotesRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.IBatchCreateNotesResponse, - protos.grafeas.v1.IBatchCreateNotesRequest|undefined, {}|undefined - ]>; - batchCreateNotes( - request: protos.grafeas.v1.IBatchCreateNotesRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1.IBatchCreateNotesResponse, - protos.grafeas.v1.IBatchCreateNotesRequest|null|undefined, - {}|null|undefined>): void; - batchCreateNotes( - request: protos.grafeas.v1.IBatchCreateNotesRequest, - callback: Callback< - protos.grafeas.v1.IBatchCreateNotesResponse, - protos.grafeas.v1.IBatchCreateNotesRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates new notes in batch. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project in the form of `projects/[PROJECT_ID]`, under which - * the notes are to be created. - * @param {number[]} request.notes - * The notes to create. Max allowed length is 1000. - * @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 [BatchCreateNotesResponse]{@link grafeas.v1.BatchCreateNotesResponse}. - * 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.batchCreateNotes(request); - */ - batchCreateNotes( - request?: protos.grafeas.v1.IBatchCreateNotesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1.IBatchCreateNotesResponse, - protos.grafeas.v1.IBatchCreateNotesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1.IBatchCreateNotesResponse, - protos.grafeas.v1.IBatchCreateNotesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1.IBatchCreateNotesResponse, - protos.grafeas.v1.IBatchCreateNotesRequest|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.batchCreateNotes(request, options, callback); - } - updateNote( - request?: protos.grafeas.v1.IUpdateNoteRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.INote, - protos.grafeas.v1.IUpdateNoteRequest|undefined, {}|undefined - ]>; - updateNote( - request: protos.grafeas.v1.IUpdateNoteRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IUpdateNoteRequest|null|undefined, - {}|null|undefined>): void; - updateNote( - request: protos.grafeas.v1.IUpdateNoteRequest, - callback: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IUpdateNoteRequest|null|undefined, - {}|null|undefined>): void; -/** - * Updates the specified note. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the note in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {grafeas.v1.Note} request.note - * The updated note. - * @param {google.protobuf.FieldMask} request.updateMask - * The fields to update. - * @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 [Note]{@link grafeas.v1.Note}. - * 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.updateNote(request); - */ - updateNote( - request?: protos.grafeas.v1.IUpdateNoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IUpdateNoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1.INote, - protos.grafeas.v1.IUpdateNoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1.INote, - protos.grafeas.v1.IUpdateNoteRequest|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.updateNote(request, options, callback); - } - - listOccurrences( - request?: protos.grafeas.v1.IListOccurrencesRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.IOccurrence[], - protos.grafeas.v1.IListOccurrencesRequest|null, - protos.grafeas.v1.IListOccurrencesResponse - ]>; - listOccurrences( - request: protos.grafeas.v1.IListOccurrencesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.grafeas.v1.IListOccurrencesRequest, - protos.grafeas.v1.IListOccurrencesResponse|null|undefined, - protos.grafeas.v1.IOccurrence>): void; - listOccurrences( - request: protos.grafeas.v1.IListOccurrencesRequest, - callback: PaginationCallback< - protos.grafeas.v1.IListOccurrencesRequest, - protos.grafeas.v1.IListOccurrencesResponse|null|undefined, - protos.grafeas.v1.IOccurrence>): void; -/** - * Lists occurrences for the specified project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project to list occurrences for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. Must be positive. Max allowed - * page size is 1000. If not specified, page size defaults to 20. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Occurrence]{@link grafeas.v1.Occurrence}. - * 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 `listOccurrencesAsync()` - * 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. - */ - listOccurrences( - request?: protos.grafeas.v1.IListOccurrencesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.grafeas.v1.IListOccurrencesRequest, - protos.grafeas.v1.IListOccurrencesResponse|null|undefined, - protos.grafeas.v1.IOccurrence>, - callback?: PaginationCallback< - protos.grafeas.v1.IListOccurrencesRequest, - protos.grafeas.v1.IListOccurrencesResponse|null|undefined, - protos.grafeas.v1.IOccurrence>): - Promise<[ - protos.grafeas.v1.IOccurrence[], - protos.grafeas.v1.IListOccurrencesRequest|null, - protos.grafeas.v1.IListOccurrencesResponse - ]>|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.listOccurrences(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 - * The name of the project to list occurrences for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. Must be positive. Max allowed - * page size is 1000. If not specified, page size defaults to 20. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Occurrence]{@link grafeas.v1.Occurrence} 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 `listOccurrencesAsync()` - * 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. - */ - listOccurrencesStream( - request?: protos.grafeas.v1.IListOccurrencesRequest, - 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.listOccurrences.createStream( - this.innerApiCalls.listOccurrences as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listOccurrences`, 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 - * The name of the project to list occurrences for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. Must be positive. Max allowed - * page size is 1000. If not specified, page size defaults to 20. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 - * [Occurrence]{@link grafeas.v1.Occurrence}. 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.listOccurrencesAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listOccurrencesAsync( - request?: protos.grafeas.v1.IListOccurrencesRequest, - 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.listOccurrences.asyncIterate( - this.innerApiCalls['listOccurrences'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - listNotes( - request?: protos.grafeas.v1.IListNotesRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.INote[], - protos.grafeas.v1.IListNotesRequest|null, - protos.grafeas.v1.IListNotesResponse - ]>; - listNotes( - request: protos.grafeas.v1.IListNotesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.grafeas.v1.IListNotesRequest, - protos.grafeas.v1.IListNotesResponse|null|undefined, - protos.grafeas.v1.INote>): void; - listNotes( - request: protos.grafeas.v1.IListNotesRequest, - callback: PaginationCallback< - protos.grafeas.v1.IListNotesRequest, - protos.grafeas.v1.IListNotesResponse|null|undefined, - protos.grafeas.v1.INote>): void; -/** - * Lists notes for the specified project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project to list notes for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of notes to return in the list. Must be positive. Max allowed page - * size is 1000. If not specified, page size defaults to 20. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Note]{@link grafeas.v1.Note}. - * 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 `listNotesAsync()` - * 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. - */ - listNotes( - request?: protos.grafeas.v1.IListNotesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.grafeas.v1.IListNotesRequest, - protos.grafeas.v1.IListNotesResponse|null|undefined, - protos.grafeas.v1.INote>, - callback?: PaginationCallback< - protos.grafeas.v1.IListNotesRequest, - protos.grafeas.v1.IListNotesResponse|null|undefined, - protos.grafeas.v1.INote>): - Promise<[ - protos.grafeas.v1.INote[], - protos.grafeas.v1.IListNotesRequest|null, - protos.grafeas.v1.IListNotesResponse - ]>|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.listNotes(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 - * The name of the project to list notes for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of notes to return in the list. Must be positive. Max allowed page - * size is 1000. If not specified, page size defaults to 20. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Note]{@link grafeas.v1.Note} 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 `listNotesAsync()` - * 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. - */ - listNotesStream( - request?: protos.grafeas.v1.IListNotesRequest, - 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.listNotes.createStream( - this.innerApiCalls.listNotes as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listNotes`, 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 - * The name of the project to list notes for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of notes to return in the list. Must be positive. Max allowed page - * size is 1000. If not specified, page size defaults to 20. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 - * [Note]{@link grafeas.v1.Note}. 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.listNotesAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listNotesAsync( - request?: protos.grafeas.v1.IListNotesRequest, - 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.listNotes.asyncIterate( - this.innerApiCalls['listNotes'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - listNoteOccurrences( - request?: protos.grafeas.v1.IListNoteOccurrencesRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1.IOccurrence[], - protos.grafeas.v1.IListNoteOccurrencesRequest|null, - protos.grafeas.v1.IListNoteOccurrencesResponse - ]>; - listNoteOccurrences( - request: protos.grafeas.v1.IListNoteOccurrencesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.grafeas.v1.IListNoteOccurrencesRequest, - protos.grafeas.v1.IListNoteOccurrencesResponse|null|undefined, - protos.grafeas.v1.IOccurrence>): void; - listNoteOccurrences( - request: protos.grafeas.v1.IListNoteOccurrencesRequest, - callback: PaginationCallback< - protos.grafeas.v1.IListNoteOccurrencesRequest, - protos.grafeas.v1.IListNoteOccurrencesResponse|null|undefined, - protos.grafeas.v1.IOccurrence>): void; -/** - * Lists occurrences referencing the specified note. Provider projects can use - * this method to get all occurrences across consumer projects referencing the - * specified note. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the note to list occurrences for in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Occurrence]{@link grafeas.v1.Occurrence}. - * 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 `listNoteOccurrencesAsync()` - * 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. - */ - listNoteOccurrences( - request?: protos.grafeas.v1.IListNoteOccurrencesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.grafeas.v1.IListNoteOccurrencesRequest, - protos.grafeas.v1.IListNoteOccurrencesResponse|null|undefined, - protos.grafeas.v1.IOccurrence>, - callback?: PaginationCallback< - protos.grafeas.v1.IListNoteOccurrencesRequest, - protos.grafeas.v1.IListNoteOccurrencesResponse|null|undefined, - protos.grafeas.v1.IOccurrence>): - Promise<[ - protos.grafeas.v1.IOccurrence[], - protos.grafeas.v1.IListNoteOccurrencesRequest|null, - protos.grafeas.v1.IListNoteOccurrencesResponse - ]>|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.listNoteOccurrences(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.name - * The name of the note to list occurrences for in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Occurrence]{@link grafeas.v1.Occurrence} 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 `listNoteOccurrencesAsync()` - * 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. - */ - listNoteOccurrencesStream( - request?: protos.grafeas.v1.IListNoteOccurrencesRequest, - 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({ - 'name': request.name || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listNoteOccurrences.createStream( - this.innerApiCalls.listNoteOccurrences as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listNoteOccurrences`, 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.name - * The name of the note to list occurrences for in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 - * [Occurrence]{@link grafeas.v1.Occurrence}. 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.listNoteOccurrencesAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listNoteOccurrencesAsync( - request?: protos.grafeas.v1.IListNoteOccurrencesRequest, - 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({ - 'name': request.name || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listNoteOccurrences.asyncIterate( - this.innerApiCalls['listNoteOccurrences'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified note resource name string. - * - * @param {string} project - * @param {string} note - * @returns {string} Resource name string. - */ - notePath(project:string,note:string) { - return this.pathTemplates.notePathTemplate.render({ - project: project, - note: note, - }); - } - - /** - * Parse the project from Note resource. - * - * @param {string} noteName - * A fully-qualified path representing Note resource. - * @returns {string} A string representing the project. - */ - matchProjectFromNoteName(noteName: string) { - return this.pathTemplates.notePathTemplate.match(noteName).project; - } - - /** - * Parse the note from Note resource. - * - * @param {string} noteName - * A fully-qualified path representing Note resource. - * @returns {string} A string representing the note. - */ - matchNoteFromNoteName(noteName: string) { - return this.pathTemplates.notePathTemplate.match(noteName).note; - } - - /** - * Return a fully-qualified occurrence resource name string. - * - * @param {string} project - * @param {string} occurrence - * @returns {string} Resource name string. - */ - occurrencePath(project:string,occurrence:string) { - return this.pathTemplates.occurrencePathTemplate.render({ - project: project, - occurrence: occurrence, - }); - } - - /** - * Parse the project from Occurrence resource. - * - * @param {string} occurrenceName - * A fully-qualified path representing Occurrence resource. - * @returns {string} A string representing the project. - */ - matchProjectFromOccurrenceName(occurrenceName: string) { - return this.pathTemplates.occurrencePathTemplate.match(occurrenceName).project; - } - - /** - * Parse the occurrence from Occurrence resource. - * - * @param {string} occurrenceName - * A fully-qualified path representing Occurrence resource. - * @returns {string} A string representing the occurrence. - */ - matchOccurrenceFromOccurrenceName(occurrenceName: string) { - return this.pathTemplates.occurrencePathTemplate.match(occurrenceName).occurrence; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.grafeasStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/grafeas_client_config.json b/owl-bot-staging/v1/src/v1/grafeas_client_config.json deleted file mode 100644 index 5a325a2..0000000 --- a/owl-bot-staging/v1/src/v1/grafeas_client_config.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "interfaces": { - "google.devtools.containeranalysis.v1.Grafeas": { - "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": { - "GetOccurrence": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListOccurrences": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteOccurrence": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateOccurrence": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "BatchCreateOccurrences": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateOccurrence": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetOccurrenceNote": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetNote": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListNotes": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteNote": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateNote": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "BatchCreateNotes": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateNote": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListNoteOccurrences": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/grafeas_proto_list.json b/owl-bot-staging/v1/src/v1/grafeas_proto_list.json deleted file mode 100644 index e44e771..0000000 --- a/owl-bot-staging/v1/src/v1/grafeas_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/devtools/containeranalysis/v1/containeranalysis.proto", - "../../protos/grafeas/v1/attestation.proto", - "../../protos/grafeas/v1/build.proto", - "../../protos/grafeas/v1/common.proto", - "../../protos/grafeas/v1/cvss.proto", - "../../protos/grafeas/v1/deployment.proto", - "../../protos/grafeas/v1/discovery.proto", - "../../protos/grafeas/v1/grafeas.proto", - "../../protos/grafeas/v1/image.proto", - "../../protos/grafeas/v1/package.proto", - "../../protos/grafeas/v1/provenance.proto", - "../../protos/grafeas/v1/upgrade.proto", - "../../protos/grafeas/v1/vulnerability.proto" -] diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 953e590..0000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {ContainerAnalysisClient} from './container_analysis_client'; -export {GrafeasClient} from './grafeas_client'; diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 088e6bd..0000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const containeranalysis = require('@google-cloud/containeranalysis'); - -function main() { - const containerAnalysisClient = new containeranalysis.ContainerAnalysisClient(); - const grafeasClient = new containeranalysis.GrafeasClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4e31b0b..0000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {ContainerAnalysisClient, GrafeasClient} from '@google-cloud/containeranalysis'; - -// check that the client class type name can be used -function doStuffWithContainerAnalysisClient(client: ContainerAnalysisClient) { - client.close(); -} -function doStuffWithGrafeasClient(client: GrafeasClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const containerAnalysisClient = new ContainerAnalysisClient(); - doStuffWithContainerAnalysisClient(containerAnalysisClient); - // check that the client instance can be created - const grafeasClient = new GrafeasClient(); - doStuffWithGrafeasClient(grafeasClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 1f850b5..0000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1/test/gapic_container_analysis_v1.ts b/owl-bot-staging/v1/test/gapic_container_analysis_v1.ts deleted file mode 100644 index 95fcda9..0000000 --- a/owl-bot-staging/v1/test/gapic_container_analysis_v1.ts +++ /dev/null @@ -1,565 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as containeranalysisModule from '../src'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1.ContainerAnalysisClient', () => { - it('has servicePath', () => { - const servicePath = containeranalysisModule.v1.ContainerAnalysisClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = containeranalysisModule.v1.ContainerAnalysisClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = containeranalysisModule.v1.ContainerAnalysisClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.containerAnalysisStub, undefined); - await client.initialize(); - assert(client.containerAnalysisStub); - }); - - it('has close method', () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - 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 containeranalysisModule.v1.ContainerAnalysisClient({ - 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('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getVulnerabilityOccurrencesSummary', () => { - it('invokes getVulnerabilityOccurrencesSummary without error', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary()); - client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCall(expectedResponse); - const [response] = await client.getVulnerabilityOccurrencesSummary(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getVulnerabilityOccurrencesSummary without error using callback', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary()); - client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getVulnerabilityOccurrencesSummary( - request, - (err?: Error|null, result?: protos.google.devtools.containeranalysis.v1.IVulnerabilityOccurrencesSummary|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getVulnerabilityOccurrencesSummary with error', async () => { - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getVulnerabilityOccurrencesSummary(request), expectedError); - assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('Path templates', () => { - - describe('note', () => { - const fakePath = "/rendered/path/note"; - const expectedParameters = { - project: "projectValue", - note: "noteValue", - }; - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.notePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.notePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('notePath', () => { - const result = client.notePath("projectValue", "noteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.notePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNoteName', () => { - const result = client.matchProjectFromNoteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.notePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNoteFromNoteName', () => { - const result = client.matchNoteFromNoteName(fakePath); - assert.strictEqual(result, "noteValue"); - assert((client.pathTemplates.notePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('occurrence', () => { - const fakePath = "/rendered/path/occurrence"; - const expectedParameters = { - project: "projectValue", - occurrence: "occurrenceValue", - }; - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.occurrencePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.occurrencePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('occurrencePath', () => { - const result = client.occurrencePath("projectValue", "occurrenceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.occurrencePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromOccurrenceName', () => { - const result = client.matchProjectFromOccurrenceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.occurrencePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchOccurrenceFromOccurrenceName', () => { - const result = client.matchOccurrenceFromOccurrenceName(fakePath); - assert.strictEqual(result, "occurrenceValue"); - assert((client.pathTemplates.occurrencePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new containeranalysisModule.v1.ContainerAnalysisClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/test/gapic_grafeas_v1.ts b/owl-bot-staging/v1/test/gapic_grafeas_v1.ts deleted file mode 100644 index 4aaaef1..0000000 --- a/owl-bot-staging/v1/test/gapic_grafeas_v1.ts +++ /dev/null @@ -1,1866 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as grafeasModule 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.GrafeasClient', () => { - it('has servicePath', () => { - const servicePath = grafeasModule.v1.GrafeasClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = grafeasModule.v1.GrafeasClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = grafeasModule.v1.GrafeasClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new grafeasModule.v1.GrafeasClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new grafeasModule.v1.GrafeasClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.grafeasStub, undefined); - await client.initialize(); - assert(client.grafeasStub); - }); - - it('has close method', () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new grafeasModule.v1.GrafeasClient({ - 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 grafeasModule.v1.GrafeasClient({ - 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('getOccurrence', () => { - it('invokes getOccurrence without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); - client.innerApiCalls.getOccurrence = stubSimpleCall(expectedResponse); - const [response] = await client.getOccurrence(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getOccurrence without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); - client.innerApiCalls.getOccurrence = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOccurrence( - request, - (err?: Error|null, result?: protos.grafeas.v1.IOccurrence|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getOccurrence with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getOccurrence = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOccurrence(request), expectedError); - assert((client.innerApiCalls.getOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('deleteOccurrence', () => { - it('invokes deleteOccurrence without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.DeleteOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteOccurrence = stubSimpleCall(expectedResponse); - const [response] = await client.deleteOccurrence(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteOccurrence without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.DeleteOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteOccurrence = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteOccurrence( - 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.deleteOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteOccurrence with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.DeleteOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteOccurrence = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteOccurrence(request), expectedError); - assert((client.innerApiCalls.deleteOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('createOccurrence', () => { - it('invokes createOccurrence without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.CreateOccurrenceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); - client.innerApiCalls.createOccurrence = stubSimpleCall(expectedResponse); - const [response] = await client.createOccurrence(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createOccurrence without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.CreateOccurrenceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); - client.innerApiCalls.createOccurrence = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createOccurrence( - request, - (err?: Error|null, result?: protos.grafeas.v1.IOccurrence|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createOccurrence with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.CreateOccurrenceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createOccurrence = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createOccurrence(request), expectedError); - assert((client.innerApiCalls.createOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('batchCreateOccurrences', () => { - it('invokes batchCreateOccurrences without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.BatchCreateOccurrencesResponse()); - client.innerApiCalls.batchCreateOccurrences = stubSimpleCall(expectedResponse); - const [response] = await client.batchCreateOccurrences(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchCreateOccurrences without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.BatchCreateOccurrencesResponse()); - client.innerApiCalls.batchCreateOccurrences = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchCreateOccurrences( - request, - (err?: Error|null, result?: protos.grafeas.v1.IBatchCreateOccurrencesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchCreateOccurrences with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchCreateOccurrences = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchCreateOccurrences(request), expectedError); - assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('updateOccurrence', () => { - it('invokes updateOccurrence without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.UpdateOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); - client.innerApiCalls.updateOccurrence = stubSimpleCall(expectedResponse); - const [response] = await client.updateOccurrence(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateOccurrence without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.UpdateOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Occurrence()); - client.innerApiCalls.updateOccurrence = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateOccurrence( - request, - (err?: Error|null, result?: protos.grafeas.v1.IOccurrence|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateOccurrence with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.UpdateOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateOccurrence = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateOccurrence(request), expectedError); - assert((client.innerApiCalls.updateOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getOccurrenceNote', () => { - it('invokes getOccurrenceNote without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); - client.innerApiCalls.getOccurrenceNote = stubSimpleCall(expectedResponse); - const [response] = await client.getOccurrenceNote(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getOccurrenceNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getOccurrenceNote without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); - client.innerApiCalls.getOccurrenceNote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOccurrenceNote( - request, - (err?: Error|null, result?: protos.grafeas.v1.INote|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getOccurrenceNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getOccurrenceNote with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.GetOccurrenceNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getOccurrenceNote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOccurrenceNote(request), expectedError); - assert((client.innerApiCalls.getOccurrenceNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getNote', () => { - it('invokes getNote without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.GetNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); - client.innerApiCalls.getNote = stubSimpleCall(expectedResponse); - const [response] = await client.getNote(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getNote without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.GetNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); - client.innerApiCalls.getNote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getNote( - request, - (err?: Error|null, result?: protos.grafeas.v1.INote|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getNote with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.GetNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getNote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getNote(request), expectedError); - assert((client.innerApiCalls.getNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('deleteNote', () => { - it('invokes deleteNote without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.DeleteNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteNote = stubSimpleCall(expectedResponse); - const [response] = await client.deleteNote(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteNote without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.DeleteNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteNote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteNote( - 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.deleteNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteNote with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.DeleteNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteNote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteNote(request), expectedError); - assert((client.innerApiCalls.deleteNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('createNote', () => { - it('invokes createNote without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.CreateNoteRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); - client.innerApiCalls.createNote = stubSimpleCall(expectedResponse); - const [response] = await client.createNote(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createNote without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.CreateNoteRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); - client.innerApiCalls.createNote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createNote( - request, - (err?: Error|null, result?: protos.grafeas.v1.INote|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createNote with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.CreateNoteRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createNote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createNote(request), expectedError); - assert((client.innerApiCalls.createNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('batchCreateNotes', () => { - it('invokes batchCreateNotes without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.BatchCreateNotesResponse()); - client.innerApiCalls.batchCreateNotes = stubSimpleCall(expectedResponse); - const [response] = await client.batchCreateNotes(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchCreateNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchCreateNotes without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.BatchCreateNotesResponse()); - client.innerApiCalls.batchCreateNotes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchCreateNotes( - request, - (err?: Error|null, result?: protos.grafeas.v1.IBatchCreateNotesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchCreateNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchCreateNotes with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.BatchCreateNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchCreateNotes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchCreateNotes(request), expectedError); - assert((client.innerApiCalls.batchCreateNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('updateNote', () => { - it('invokes updateNote without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.UpdateNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); - client.innerApiCalls.updateNote = stubSimpleCall(expectedResponse); - const [response] = await client.updateNote(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateNote without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.UpdateNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1.Note()); - client.innerApiCalls.updateNote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateNote( - request, - (err?: Error|null, result?: protos.grafeas.v1.INote|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateNote with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.UpdateNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateNote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateNote(request), expectedError); - assert((client.innerApiCalls.updateNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('listOccurrences', () => { - it('invokes listOccurrences without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - ]; - client.innerApiCalls.listOccurrences = stubSimpleCall(expectedResponse); - const [response] = await client.listOccurrences(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listOccurrences without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - ]; - client.innerApiCalls.listOccurrences = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOccurrences( - request, - (err?: Error|null, result?: protos.grafeas.v1.IOccurrence[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listOccurrences with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listOccurrences = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOccurrences(request), expectedError); - assert((client.innerApiCalls.listOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listOccurrencesStream without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - ]; - client.descriptors.page.listOccurrences.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOccurrencesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1.Occurrence[] = []; - stream.on('data', (response: protos.grafeas.v1.Occurrence) => { - 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.listOccurrences.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOccurrences, request)); - assert.strictEqual( - (client.descriptors.page.listOccurrences.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listOccurrencesStream with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listOccurrences.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOccurrencesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1.Occurrence[] = []; - stream.on('data', (response: protos.grafeas.v1.Occurrence) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOccurrences.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOccurrences, request)); - assert.strictEqual( - (client.descriptors.page.listOccurrences.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listOccurrences without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - ]; - client.descriptors.page.listOccurrences.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.grafeas.v1.IOccurrence[] = []; - const iterable = client.listOccurrencesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listOccurrences with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listOccurrences.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOccurrencesAsync(request); - await assert.rejects(async () => { - const responses: protos.grafeas.v1.IOccurrence[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listNotes', () => { - it('invokes listNotes without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Note()), - generateSampleMessage(new protos.grafeas.v1.Note()), - generateSampleMessage(new protos.grafeas.v1.Note()), - ]; - client.innerApiCalls.listNotes = stubSimpleCall(expectedResponse); - const [response] = await client.listNotes(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listNotes without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Note()), - generateSampleMessage(new protos.grafeas.v1.Note()), - generateSampleMessage(new protos.grafeas.v1.Note()), - ]; - client.innerApiCalls.listNotes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listNotes( - request, - (err?: Error|null, result?: protos.grafeas.v1.INote[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listNotes with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listNotes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listNotes(request), expectedError); - assert((client.innerApiCalls.listNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listNotesStream without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Note()), - generateSampleMessage(new protos.grafeas.v1.Note()), - generateSampleMessage(new protos.grafeas.v1.Note()), - ]; - client.descriptors.page.listNotes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listNotesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1.Note[] = []; - stream.on('data', (response: protos.grafeas.v1.Note) => { - 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.listNotes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNotes, request)); - assert.strictEqual( - (client.descriptors.page.listNotes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listNotesStream with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listNotes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listNotesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1.Note[] = []; - stream.on('data', (response: protos.grafeas.v1.Note) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listNotes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNotes, request)); - assert.strictEqual( - (client.descriptors.page.listNotes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listNotes without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Note()), - generateSampleMessage(new protos.grafeas.v1.Note()), - generateSampleMessage(new protos.grafeas.v1.Note()), - ]; - client.descriptors.page.listNotes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.grafeas.v1.INote[] = []; - const iterable = client.listNotesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listNotes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listNotes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listNotes with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listNotes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listNotesAsync(request); - await assert.rejects(async () => { - const responses: protos.grafeas.v1.INote[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listNotes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listNotes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listNoteOccurrences', () => { - it('invokes listNoteOccurrences without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - ]; - client.innerApiCalls.listNoteOccurrences = stubSimpleCall(expectedResponse); - const [response] = await client.listNoteOccurrences(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listNoteOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listNoteOccurrences without error using callback', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - ]; - client.innerApiCalls.listNoteOccurrences = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listNoteOccurrences( - request, - (err?: Error|null, result?: protos.grafeas.v1.IOccurrence[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listNoteOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listNoteOccurrences with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listNoteOccurrences = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listNoteOccurrences(request), expectedError); - assert((client.innerApiCalls.listNoteOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listNoteOccurrencesStream without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - ]; - client.descriptors.page.listNoteOccurrences.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listNoteOccurrencesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1.Occurrence[] = []; - stream.on('data', (response: protos.grafeas.v1.Occurrence) => { - 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.listNoteOccurrences.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNoteOccurrences, request)); - assert.strictEqual( - (client.descriptors.page.listNoteOccurrences.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listNoteOccurrencesStream with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedError = new Error('expected'); - client.descriptors.page.listNoteOccurrences.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listNoteOccurrencesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1.Occurrence[] = []; - stream.on('data', (response: protos.grafeas.v1.Occurrence) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listNoteOccurrences.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNoteOccurrences, request)); - assert.strictEqual( - (client.descriptors.page.listNoteOccurrences.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listNoteOccurrences without error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name=";const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1.Occurrence()), - ]; - client.descriptors.page.listNoteOccurrences.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.grafeas.v1.IOccurrence[] = []; - const iterable = client.listNoteOccurrencesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listNoteOccurrences with error', async () => { - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); - client.descriptors.page.listNoteOccurrences.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listNoteOccurrencesAsync(request); - await assert.rejects(async () => { - const responses: protos.grafeas.v1.IOccurrence[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('note', () => { - const fakePath = "/rendered/path/note"; - const expectedParameters = { - project: "projectValue", - note: "noteValue", - }; - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.notePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.notePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('notePath', () => { - const result = client.notePath("projectValue", "noteValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.notePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNoteName', () => { - const result = client.matchProjectFromNoteName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.notePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNoteFromNoteName', () => { - const result = client.matchNoteFromNoteName(fakePath); - assert.strictEqual(result, "noteValue"); - assert((client.pathTemplates.notePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('occurrence', () => { - const fakePath = "/rendered/path/occurrence"; - const expectedParameters = { - project: "projectValue", - occurrence: "occurrenceValue", - }; - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.occurrencePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.occurrencePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('occurrencePath', () => { - const result = client.occurrencePath("projectValue", "occurrenceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.occurrencePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromOccurrenceName', () => { - const result = client.matchProjectFromOccurrenceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.occurrencePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchOccurrenceFromOccurrenceName', () => { - const result = client.matchOccurrenceFromOccurrenceName(fakePath); - assert.strictEqual(result, "occurrenceValue"); - assert((client.pathTemplates.occurrencePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new grafeasModule.v1.GrafeasClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c8..0000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index f9beacf..0000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'containeranalysis', - filename: './containeranalysis.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v1beta1/.eslintignore b/owl-bot-staging/v1beta1/.eslintignore deleted file mode 100644 index 521dc25..0000000 --- a/owl-bot-staging/v1beta1/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ diff --git a/owl-bot-staging/v1beta1/.eslintrc.json b/owl-bot-staging/v1beta1/.eslintrc.json deleted file mode 100644 index 7821534..0000000 --- a/owl-bot-staging/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1beta1/.gitignore b/owl-bot-staging/v1beta1/.gitignore deleted file mode 100644 index 5d32b23..0000000 --- a/owl-bot-staging/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1beta1/.jsdoc.js b/owl-bot-staging/v1beta1/.jsdoc.js deleted file mode 100644 index cb937ac..0000000 --- a/owl-bot-staging/v1beta1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2021 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/containeranalysis', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1beta1/.mocharc.js b/owl-bot-staging/v1beta1/.mocharc.js deleted file mode 100644 index 50bc7f7..0000000 --- a/owl-bot-staging/v1beta1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1beta1/.prettierrc.js b/owl-bot-staging/v1beta1/.prettierrc.js deleted file mode 100644 index 84f4713..0000000 --- a/owl-bot-staging/v1beta1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1beta1/README.md b/owl-bot-staging/v1beta1/README.md deleted file mode 100644 index dc843b7..0000000 --- a/owl-bot-staging/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Containeranalysis: Nodejs Client diff --git a/owl-bot-staging/v1beta1/linkinator.config.json b/owl-bot-staging/v1beta1/linkinator.config.json deleted file mode 100644 index 29a223b..0000000 --- a/owl-bot-staging/v1beta1/linkinator.config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io" - ], - "silent": true, - "concurrency": 10 -} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json deleted file mode 100644 index ecba9da..0000000 --- a/owl-bot-staging/v1beta1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/containeranalysis", - "version": "0.1.0", - "description": "Containeranalysis client for Node.js", - "repository": "googleapis/nodejs-containeranalysis", - "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 containeranalysis", - "containeranalysis", - "container analysis v1 beta1", - "grafeas v1 beta1" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.15.0" - }, - "devDependencies": { - "@types/mocha": "^8.2.2", - "@types/node": "^14.17.3", - "@types/sinon": "^10.0.2", - "c8": "^7.7.3", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.0", - "jsdoc-region-tag": "^1.1.0", - "linkinator": "^2.13.6", - "mocha": "^8.4.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^11.1.1", - "ts-loader": "^9.2.3", - "typescript": "^4.3.4", - "webpack": "^5.39.1", - "webpack-cli": "^4.7.2" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto deleted file mode 100644 index 0d3d6c9..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.attestation; - -import "google/devtools/containeranalysis/v1beta1/common/common.proto"; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/attestation;attestation"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1.attestation"; -option objc_class_prefix = "GRA"; - -// An attestation wrapper with a PGP-compatible signature. This message only -// supports `ATTACHED` signatures, where the payload that is signed is included -// alongside the signature itself in the same file. -message PgpSignedAttestation { - // Required. The raw content of the signature, as output by GNU Privacy Guard - // (GPG) or equivalent. Since this message only supports attached signatures, - // the payload that was signed must be attached. While the signature format - // supported is dependent on the verification implementation, currently only - // ASCII-armored (`--armor` to gpg), non-clearsigned (`--sign` rather than - // `--clearsign` to gpg) are supported. Concretely, `gpg --sign --armor - // --output=signature.gpg payload.json` will create the signature content - // expected in this field in `signature.gpg` for the `payload.json` - // attestation payload. - string signature = 1; - - // Type (for example schema) of the attestation payload that was signed. - enum ContentType { - // `ContentType` is not set. - CONTENT_TYPE_UNSPECIFIED = 0; - // Atomic format attestation signature. See - // https://github.com/containers/image/blob/8a5d2f82a6e3263290c8e0276c3e0f64e77723e7/docs/atomic-signature.md - // The payload extracted from `signature` is a JSON blob conforming to the - // linked schema. - SIMPLE_SIGNING_JSON = 1; - } - - // Type (for example schema) of the attestation payload that was signed. - // The verifier must ensure that the provided type is one that the verifier - // supports, and that the attestation payload is a valid instantiation of that - // type (for example by validating a JSON schema). - ContentType content_type = 3; - - // This field is used by verifiers to select the public key used to validate - // the signature. Note that the policy of the verifier ultimately determines - // which public keys verify a signature based on the context of the - // verification. There is no guarantee validation will succeed if the - // verifier has no key matching this ID, even if it has a key under a - // different ID that would verify the signature. Note that this ID should also - // be present in the signature content above, but that is not expected to be - // used by the verifier. - oneof key_id { - // The cryptographic fingerprint of the key used to generate the signature, - // as output by, e.g. `gpg --list-keys`. This should be the version 4, full - // 160-bit fingerprint, expressed as a 40 character hexidecimal string. See - // https://tools.ietf.org/html/rfc4880#section-12.2 for details. - // Implementations may choose to acknowledge "LONG", "SHORT", or other - // abbreviated key IDs, but only the full fingerprint is guaranteed to work. - // In gpg, the full fingerprint can be retrieved from the `fpr` field - // returned when calling --list-keys with --with-colons. For example: - // ``` - // gpg --with-colons --with-fingerprint --force-v4-certs \ - // --list-keys attester@example.com - // tru::1:1513631572:0:3:1:5 - // pub:...... - // fpr:::::::::24FF6481B76AC91E66A00AC657A93A81EF3AE6FB: - // ``` - // Above, the fingerprint is `24FF6481B76AC91E66A00AC657A93A81EF3AE6FB`. - string pgp_key_id = 2; - } -} - -// An attestation wrapper that uses the Grafeas `Signature` message. -// This attestation must define the `serialized_payload` that the `signatures` -// verify and any metadata necessary to interpret that plaintext. The -// signatures should always be over the `serialized_payload` bytestring. -message GenericSignedAttestation { - // Type of the attestation plaintext that was signed. - enum ContentType { - // `ContentType` is not set. - CONTENT_TYPE_UNSPECIFIED = 0; - // Atomic format attestation signature. See - // https://github.com/containers/image/blob/8a5d2f82a6e3263290c8e0276c3e0f64e77723e7/docs/atomic-signature.md - // The payload extracted in `plaintext` is a JSON blob conforming to the - // linked schema. - SIMPLE_SIGNING_JSON = 1; - } - - // Type (for example schema) of the attestation payload that was signed. - // The verifier must ensure that the provided type is one that the verifier - // supports, and that the attestation payload is a valid instantiation of that - // type (for example by validating a JSON schema). - ContentType content_type = 1; - - // The serialized payload that is verified by one or more `signatures`. - // The encoding and semantic meaning of this payload must match what is set in - // `content_type`. - bytes serialized_payload = 2; - - // One or more signatures over `serialized_payload`. Verifier implementations - // should consider this attestation message verified if at least one - // `signature` verifies `serialized_payload`. See `Signature` in common.proto - // for more details on signature structure and verification. - repeated Signature signatures = 3; -} - -// Note kind that represents a logical attestation "role" or "authority". For -// example, an organization might have one `Authority` for "QA" and one for -// "build". This note is intended to act strictly as a grouping mechanism for -// the attached occurrences (Attestations). This grouping mechanism also -// provides a security boundary, since IAM ACLs gate the ability for a principle -// to attach an occurrence to a given note. It also provides a single point of -// lookup to find all attached attestation occurrences, even if they don't all -// live in the same project. -message Authority { - // This submessage provides human-readable hints about the purpose of the - // authority. Because the name of a note acts as its resource reference, it is - // important to disambiguate the canonical name of the Note (which might be a - // UUID for security purposes) from "readable" names more suitable for debug - // output. Note that these hints should not be used to look up authorities in - // security sensitive contexts, such as when looking up attestations to - // verify. - message Hint { - // Required. The human readable name of this attestation authority, for - // example "qa". - string human_readable_name = 1; - } - - // Hint hints at the purpose of the attestation authority. - Hint hint = 1; -} - -// Details of an attestation occurrence. -message Details { - // Required. Attestation for the resource. - Attestation attestation = 1; -} - -// Occurrence that represents a single "attestation". The authenticity of an -// attestation can be verified using the attached signature. If the verifier -// trusts the public key of the signer, then verifying the signature is -// sufficient to establish trust. In this circumstance, the authority to which -// this attestation is attached is primarily useful for look-up (how to find -// this attestation if you already know the authority and artifact to be -// verified) and intent (which authority was this attestation intended to sign -// for). -message Attestation { - // Required. The signature, generally over the `resource_url`, that verifies - // this attestation. The semantics of the signature veracity are ultimately - // determined by the verification engine. - oneof signature { - // A PGP signed attestation. - PgpSignedAttestation pgp_signed_attestation = 1; - GenericSignedAttestation generic_signed_attestation = 2; - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/common/common.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/common/common.proto deleted file mode 100644 index bb97a31..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/common/common.proto +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/common;common"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1.common"; -option objc_class_prefix = "GRA"; - -// Kind represents the kinds of notes supported. -enum NoteKind { - // Unknown. - NOTE_KIND_UNSPECIFIED = 0; - // The note and occurrence represent a package vulnerability. - VULNERABILITY = 1; - // The note and occurrence assert build provenance. - BUILD = 2; - // This represents an image basis relationship. - IMAGE = 3; - // This represents a package installed via a package manager. - PACKAGE = 4; - // The note and occurrence track deployment events. - DEPLOYMENT = 5; - // The note and occurrence track the initial discovery status of a resource. - DISCOVERY = 6; - // This represents a logical "role" that can attest to artifacts. - ATTESTATION = 7; -} - -// Metadata for any related URL information. -message RelatedUrl { - // Specific URL associated with the resource. - string url = 1; - // Label to describe usage of the URL. - string label = 2; -} - -// Verifiers (e.g. Kritis implementations) MUST verify signatures -// with respect to the trust anchors defined in policy (e.g. a Kritis policy). -// Typically this means that the verifier has been configured with a map from -// `public_key_id` to public key material (and any required parameters, e.g. -// signing algorithm). -// -// In particular, verification implementations MUST NOT treat the signature -// `public_key_id` as anything more than a key lookup hint. The `public_key_id` -// DOES NOT validate or authenticate a public key; it only provides a mechanism -// for quickly selecting a public key ALREADY CONFIGURED on the verifier through -// a trusted channel. Verification implementations MUST reject signatures in any -// of the following circumstances: -// * The `public_key_id` is not recognized by the verifier. -// * The public key that `public_key_id` refers to does not verify the -// signature with respect to the payload. -// -// The `signature` contents SHOULD NOT be "attached" (where the payload is -// included with the serialized `signature` bytes). Verifiers MUST ignore any -// "attached" payload and only verify signatures with respect to explicitly -// provided payload (e.g. a `payload` field on the proto message that holds -// this Signature, or the canonical serialization of the proto message that -// holds this signature). -message Signature { - // The content of the signature, an opaque bytestring. - // The payload that this signature verifies MUST be unambiguously provided - // with the Signature during verification. A wrapper message might provide - // the payload explicitly. Alternatively, a message might have a canonical - // serialization that can always be unambiguously computed to derive the - // payload. - bytes signature = 1; - - // The identifier for the public key that verifies this signature. - // * The `public_key_id` is required. - // * The `public_key_id` MUST be an RFC3986 conformant URI. - // * When possible, the `public_key_id` SHOULD be an immutable reference, - // such as a cryptographic digest. - // - // Examples of valid `public_key_id`s: - // - // OpenPGP V4 public key fingerprint: - // * "openpgp4fpr:74FAF3B861BDA0870C7B6DEF607E48D2A663AEEA" - // See https://www.iana.org/assignments/uri-schemes/prov/openpgp4fpr for more - // details on this scheme. - // - // RFC6920 digest-named SubjectPublicKeyInfo (digest of the DER - // serialization): - // * "ni:///sha-256;cD9o9Cq6LG3jD0iKXqEi_vdjJGecm_iXkbqVoScViaU" - // * "nih:///sha-256;703f68f42aba2c6de30f488a5ea122fef76324679c9bf89791ba95a1271589a5" - string public_key_id = 2; -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto deleted file mode 100644 index 59f3ecd..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright 2019 Google LLC. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.devtools.containeranalysis.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1;containeranalysis"; -option java_multiple_files = true; -option java_package = "com.google.containeranalysis.v1beta1"; -option objc_class_prefix = "GCA"; - -// Retrieves analysis results of Cloud components such as Docker container -// images. The Container Analysis API is an implementation of the -// [Grafeas](grafeas.io) API. -// -// Analysis results are stored as a series of occurrences. An `Occurrence` -// contains information about a specific analysis instance on a resource. An -// occurrence refers to a `Note`. A note contains details describing the -// analysis and is generally stored in a separate project, called a `Provider`. -// Multiple occurrences can refer to the same note. -// -// For example, an SSL vulnerability could affect multiple images. In this case, -// there would be one note for the vulnerability and an occurrence for each -// image with the vulnerability referring to that note. -service ContainerAnalysisV1Beta1 { - option (google.api.default_host) = "containeranalysis.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Sets the access control policy on the specified note or occurrence. - // Requires `containeranalysis.notes.setIamPolicy` or - // `containeranalysis.occurrences.setIamPolicy` permission if the resource is - // a note or an occurrence, respectively. - // - // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - // occurrences. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1beta1/{resource=projects/*/notes/*}:setIamPolicy" - body: "*" - additional_bindings { - post: "/v1beta1/{resource=projects/*/occurrences/*}:setIamPolicy" - body: "*" - } - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Gets the access control policy for a note or an occurrence resource. - // Requires `containeranalysis.notes.setIamPolicy` or - // `containeranalysis.occurrences.setIamPolicy` permission if the resource is - // a note or occurrence, respectively. - // - // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - // occurrences. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1beta1/{resource=projects/*/notes/*}:getIamPolicy" - body: "*" - additional_bindings { - post: "/v1beta1/{resource=projects/*/occurrences/*}:getIamPolicy" - body: "*" - } - }; - option (google.api.method_signature) = "resource"; - } - - // Returns the permissions that a caller has on the specified note or - // occurrence. Requires list permission on the project (for example, - // `containeranalysis.notes.list`). - // - // The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - // notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - // occurrences. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v1beta1/{resource=projects/*/notes/*}:testIamPermissions" - body: "*" - additional_bindings { - post: "/v1beta1/{resource=projects/*/occurrences/*}:testIamPermissions" - body: "*" - } - }; - option (google.api.method_signature) = "resource,permissions"; - } - - // Gets the specified scan configuration. - rpc GetScanConfig(GetScanConfigRequest) returns (ScanConfig) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/scanConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists scan configurations for the specified project. - rpc ListScanConfigs(ListScanConfigsRequest) returns (ListScanConfigsResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*}/scanConfigs" - }; - option (google.api.method_signature) = "parent,filter"; - } - - // Updates the specified scan configuration. - rpc UpdateScanConfig(UpdateScanConfigRequest) returns (ScanConfig) { - option (google.api.http) = { - put: "/v1beta1/{name=projects/*/scanConfigs/*}" - body: "scan_config" - }; - option (google.api.method_signature) = "name,scan_config"; - } -} - -// A scan configuration specifies whether Cloud components in a project have a -// particular type of analysis being run. For example, it can configure whether -// vulnerability scanning is being done on Docker images or not. -message ScanConfig { - option (google.api.resource) = { - type: "containeranalysis.googleapis.com/ScanConfig" - pattern: "projects/{project}/scanConfigs/{scan_config}" - }; - - // Output only. The name of the scan configuration in the form of - // `projects/[PROJECT_ID]/scanConfigs/[SCAN_CONFIG_ID]`. - string name = 1; - - // Output only. A human-readable description of what the scan configuration - // does. - string description = 2; - - // Whether the scan is enabled. - bool enabled = 3; - - // Output only. The time this scan config was created. - google.protobuf.Timestamp create_time = 4; - - // Output only. The time this scan config was last updated. - google.protobuf.Timestamp update_time = 5; -} - -// Request to get a scan configuration. -message GetScanConfigRequest { - // Required. The name of the scan configuration in the form of - // `projects/[PROJECT_ID]/scanConfigs/[SCAN_CONFIG_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "containeranalysis.googleapis.com/ScanConfig" - } - ]; -} - -// Request to list scan configurations. -message ListScanConfigsRequest { - // Required. The name of the project to list scan configurations for in the form of - // `projects/[PROJECT_ID]`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The filter expression. - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // The number of scan configs to return in the list. - int32 page_size = 3; - - // Token to provide to skip to a particular spot in the list. - string page_token = 4; -} - -// Response for listing scan configurations. -message ListScanConfigsResponse { - // The scan configurations requested. - repeated ScanConfig scan_configs = 1; - - // The next pagination token in the list response. It should be used as - // `page_token` for the following request. An empty value means no more - // results. - string next_page_token = 2; -} - -// A request to update a scan configuration. -message UpdateScanConfigRequest { - // Required. The name of the scan configuration in the form of - // `projects/[PROJECT_ID]/scanConfigs/[SCAN_CONFIG_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "containeranalysis.googleapis.com/ScanConfig" - } - ]; - - // Required. The updated scan configuration. - ScanConfig scan_config = 2 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto deleted file mode 100644 index 3484441..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.vulnerability; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/cvss;cvss"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1.vulnerability"; -option objc_class_prefix = "GRA"; - -// Common Vulnerability Scoring System version 3. -// For details, see https://www.first.org/cvss/specification-document -message CVSSv3 { - // The base score is a function of the base metric scores. - float base_score = 1; - - float exploitability_score = 2; - - float impact_score = 3; - - // Base Metrics - // Represents the intrinsic characteristics of a vulnerability that are - // constant over time and across user environments. - AttackVector attack_vector = 5; - AttackComplexity attack_complexity = 6; - PrivilegesRequired privileges_required = 7; - UserInteraction user_interaction = 8; - Scope scope = 9; - Impact confidentiality_impact = 10; - Impact integrity_impact = 11; - Impact availability_impact = 12; - - enum AttackVector { - ATTACK_VECTOR_UNSPECIFIED = 0; - ATTACK_VECTOR_NETWORK = 1; - ATTACK_VECTOR_ADJACENT = 2; - ATTACK_VECTOR_LOCAL = 3; - ATTACK_VECTOR_PHYSICAL = 4; - } - - enum AttackComplexity { - ATTACK_COMPLEXITY_UNSPECIFIED = 0; - ATTACK_COMPLEXITY_LOW = 1; - ATTACK_COMPLEXITY_HIGH = 2; - } - - enum PrivilegesRequired { - PRIVILEGES_REQUIRED_UNSPECIFIED = 0; - PRIVILEGES_REQUIRED_NONE = 1; - PRIVILEGES_REQUIRED_LOW = 2; - PRIVILEGES_REQUIRED_HIGH = 3; - } - - enum UserInteraction { - USER_INTERACTION_UNSPECIFIED = 0; - USER_INTERACTION_NONE = 1; - USER_INTERACTION_REQUIRED = 2; - } - - enum Scope { - SCOPE_UNSPECIFIED = 0; - SCOPE_UNCHANGED = 1; - SCOPE_CHANGED = 2; - } - - enum Impact { - IMPACT_UNSPECIFIED = 0; - IMPACT_HIGH = 1; - IMPACT_LOW = 2; - IMPACT_NONE = 3; - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto deleted file mode 100644 index 7bc8dc8..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.deployment; - -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/deployment;deployment"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1.deployment"; -option objc_class_prefix = "GRA"; - -// An artifact that can be deployed in some runtime. -message Deployable { - // Required. Resource URI for the artifact being deployed. - repeated string resource_uri = 1; -} - -// Details of a deployment occurrence. -message Details { - // Required. Deployment history for the resource. - Deployment deployment = 1; -} - -// The period during which some deployable was active in a runtime. -message Deployment { - // Identity of the user that triggered this deployment. - string user_email = 1; - - // Required. Beginning of the lifetime of this deployment. - google.protobuf.Timestamp deploy_time = 2; - - // End of the lifetime of this deployment. - google.protobuf.Timestamp undeploy_time = 3; - - // Configuration used to create this deployment. - string config = 4; - - // Address of the runtime element hosting this deployment. - string address = 5; - - // Output only. Resource URI for the artifact being deployed taken from - // the deployable field with the same name. - repeated string resource_uri = 6; - - // Types of platforms. - enum Platform { - // Unknown. - PLATFORM_UNSPECIFIED = 0; - // Google Container Engine. - GKE = 1; - // Google App Engine: Flexible Environment. - FLEX = 2; - // Custom user-defined platform. - CUSTOM = 3; - } - // Platform hosting this deployment. - Platform platform = 7; - - // next_id = 8; -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto deleted file mode 100644 index edfa043..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.discovery; - -import "google/devtools/containeranalysis/v1beta1/common/common.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/discovery;discovery"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1.discovery"; -option objc_class_prefix = "GRA"; - -// A note that indicates a type of analysis a provider would perform. This note -// exists in a provider's project. A `Discovery` occurrence is created in a -// consumer's project at the start of analysis. -message Discovery { - // Required. Immutable. The kind of analysis that is handled by this - // discovery. - grafeas.v1beta1.NoteKind analysis_kind = 1; -} - -// Details of a discovery occurrence. -message Details { - // Required. Analysis status for the discovered resource. - Discovered discovered = 1; -} - -// Provides information about the analysis status of a discovered resource. -message Discovered { - // Whether the resource is continuously analyzed. - enum ContinuousAnalysis { - // Unknown. - CONTINUOUS_ANALYSIS_UNSPECIFIED = 0; - // The resource is continuously analyzed. - ACTIVE = 1; - // The resource is ignored for continuous analysis. - INACTIVE = 2; - } - - // Whether the resource is continuously analyzed. - ContinuousAnalysis continuous_analysis = 1; - - // The last time continuous analysis was done for this resource. - google.protobuf.Timestamp last_analysis_time = 2; - - // Analysis status for a resource. Currently for initial analysis only (not - // updated in continuous analysis). - enum AnalysisStatus { - // Unknown. - ANALYSIS_STATUS_UNSPECIFIED = 0; - // Resource is known but no action has been taken yet. - PENDING = 1; - // Resource is being analyzed. - SCANNING = 2; - // Analysis has finished successfully. - FINISHED_SUCCESS = 3; - // Analysis has finished unsuccessfully, the analysis itself is in a bad - // state. - FINISHED_FAILED = 4; - // The resource is known not to be supported - FINISHED_UNSUPPORTED = 5; - } - - // The status of discovery for the resource. - AnalysisStatus analysis_status = 3; - - // When an error is encountered this will contain a LocalizedMessage under - // details to show to the user. The LocalizedMessage is output only and - // populated by the API. - google.rpc.Status analysis_status_error = 4; -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto deleted file mode 100644 index 8952164..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/devtools/containeranalysis/v1beta1/attestation/attestation.proto"; -import "google/devtools/containeranalysis/v1beta1/build/build.proto"; -import "google/devtools/containeranalysis/v1beta1/common/common.proto"; -import "google/devtools/containeranalysis/v1beta1/deployment/deployment.proto"; -import "google/devtools/containeranalysis/v1beta1/discovery/discovery.proto"; -import "google/devtools/containeranalysis/v1beta1/image/image.proto"; -import "google/devtools/containeranalysis/v1beta1/package/package.proto"; -import "google/devtools/containeranalysis/v1beta1/provenance/provenance.proto"; -import "google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas;grafeas"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1"; -option objc_class_prefix = "GRA"; - -// [Grafeas](grafeas.io) API. -// -// Retrieves analysis results of Cloud components such as Docker container -// images. -// -// Analysis results are stored as a series of occurrences. An `Occurrence` -// contains information about a specific analysis instance on a resource. An -// occurrence refers to a `Note`. A note contains details describing the -// analysis and is generally stored in a separate project, called a `Provider`. -// Multiple occurrences can refer to the same note. -// -// For example, an SSL vulnerability could affect multiple images. In this case, -// there would be one note for the vulnerability and an occurrence for each -// image with the vulnerability referring to that note. -service GrafeasV1Beta1 { - option (google.api.default_host) = "containeranalysis.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Gets the specified occurrence. - rpc GetOccurrence(GetOccurrenceRequest) returns (Occurrence) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/occurrences/*}" - }; - } - - // Lists occurrences for the specified project. - rpc ListOccurrences(ListOccurrencesRequest) - returns (ListOccurrencesResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*}/occurrences" - }; - } - - // Deletes the specified occurrence. For example, use this method to delete an - // occurrence when the occurrence is no longer applicable for the given - // resource. - rpc DeleteOccurrence(DeleteOccurrenceRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/occurrences/*}" - }; - } - - // Creates a new occurrence. - rpc CreateOccurrence(CreateOccurrenceRequest) returns (Occurrence) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*}/occurrences" - body: "occurrence" - }; - } - - // Creates new occurrences in batch. - rpc BatchCreateOccurrences(BatchCreateOccurrencesRequest) - returns (BatchCreateOccurrencesResponse) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*}/occurrences:batchCreate" - body: "*" - }; - } - - // Updates the specified occurrence. - rpc UpdateOccurrence(UpdateOccurrenceRequest) returns (Occurrence) { - option (google.api.http) = { - patch: "/v1beta1/{name=projects/*/occurrences/*}" - body: "occurrence" - }; - } - - // Gets the note attached to the specified occurrence. Consumer projects can - // use this method to get a note that belongs to a provider project. - rpc GetOccurrenceNote(GetOccurrenceNoteRequest) returns (Note) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/occurrences/*}/notes" - }; - } - - // Gets the specified note. - rpc GetNote(GetNoteRequest) returns (Note) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/notes/*}" - }; - } - - // Lists notes for the specified project. - rpc ListNotes(ListNotesRequest) returns (ListNotesResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*}/notes" - }; - } - - // Deletes the specified note. - rpc DeleteNote(DeleteNoteRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/notes/*}" - }; - } - - // Creates a new note. - rpc CreateNote(CreateNoteRequest) returns (Note) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*}/notes" - body: "note" - }; - } - - // Creates new notes in batch. - rpc BatchCreateNotes(BatchCreateNotesRequest) - returns (BatchCreateNotesResponse) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*}/notes:batchCreate" - body: "*" - }; - } - - // Updates the specified note. - rpc UpdateNote(UpdateNoteRequest) returns (Note) { - option (google.api.http) = { - patch: "/v1beta1/{name=projects/*/notes/*}" - body: "note" - }; - } - - // Lists occurrences referencing the specified note. Provider projects can use - // this method to get all occurrences across consumer projects referencing the - // specified note. - rpc ListNoteOccurrences(ListNoteOccurrencesRequest) - returns (ListNoteOccurrencesResponse) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/notes/*}/occurrences" - }; - } - - // Gets a summary of the number and severity of occurrences. - rpc GetVulnerabilityOccurrencesSummary( - GetVulnerabilityOccurrencesSummaryRequest) - returns (VulnerabilityOccurrencesSummary) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*}/occurrences:vulnerabilitySummary" - }; - } -} - -// An instance of an analysis type that has been found on a resource. -message Occurrence { - // Output only. The name of the occurrence in the form of - // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - string name = 1; - - // Required. Immutable. The resource for which the occurrence applies. - Resource resource = 2; - - // Required. Immutable. The analysis note associated with this occurrence, in - // the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. This field can be - // used as a filter in list requests. - string note_name = 3; - - // Output only. This explicitly denotes which of the occurrence details are - // specified. This field can be used as a filter in list requests. - grafeas.v1beta1.NoteKind kind = 4; - - // A description of actions that can be taken to remedy the note. - string remediation = 5; - - // Output only. The time this occurrence was created. - google.protobuf.Timestamp create_time = 6; - - // Output only. The time this occurrence was last updated. - google.protobuf.Timestamp update_time = 7; - - // Required. Immutable. Describes the details of the note kind found on this - // resource. - oneof details { - // Describes a security vulnerability. - grafeas.v1beta1.vulnerability.Details vulnerability = 8; - // Describes a verifiable build. - grafeas.v1beta1.build.Details build = 9; - // Describes how this resource derives from the basis in the associated - // note. - grafeas.v1beta1.image.Details derived_image = 10; - // Describes the installation of a package on the linked resource. - grafeas.v1beta1.package.Details installation = 11; - // Describes the deployment of an artifact on a runtime. - grafeas.v1beta1.deployment.Details deployment = 12; - // Describes when a resource was discovered. - grafeas.v1beta1.discovery.Details discovered = 13; - // Describes an attestation of an artifact. - grafeas.v1beta1.attestation.Details attestation = 14; - } - - // next_id = 15; -} - -// An entity that can have metadata. For example, a Docker image. -message Resource { - // The name of the resource. For example, the name of a Docker image - - // "Debian". - string name = 1; - // Required. The unique URI of the resource. For example, - // `https://gcr.io/project/image@sha256:foo` for a Docker image. - string uri = 2; - // The hash of the resource content. For example, the Docker digest. - grafeas.v1beta1.provenance.Hash content_hash = 3; - - // next_id = 4; -} - -// A type of analysis that can be done for a resource. -message Note { - // Output only. The name of the note in the form of - // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - string name = 1; - - // A one sentence description of this note. - string short_description = 2; - - // A detailed description of this note. - string long_description = 3; - - // Output only. The type of analysis. This field can be used as a filter in - // list requests. - grafeas.v1beta1.NoteKind kind = 4; - - // URLs associated with this note. - repeated grafeas.v1beta1.RelatedUrl related_url = 5; - - // Time of expiration for this note. Empty if note does not expire. - google.protobuf.Timestamp expiration_time = 6; - - // Output only. The time this note was created. This field can be used as a - // filter in list requests. - google.protobuf.Timestamp create_time = 7; - - // Output only. The time this note was last updated. This field can be used as - // a filter in list requests. - google.protobuf.Timestamp update_time = 8; - - // Other notes related to this note. - repeated string related_note_names = 9; - - // Required. Immutable. The type of analysis this note represents. - oneof type { - // A note describing a package vulnerability. - grafeas.v1beta1.vulnerability.Vulnerability vulnerability = 10; - // A note describing build provenance for a verifiable build. - grafeas.v1beta1.build.Build build = 11; - // A note describing a base image. - grafeas.v1beta1.image.Basis base_image = 12; - // A note describing a package hosted by various package managers. - grafeas.v1beta1.package.Package package = 13; - // A note describing something that can be deployed. - grafeas.v1beta1.deployment.Deployable deployable = 14; - // A note describing the initial analysis of a resource. - grafeas.v1beta1.discovery.Discovery discovery = 15; - // A note describing an attestation role. - grafeas.v1beta1.attestation.Authority attestation_authority = 16; - } - - // next_id = 17; -} - -// Request to get an occurrence. -message GetOccurrenceRequest { - // The name of the occurrence in the form of - // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - string name = 1; -} - -// Request to list occurrences. -message ListOccurrencesRequest { - // The name of the project to list occurrences for in the form of - // `projects/[PROJECT_ID]`. - string parent = 1; - - // The filter expression. - string filter = 2; - - // Number of occurrences to return in the list. - int32 page_size = 3; - - // Token to provide to skip to a particular spot in the list. - string page_token = 4; - - // next_id = 7; -} - -// Response for listing occurrences. -message ListOccurrencesResponse { - // The occurrences requested. - repeated Occurrence occurrences = 1; - // The next pagination token in the list response. It should be used as - // `page_token` for the following request. An empty value means no more - // results. - string next_page_token = 2; -} - -// Request to delete a occurrence. -message DeleteOccurrenceRequest { - // The name of the occurrence in the form of - // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - string name = 1; -} - -// Request to create a new occurrence. -message CreateOccurrenceRequest { - // The name of the project in the form of `projects/[PROJECT_ID]`, under which - // the occurrence is to be created. - string parent = 1; - // The occurrence to create. - Occurrence occurrence = 2; -} - -// Request to update an occurrence. -message UpdateOccurrenceRequest { - // The name of the occurrence in the form of - // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - string name = 1; - // The updated occurrence. - Occurrence occurrence = 2; - // The fields to update. - google.protobuf.FieldMask update_mask = 3; -} - -// Request to get a note. -message GetNoteRequest { - // The name of the note in the form of - // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - string name = 1; -} - -// Request to get the note to which the specified occurrence is attached. -message GetOccurrenceNoteRequest { - // The name of the occurrence in the form of - // `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - string name = 1; -} - -// Request to list notes. -message ListNotesRequest { - // The name of the project to list notes for in the form of - // `projects/[PROJECT_ID]`. - string parent = 1; - // The filter expression. - string filter = 2; - // Number of notes to return in the list. - int32 page_size = 3; - // Token to provide to skip to a particular spot in the list. - string page_token = 4; -} - -// Response for listing notes. -message ListNotesResponse { - // The notes requested. - repeated Note notes = 1; - // The next pagination token in the list response. It should be used as - // `page_token` for the following request. An empty value means no more - // results. - string next_page_token = 2; -} - -// Request to delete a note. -message DeleteNoteRequest { - // The name of the note in the form of - // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - string name = 1; -} - -// Request to create a new note. -message CreateNoteRequest { - // The name of the project in the form of `projects/[PROJECT_ID]`, under which - // the note is to be created. - string parent = 1; - // The ID to use for this note. - string note_id = 2; - // The note to create. - Note note = 3; -} - -// Request to update a note. -message UpdateNoteRequest { - // The name of the note in the form of - // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - string name = 1; - // The updated note. - Note note = 2; - // The fields to update. - google.protobuf.FieldMask update_mask = 3; -} - -// Request to list occurrences for a note. -message ListNoteOccurrencesRequest { - // The name of the note to list occurrences for in the form of - // `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - string name = 1; - // The filter expression. - string filter = 2; - // Number of occurrences to return in the list. - int32 page_size = 3; - // Token to provide to skip to a particular spot in the list. - string page_token = 4; -} - -// Response for listing occurrences for a note. -message ListNoteOccurrencesResponse { - // The occurrences attached to the specified note. - repeated Occurrence occurrences = 1; - // Token to provide to skip to a particular spot in the list. - string next_page_token = 2; -} - -// Request to create notes in batch. -message BatchCreateNotesRequest { - // The name of the project in the form of `projects/[PROJECT_ID]`, under which - // the notes are to be created. - string parent = 1; - - // The notes to create. - map notes = 2; -} - -// Response for creating notes in batch. -message BatchCreateNotesResponse { - // The notes that were created. - repeated Note notes = 1; -} - -// Request to create occurrences in batch. -message BatchCreateOccurrencesRequest { - // The name of the project in the form of `projects/[PROJECT_ID]`, under which - // the occurrences are to be created. - string parent = 1; - // The occurrences to create. - repeated Occurrence occurrences = 2; -} - -// Response for creating occurrences in batch. -message BatchCreateOccurrencesResponse { - // The occurrences that were created. - repeated Occurrence occurrences = 1; -} - -// Request to get a vulnerability summary for some set of occurrences. -message GetVulnerabilityOccurrencesSummaryRequest { - // The name of the project to get a vulnerability summary for in the form of - // `projects/[PROJECT_ID]`. - string parent = 1; - // The filter expression. - string filter = 2; -} - -// A summary of how many vulnerability occurrences there are per resource and -// severity type. -message VulnerabilityOccurrencesSummary { - // A listing by resource of the number of fixable and total vulnerabilities. - repeated FixableTotalByDigest counts = 1; - - // Per resource and severity counts of fixable and total vulnerabilities. - message FixableTotalByDigest { - // The affected resource. - Resource resource = 1; - // The severity for this count. SEVERITY_UNSPECIFIED indicates total across - // all severities. - grafeas.v1beta1.vulnerability.Severity severity = 2; - // The number of fixable vulnerabilities associated with this resource. - int64 fixable_count = 3; - // The total number of vulnerabilities associated with this resource. - int64 total_count = 4; - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/image/image.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/image/image.proto deleted file mode 100644 index 91ee33e..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/image/image.proto +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.image; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/image;image"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1.image"; -option objc_class_prefix = "GRA"; - -// Layer holds metadata specific to a layer of a Docker image. -message Layer { - // Instructions from Dockerfile. - enum Directive { - // Default value for unsupported/missing directive. - DIRECTIVE_UNSPECIFIED = 0; - - // https://docs.docker.com/engine/reference/builder/ - MAINTAINER = 1; - - // https://docs.docker.com/engine/reference/builder/ - RUN = 2; - - // https://docs.docker.com/engine/reference/builder/ - CMD = 3; - - // https://docs.docker.com/engine/reference/builder/ - LABEL = 4; - - // https://docs.docker.com/engine/reference/builder/ - EXPOSE = 5; - - // https://docs.docker.com/engine/reference/builder/ - ENV = 6; - - // https://docs.docker.com/engine/reference/builder/ - ADD = 7; - - // https://docs.docker.com/engine/reference/builder/ - COPY = 8; - - // https://docs.docker.com/engine/reference/builder/ - ENTRYPOINT = 9; - - // https://docs.docker.com/engine/reference/builder/ - VOLUME = 10; - - // https://docs.docker.com/engine/reference/builder/ - USER = 11; - - // https://docs.docker.com/engine/reference/builder/ - WORKDIR = 12; - - // https://docs.docker.com/engine/reference/builder/ - ARG = 13; - - // https://docs.docker.com/engine/reference/builder/ - ONBUILD = 14; - - // https://docs.docker.com/engine/reference/builder/ - STOPSIGNAL = 15; - - // https://docs.docker.com/engine/reference/builder/ - HEALTHCHECK = 16; - - // https://docs.docker.com/engine/reference/builder/ - SHELL = 17; - } - - // Required. The recovered Dockerfile directive used to construct this layer. - Directive directive = 1; - - // The recovered arguments to the Dockerfile directive. - string arguments = 2; -} - -// A set of properties that uniquely identify a given Docker image. -message Fingerprint { - // Required. The layer ID of the final layer in the Docker image's v1 - // representation. - string v1_name = 1; - - // Required. The ordered list of v2 blobs that represent a given image. - repeated string v2_blob = 2; - - // Output only. The name of the image's v2 blobs computed via: - // [bottom] := v2_blob[bottom] - // [N] := sha256(v2_blob[N] + " " + v2_name[N+1]) - // Only the name of the final blob is kept. - string v2_name = 3; -} - -// Basis describes the base image portion (Note) of the DockerImage -// relationship. Linked occurrences are derived from this or an -// equivalent image via: -// FROM -// Or an equivalent reference, e.g. a tag of the resource_url. -message Basis { - // Required. Immutable. The resource_url for the resource representing the - // basis of associated occurrence images. - string resource_url = 1; - - // Required. Immutable. The fingerprint of the base image. - Fingerprint fingerprint = 2; -} - -// Details of an image occurrence. -message Details { - // Required. Immutable. The child image derived from the base image. - Derived derived_image = 1; -} - -// Derived describes the derived image portion (Occurrence) of the DockerImage -// relationship. This image would be produced from a Dockerfile with FROM -// . -message Derived { - // Required. The fingerprint of the derived image. - Fingerprint fingerprint = 1; - - // Output only. The number of layers by which this image differs from the - // associated image basis. - int32 distance = 2; - - // This contains layer-specific metadata, if populated it has length - // "distance" and is ordered with [distance] being the layer immediately - // following the base image and [1] being the final layer. - repeated Layer layer_info = 3; - - // Output only. This contains the base image URL for the derived image - // occurrence. - string base_resource_url = 4; -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/package/package.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/package/package.proto deleted file mode 100644 index 59cac20..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/package/package.proto +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.package; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/package"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1.pkg"; -option objc_class_prefix = "GRA"; - -// Instruction set architectures supported by various package managers. -enum Architecture { - // Unknown architecture. - ARCHITECTURE_UNSPECIFIED = 0; - // X86 architecture. - X86 = 1; - // X64 architecture. - X64 = 2; -} - -// This represents a particular channel of distribution for a given package. -// E.g., Debian's jessie-backports dpkg mirror. -message Distribution { - // Required. The cpe_uri in [CPE format](https://cpe.mitre.org/specification/) - // denoting the package manager version distributing a package. - string cpe_uri = 1; - - // The CPU architecture for which packages in this distribution channel were - // built. - Architecture architecture = 2; - - // The latest available version of this package in this distribution channel. - Version latest_version = 3; - - // A freeform string denoting the maintainer of this package. - string maintainer = 4; - - // The distribution channel-specific homepage for this package. - string url = 5; - - // The distribution channel-specific description of this package. - string description = 6; -} - -// An occurrence of a particular package installation found within a system's -// filesystem. E.g., glibc was found in `/var/lib/dpkg/status`. -message Location { - // Required. The CPE URI in [CPE format](https://cpe.mitre.org/specification/) - // denoting the package manager version distributing a package. - string cpe_uri = 1; - - // The version installed at this location. - Version version = 2; - - // The path from which we gathered that this package/version is installed. - string path = 3; -} - -// This represents a particular package that is distributed over various -// channels. E.g., glibc (aka libc6) is distributed by many, at various -// versions. -message Package { - // Required. Immutable. The name of the package. - string name = 1; - - // The various channels by which a package is distributed. - repeated Distribution distribution = 10; -} - -// Details of a package occurrence. -message Details { - // Required. Where the package was installed. - Installation installation = 1; -} - -// This represents how a particular software package may be installed on a -// system. -message Installation { - // Output only. The name of the installed package. - string name = 1; - - // Required. All of the places within the filesystem versions of this package - // have been found. - repeated Location location = 2; -} - -// Version contains structured information about the version of a package. -message Version { - // Used to correct mistakes in the version numbering scheme. - int32 epoch = 1; - - // Required only when version kind is NORMAL. The main part of the version - // name. - string name = 2; - - // The iteration of the package build from the above version. - string revision = 3; - - // Whether this is an ordinary package version or a sentinel MIN/MAX version. - enum VersionKind { - // Unknown. - VERSION_KIND_UNSPECIFIED = 0; - // A standard package version. - NORMAL = 1; - // A special version representing negative infinity. - MINIMUM = 2; - // A special version representing positive infinity. - MAXIMUM = 3; - }; - - // Required. Distinguishes between sentinel MIN/MAX versions and normal - // versions. - VersionKind kind = 4; -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto deleted file mode 100644 index 761877c..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.provenance; - -import "google/devtools/containeranalysis/v1beta1/source/source.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/provenance;provenance"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1.provenance"; -option objc_class_prefix = "GRA"; - -// Provenance of a build. Contains all information needed to verify the full -// details about the build from source to completion. -message BuildProvenance { - // Required. Unique identifier of the build. - string id = 1; - - // ID of the project. - string project_id = 2; - - // Commands requested by the build. - repeated Command commands = 3; - - // Output of the build. - repeated Artifact built_artifacts = 4; - - // Time at which the build was created. - google.protobuf.Timestamp create_time = 5; - - // Time at which execution of the build was started. - google.protobuf.Timestamp start_time = 6; - - // Time at which execution of the build was finished. - google.protobuf.Timestamp end_time = 7; - - // E-mail address of the user who initiated this build. Note that this was the - // user's e-mail address at the time the build was initiated; this address may - // not represent the same end-user for all time. - string creator = 8; - - // URI where any logs for this provenance were written. - string logs_uri = 9; - - // Details of the Source input to the build. - Source source_provenance = 10; - - // Trigger identifier if the build was triggered automatically; empty if not. - string trigger_id = 11; - - // Special options applied to this build. This is a catch-all field where - // build providers can enter any desired additional details. - map build_options = 12; - - // Version string of the builder at the time this build was executed. - string builder_version = 13; - - // next_id = 14 -} - -// Source describes the location of the source used for the build. -message Source { - // If provided, the input binary artifacts for the build came from this - // location. - string artifact_storage_source_uri = 1; - - // Hash(es) of the build source, which can be used to verify that the original - // source integrity was maintained in the build. - // - // The keys to this map are file paths used as build source and the values - // contain the hash values for those files. - // - // If the build source came in a single package such as a gzipped tarfile - // (.tar.gz), the FileHash will be for the single path to that file. - map file_hashes = 2; - - // If provided, the source code used for the build came from this location. - grafeas.v1beta1.source.SourceContext context = 3; - - // If provided, some of the source code used for the build may be found in - // these locations, in the case where the source repository had multiple - // remotes or submodules. This list will not include the context specified in - // the context field. - repeated grafeas.v1beta1.source.SourceContext additional_contexts = 4; -} - -// Container message for hashes of byte content of files, used in source -// messages to verify integrity of source input to the build. -message FileHashes { - // Required. Collection of file hashes. - repeated Hash file_hash = 1; -} - -// Container message for hash values. -message Hash { - // Specifies the hash algorithm. - enum HashType { - // Unknown. - HASH_TYPE_UNSPECIFIED = 0; - // A SHA-256 hash. - SHA256 = 1; - } - - // Required. The type of hash that was performed. - HashType type = 1; - // Required. The hash value. - bytes value = 2; -} - -// Command describes a step performed as part of the build pipeline. -message Command { - // Required. Name of the command, as presented on the command line, or if the - // command is packaged as a Docker container, as presented to `docker pull`. - string name = 1; - - // Environment variables set before running this command. - repeated string env = 2; - - // Command-line arguments used when executing this command. - repeated string args = 3; - - // Working directory (relative to project source root) used when running this - // command. - string dir = 4; - - // Optional unique identifier for this command, used in wait_for to reference - // this command as a dependency. - string id = 5; - - // The ID(s) of the command(s) that this command depends on. - repeated string wait_for = 6; -} - -// Artifact describes a build product. -message Artifact { - // Hash or checksum value of a binary, or Docker Registry 2.0 digest of a - // container. - string checksum = 1; - - // Artifact ID, if any; for container images, this will be a URL by digest - // like `gcr.io/projectID/imagename@sha256:123456`. - string id = 2; - - // Related artifact names. This may be the path to a binary or jar file, or in - // the case of a container build, the name used to push the container image to - // Google Container Registry, as presented to `docker push`. Note that a - // single Artifact ID can have multiple names, for example if two tags are - // applied to one image. - repeated string names = 3; -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/source/source.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/source/source.proto deleted file mode 100644 index 01be060..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/source/source.proto +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.source; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/source;source"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1.source"; -option objc_class_prefix = "GRA"; - -// A SourceContext is a reference to a tree of files. A SourceContext together -// with a path point to a unique revision of a single file or directory. -message SourceContext { - // A SourceContext can refer any one of the following types of repositories. - oneof context { - // A SourceContext referring to a revision in a Google Cloud Source Repo. - CloudRepoSourceContext cloud_repo = 1; - - // A SourceContext referring to a Gerrit project. - GerritSourceContext gerrit = 2; - - // A SourceContext referring to any third party Git repo (e.g., GitHub). - GitSourceContext git = 3; - } - - // Labels with user defined metadata. - map labels = 4; -} - -// An alias to a repo revision. -message AliasContext { - // The type of an alias. - enum Kind { - // Unknown. - KIND_UNSPECIFIED = 0; - // Git tag. - FIXED = 1; - // Git branch. - MOVABLE = 2; - // Used to specify non-standard aliases. For example, if a Git repo has a - // ref named "refs/foo/bar". - OTHER = 4; - } - - // The alias kind. - Kind kind = 1; - - // The alias name. - string name = 2; -} - -// A CloudRepoSourceContext denotes a particular revision in a Google Cloud -// Source Repo. -message CloudRepoSourceContext { - // The ID of the repo. - RepoId repo_id = 1; - - // A revision in a Cloud Repo can be identified by either its revision ID or - // its alias. - oneof revision { - // A revision ID. - string revision_id = 2; - - // An alias, which may be a branch or tag. - AliasContext alias_context = 3; - } -} - -// A SourceContext referring to a Gerrit project. -message GerritSourceContext { - // The URI of a running Gerrit instance. - string host_uri = 1; - - // The full project name within the host. Projects may be nested, so - // "project/subproject" is a valid project name. The "repo name" is the - // hostURI/project. - string gerrit_project = 2; - - // A revision in a Gerrit project can be identified by either its revision ID - // or its alias. - oneof revision { - // A revision (commit) ID. - string revision_id = 3; - - // An alias, which may be a branch or tag. - AliasContext alias_context = 4; - } -} - -// A GitSourceContext denotes a particular revision in a third party Git -// repository (e.g., GitHub). -message GitSourceContext { - // Git repository URL. - string url = 1; - - // Git commit hash. - string revision_id = 2; -} - -// A unique identifier for a Cloud Repo. -message RepoId { - // A cloud repo can be identified by either its project ID and repository name - // combination, or its globally unique identifier. - oneof id { - // A combination of a project ID and a repo name. - ProjectRepoId project_repo_id = 1; - - // A server-assigned, globally unique identifier. - string uid = 2; - } -} - -// Selects a repo using a Google Cloud Platform project ID (e.g., -// winged-cargo-31) and a repo name within that project. -message ProjectRepoId { - // The ID of the project. - string project_id = 1; - - // The name of the repo. Leave empty for the default repo. - string repo_name = 2; -} diff --git a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto b/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto deleted file mode 100644 index d83c7e4..0000000 --- a/owl-bot-staging/v1beta1/protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright 2018 The Grafeas Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.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 grafeas.v1beta1.vulnerability; - -import "google/protobuf/timestamp.proto"; -import "google/devtools/containeranalysis/v1beta1/common/common.proto"; -import "google/devtools/containeranalysis/v1beta1/cvss/cvss.proto"; -import "google/devtools/containeranalysis/v1beta1/package/package.proto"; - -option go_package = "google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/vulnerability;vulnerability"; -option java_multiple_files = true; -option java_package = "io.grafeas.v1beta1.vulnerability"; -option objc_class_prefix = "GRA"; - -// Note provider-assigned severity/impact ranking. -enum Severity { - // Unknown. - SEVERITY_UNSPECIFIED = 0; - // Minimal severity. - MINIMAL = 1; - // Low severity. - LOW = 2; - // Medium severity. - MEDIUM = 3; - // High severity. - HIGH = 4; - // Critical severity. - CRITICAL = 5; -} - -// Vulnerability provides metadata about a security vulnerability in a Note. -message Vulnerability { - // The CVSS score for this vulnerability. - float cvss_score = 1; - - // Note provider assigned impact of the vulnerability. - Severity severity = 2; - - // All information about the package to specifically identify this - // vulnerability. One entry per (version range and cpe_uri) the package - // vulnerability has manifested in. - repeated Detail details = 3; - - // Identifies all appearances of this vulnerability in the package for a - // specific distro/location. For example: glibc in - // cpe:/o:debian:debian_linux:8 for versions 2.1 - 2.2 - message Detail { - // Required. The CPE URI in - // [cpe format](https://cpe.mitre.org/specification/) in which the - // vulnerability manifests. Examples include distro or storage location for - // vulnerable jar. - string cpe_uri = 1; - - // Required. The name of the package where the vulnerability was found. - string package = 2; - - // The min version of the package in which the vulnerability exists. - grafeas.v1beta1.package.Version min_affected_version = 3; - - // The max version of the package in which the vulnerability exists. - grafeas.v1beta1.package.Version max_affected_version = 4; - - // The severity (eg: distro assigned severity) for this vulnerability. - string severity_name = 5; - - // A vendor-specific description of this note. - string description = 6; - - // The fix for this specific package version. - VulnerabilityLocation fixed_location = 7; - - // The type of package; whether native or non native(ruby gems, node.js - // packages etc). - string package_type = 8; - - // Whether this detail is obsolete. Occurrences are expected not to point to - // obsolete details. - bool is_obsolete = 9; - - // The time this information was last changed at the source. This is an - // upstream timestamp from the underlying information source - e.g. Ubuntu - // security tracker. - google.protobuf.Timestamp source_update_time = 10; - } - - // The full description of the CVSSv3. - CVSSv3 cvss_v3 = 4; - - // Windows details get their own format because the information format and - // model don't match a normal detail. Specifically Windows updates are done as - // patches, thus Windows vulnerabilities really are a missing package, rather - // than a package being at an incorrect version. - repeated WindowsDetail windows_details = 5; - - message WindowsDetail { - // Required. The CPE URI in - // [cpe format](https://cpe.mitre.org/specification/) in which the - // vulnerability manifests. Examples include distro or storage location for - // vulnerable jar. - string cpe_uri = 1; - - // Required. The name of the vulnerability. - string name = 2; - - // The description of the vulnerability. - string description = 3; - - // Required. The names of the KBs which have hotfixes to mitigate this - // vulnerability. Note that there may be multiple hotfixes (and thus - // multiple KBs) that mitigate a given vulnerability. Currently any listed - // kb's presence is considered a fix. - repeated KnowledgeBase fixing_kbs = 4; - - message KnowledgeBase { - // The KB name (generally of the form KB[0-9]+ i.e. KB123456). - string name = 1; - // A link to the KB in the Windows update catalog - - // https://www.catalog.update.microsoft.com/ - string url = 2; - } - } - - // The time this information was last changed at the source. This is an - // upstream timestamp from the underlying information source - e.g. Ubuntu - // security tracker. - google.protobuf.Timestamp source_update_time = 6; - - // Next free ID is 7. -} - -// Details of a vulnerability Occurrence. -message Details { - // The type of package; whether native or non native(ruby gems, node.js - // packages etc) - string type = 1; - - // Output only. The note provider assigned Severity of the vulnerability. - Severity severity = 2; - - // Output only. The CVSS score of this vulnerability. CVSS score is on a - // scale of 0-10 where 0 indicates low severity and 10 indicates high - // severity. - float cvss_score = 3; - - // Required. The set of affected locations and their fixes (if available) - // within the associated resource. - repeated PackageIssue package_issue = 4; - - // Output only. A one sentence description of this vulnerability. - string short_description = 5; - - // Output only. A detailed description of this vulnerability. - string long_description = 6; - - // Output only. URLs related to this vulnerability. - repeated grafeas.v1beta1.RelatedUrl related_urls = 7; - - // The distro assigned severity for this vulnerability when it is - // available, and note provider assigned severity when distro has not yet - // assigned a severity for this vulnerability. - Severity effective_severity = 8; -} - -// This message wraps a location affected by a vulnerability and its -// associated fix (if one is available). -message PackageIssue { - // Required. The location of the vulnerability. - VulnerabilityLocation affected_location = 1; - - // The location of the available fix for vulnerability. - VulnerabilityLocation fixed_location = 2; - - // Deprecated, use Details.effective_severity instead - // The severity (e.g., distro assigned severity) for this vulnerability. - string severity_name = 3; -} - -// The location of the vulnerability. -message VulnerabilityLocation { - // Required. The CPE URI in [cpe format](https://cpe.mitre.org/specification/) - // format. Examples include distro or storage location for vulnerable jar. - string cpe_uri = 1; - - // Required. The package being described. - string package = 2; - - // Required. The version of the package being described. - grafeas.v1beta1.package.Version version = 3; -} diff --git a/owl-bot-staging/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts deleted file mode 100644 index d3f5d83..0000000 --- a/owl-bot-staging/v1beta1/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1beta1 from './v1beta1'; -const ContainerAnalysisV1Beta1Client = v1beta1.ContainerAnalysisV1Beta1Client; -type ContainerAnalysisV1Beta1Client = v1beta1.ContainerAnalysisV1Beta1Client; -const GrafeasV1Beta1Client = v1beta1.GrafeasV1Beta1Client; -type GrafeasV1Beta1Client = v1beta1.GrafeasV1Beta1Client; -export {v1beta1, ContainerAnalysisV1Beta1Client, GrafeasV1Beta1Client}; -export default {v1beta1, ContainerAnalysisV1Beta1Client, GrafeasV1Beta1Client}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client.ts deleted file mode 100644 index 0bcd7d1..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client.ts +++ /dev/null @@ -1,959 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/container_analysis_v1_beta1_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './container_analysis_v1_beta1_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Retrieves analysis results of Cloud components such as Docker container - * images. The Container Analysis API is an implementation of the - * [Grafeas](grafeas.io) API. - * - * Analysis results are stored as a series of occurrences. An `Occurrence` - * contains information about a specific analysis instance on a resource. An - * occurrence refers to a `Note`. A note contains details describing the - * analysis and is generally stored in a separate project, called a `Provider`. - * Multiple occurrences can refer to the same note. - * - * For example, an SSL vulnerability could affect multiple images. In this case, - * there would be one note for the vulnerability and an occurrence for each - * image with the vulnerability referring to that note. - * @class - * @memberof v1beta1 - */ -export class ContainerAnalysisV1Beta1Client { - 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}; - containerAnalysisV1Beta1Stub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ContainerAnalysisV1Beta1Client. - * - * @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 ContainerAnalysisV1Beta1Client; - 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 = { - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - scanConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/scanConfigs/{scan_config}' - ), - }; - - // 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') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1', 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.containerAnalysisV1Beta1Stub) { - return this.containerAnalysisV1Beta1Stub; - } - - // Put together the "service stub" for - // google.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1. - this.containerAnalysisV1Beta1Stub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1, - 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 containerAnalysisV1Beta1StubMethods = - ['setIamPolicy', 'getIamPolicy', 'testIamPermissions', 'getScanConfig', 'listScanConfigs', 'updateScanConfig']; - for (const methodName of containerAnalysisV1Beta1StubMethods) { - const callPromise = this.containerAnalysisV1Beta1Stub.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.containerAnalysisV1Beta1Stub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'containeranalysis.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 'containeranalysis.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 -- - // ------------------- - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Sets the access control policy on the specified note or occurrence. - * Requires `containeranalysis.notes.setIamPolicy` or - * `containeranalysis.occurrences.setIamPolicy` permission if the resource is - * a note or an occurrence, respectively. - * - * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - * occurrences. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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.setIamPolicy(request); - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets the access control policy for a note or an occurrence resource. - * Requires `containeranalysis.notes.setIamPolicy` or - * `containeranalysis.occurrences.setIamPolicy` permission if the resource is - * a note or occurrence, respectively. - * - * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - * occurrences. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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.getIamPolicy(request); - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; -/** - * Returns the permissions that a caller has on the specified note or - * occurrence. Requires list permission on the project (for example, - * `containeranalysis.notes.list`). - * - * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - * occurrences. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * 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.testIamPermissions(request); - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - getScanConfig( - request?: protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest|undefined, {}|undefined - ]>; - getScanConfig( - request: protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest|null|undefined, - {}|null|undefined>): void; - getScanConfig( - request: protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, - callback: Callback< - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets the specified scan configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the scan configuration in the form of - * `projects/[PROJECT_ID]/scanConfigs/[SCAN_CONFIG_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ScanConfig]{@link google.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest|undefined, {}|undefined - ]>; - updateScanConfig( - request: protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest|null|undefined, - {}|null|undefined>): void; - updateScanConfig( - request: protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, - callback: Callback< - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest|null|undefined, - {}|null|undefined>): void; -/** - * Updates the specified scan configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the scan configuration in the form of - * `projects/[PROJECT_ID]/scanConfigs/[SCAN_CONFIG_ID]`. - * @param {google.devtools.containeranalysis.v1beta1.ScanConfig} request.scanConfig - * Required. The updated scan configuration. - * @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.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.devtools.containeranalysis.v1beta1.IScanConfig, - protos.google.devtools.containeranalysis.v1beta1.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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateScanConfig(request, options, callback); - } - - listScanConfigs( - request?: protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.devtools.containeranalysis.v1beta1.IScanConfig[], - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest|null, - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsResponse - ]>; - listScanConfigs( - request: protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsResponse|null|undefined, - protos.google.devtools.containeranalysis.v1beta1.IScanConfig>): void; - listScanConfigs( - request: protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, - callback: PaginationCallback< - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsResponse|null|undefined, - protos.google.devtools.containeranalysis.v1beta1.IScanConfig>): void; -/** - * Lists scan configurations for the specified project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project to list scan configurations for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * Required. The filter expression. - * @param {number} request.pageSize - * The number of scan configs to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsResponse|null|undefined, - protos.google.devtools.containeranalysis.v1beta1.IScanConfig>, - callback?: PaginationCallback< - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsResponse|null|undefined, - protos.google.devtools.containeranalysis.v1beta1.IScanConfig>): - Promise<[ - protos.google.devtools.containeranalysis.v1beta1.IScanConfig[], - protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest|null, - protos.google.devtools.containeranalysis.v1beta1.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 name of the project to list scan configurations for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * Required. The filter expression. - * @param {number} request.pageSize - * The number of scan configs to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.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 name of the project to list scan configurations for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * Required. The filter expression. - * @param {number} request.pageSize - * The number of scan configs to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.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; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified 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; - } - - /** - * 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.containerAnalysisV1Beta1Stub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client_config.json deleted file mode 100644 index 56b0712..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_client_config.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "interfaces": { - "google.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1": { - "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": { - "SetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetScanConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListScanConfigs": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateScanConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_proto_list.json deleted file mode 100644 index 9ad38a4..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/container_analysis_v1_beta1_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/build/build.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/common/common.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/image/image.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/package/package.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/source/source.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto" -] diff --git a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index da6fa7b..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,263 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.devtools.containeranalysis.v1beta1", - "libraryPackage": "@google-cloud/containeranalysis", - "services": { - "ContainerAnalysisV1Beta1": { - "clients": { - "grpc": { - "libraryClient": "ContainerAnalysisV1Beta1Client", - "rpcs": { - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "GetScanConfig": { - "methods": [ - "getScanConfig" - ] - }, - "UpdateScanConfig": { - "methods": [ - "updateScanConfig" - ] - }, - "ListScanConfigs": { - "methods": [ - "listScanConfigs", - "listScanConfigsStream", - "listScanConfigsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ContainerAnalysisV1Beta1Client", - "rpcs": { - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "GetScanConfig": { - "methods": [ - "getScanConfig" - ] - }, - "UpdateScanConfig": { - "methods": [ - "updateScanConfig" - ] - }, - "ListScanConfigs": { - "methods": [ - "listScanConfigs", - "listScanConfigsStream", - "listScanConfigsAsync" - ] - } - } - } - } - }, - "GrafeasV1Beta1": { - "clients": { - "grpc": { - "libraryClient": "GrafeasV1Beta1Client", - "rpcs": { - "GetOccurrence": { - "methods": [ - "getOccurrence" - ] - }, - "DeleteOccurrence": { - "methods": [ - "deleteOccurrence" - ] - }, - "CreateOccurrence": { - "methods": [ - "createOccurrence" - ] - }, - "BatchCreateOccurrences": { - "methods": [ - "batchCreateOccurrences" - ] - }, - "UpdateOccurrence": { - "methods": [ - "updateOccurrence" - ] - }, - "GetOccurrenceNote": { - "methods": [ - "getOccurrenceNote" - ] - }, - "GetNote": { - "methods": [ - "getNote" - ] - }, - "DeleteNote": { - "methods": [ - "deleteNote" - ] - }, - "CreateNote": { - "methods": [ - "createNote" - ] - }, - "BatchCreateNotes": { - "methods": [ - "batchCreateNotes" - ] - }, - "UpdateNote": { - "methods": [ - "updateNote" - ] - }, - "GetVulnerabilityOccurrencesSummary": { - "methods": [ - "getVulnerabilityOccurrencesSummary" - ] - }, - "ListOccurrences": { - "methods": [ - "listOccurrences", - "listOccurrencesStream", - "listOccurrencesAsync" - ] - }, - "ListNotes": { - "methods": [ - "listNotes", - "listNotesStream", - "listNotesAsync" - ] - }, - "ListNoteOccurrences": { - "methods": [ - "listNoteOccurrences", - "listNoteOccurrencesStream", - "listNoteOccurrencesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "GrafeasV1Beta1Client", - "rpcs": { - "GetOccurrence": { - "methods": [ - "getOccurrence" - ] - }, - "DeleteOccurrence": { - "methods": [ - "deleteOccurrence" - ] - }, - "CreateOccurrence": { - "methods": [ - "createOccurrence" - ] - }, - "BatchCreateOccurrences": { - "methods": [ - "batchCreateOccurrences" - ] - }, - "UpdateOccurrence": { - "methods": [ - "updateOccurrence" - ] - }, - "GetOccurrenceNote": { - "methods": [ - "getOccurrenceNote" - ] - }, - "GetNote": { - "methods": [ - "getNote" - ] - }, - "DeleteNote": { - "methods": [ - "deleteNote" - ] - }, - "CreateNote": { - "methods": [ - "createNote" - ] - }, - "BatchCreateNotes": { - "methods": [ - "batchCreateNotes" - ] - }, - "UpdateNote": { - "methods": [ - "updateNote" - ] - }, - "GetVulnerabilityOccurrencesSummary": { - "methods": [ - "getVulnerabilityOccurrencesSummary" - ] - }, - "ListOccurrences": { - "methods": [ - "listOccurrences", - "listOccurrencesStream", - "listOccurrencesAsync" - ] - }, - "ListNotes": { - "methods": [ - "listNotes", - "listNotesStream", - "listNotesAsync" - ] - }, - "ListNoteOccurrences": { - "methods": [ - "listNoteOccurrences", - "listNoteOccurrencesStream", - "listNoteOccurrencesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client.ts deleted file mode 100644 index 8dfb10a..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client.ts +++ /dev/null @@ -1,1800 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/grafeas_v1_beta1_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './grafeas_v1_beta1_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * [Grafeas](grafeas.io) API. - * - * Retrieves analysis results of Cloud components such as Docker container - * images. - * - * Analysis results are stored as a series of occurrences. An `Occurrence` - * contains information about a specific analysis instance on a resource. An - * occurrence refers to a `Note`. A note contains details describing the - * analysis and is generally stored in a separate project, called a `Provider`. - * Multiple occurrences can refer to the same note. - * - * For example, an SSL vulnerability could affect multiple images. In this case, - * there would be one note for the vulnerability and an occurrence for each - * image with the vulnerability referring to that note. - * @class - * @memberof v1beta1 - */ -export class GrafeasV1Beta1Client { - 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}; - grafeasV1Beta1Stub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of GrafeasV1Beta1Client. - * - * @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 GrafeasV1Beta1Client; - 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 = { - scanConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/scanConfigs/{scan_config}' - ), - }; - - // 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 = { - listOccurrences: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'occurrences'), - listNotes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'notes'), - listNoteOccurrences: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'occurrences') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.devtools.containeranalysis.v1beta1.GrafeasV1Beta1', 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.grafeasV1Beta1Stub) { - return this.grafeasV1Beta1Stub; - } - - // Put together the "service stub" for - // google.devtools.containeranalysis.v1beta1.GrafeasV1Beta1. - this.grafeasV1Beta1Stub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.devtools.containeranalysis.v1beta1.GrafeasV1Beta1') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.devtools.containeranalysis.v1beta1.GrafeasV1Beta1, - 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 grafeasV1Beta1StubMethods = - ['getOccurrence', 'listOccurrences', 'deleteOccurrence', 'createOccurrence', 'batchCreateOccurrences', 'updateOccurrence', 'getOccurrenceNote', 'getNote', 'listNotes', 'deleteNote', 'createNote', 'batchCreateNotes', 'updateNote', 'listNoteOccurrences', 'getVulnerabilityOccurrencesSummary']; - for (const methodName of grafeasV1Beta1StubMethods) { - const callPromise = this.grafeasV1Beta1Stub.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.grafeasV1Beta1Stub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'containeranalysis.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 'containeranalysis.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 -- - // ------------------- - getOccurrence( - request?: protos.grafeas.v1beta1.IGetOccurrenceRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IGetOccurrenceRequest|undefined, {}|undefined - ]>; - getOccurrence( - request: protos.grafeas.v1beta1.IGetOccurrenceRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IGetOccurrenceRequest|null|undefined, - {}|null|undefined>): void; - getOccurrence( - request: protos.grafeas.v1beta1.IGetOccurrenceRequest, - callback: Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IGetOccurrenceRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets the specified occurrence. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the occurrence in the form of - * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Occurrence]{@link grafeas.v1beta1.Occurrence}. - * 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.getOccurrence(request); - */ - getOccurrence( - request?: protos.grafeas.v1beta1.IGetOccurrenceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IGetOccurrenceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IGetOccurrenceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IGetOccurrenceRequest|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.getOccurrence(request, options, callback); - } - deleteOccurrence( - request?: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteOccurrenceRequest|undefined, {}|undefined - ]>; - deleteOccurrence( - request: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteOccurrenceRequest|null|undefined, - {}|null|undefined>): void; - deleteOccurrence( - request: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteOccurrenceRequest|null|undefined, - {}|null|undefined>): void; -/** - * Deletes the specified occurrence. For example, use this method to delete an - * occurrence when the occurrence is no longer applicable for the given - * resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the occurrence in the form of - * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.deleteOccurrence(request); - */ - deleteOccurrence( - request?: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteOccurrenceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteOccurrenceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteOccurrenceRequest|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.deleteOccurrence(request, options, callback); - } - createOccurrence( - request?: protos.grafeas.v1beta1.ICreateOccurrenceRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.ICreateOccurrenceRequest|undefined, {}|undefined - ]>; - createOccurrence( - request: protos.grafeas.v1beta1.ICreateOccurrenceRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.ICreateOccurrenceRequest|null|undefined, - {}|null|undefined>): void; - createOccurrence( - request: protos.grafeas.v1beta1.ICreateOccurrenceRequest, - callback: Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.ICreateOccurrenceRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new occurrence. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project in the form of `projects/[PROJECT_ID]`, under which - * the occurrence is to be created. - * @param {grafeas.v1beta1.Occurrence} request.occurrence - * The occurrence to create. - * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence}. - * 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.createOccurrence(request); - */ - createOccurrence( - request?: protos.grafeas.v1beta1.ICreateOccurrenceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.ICreateOccurrenceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.ICreateOccurrenceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.ICreateOccurrenceRequest|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.createOccurrence(request, options, callback); - } - batchCreateOccurrences( - request?: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|undefined, {}|undefined - ]>; - batchCreateOccurrences( - request: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|null|undefined, - {}|null|undefined>): void; - batchCreateOccurrences( - request: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, - callback: Callback< - protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates new occurrences in batch. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project in the form of `projects/[PROJECT_ID]`, under which - * the occurrences are to be created. - * @param {number[]} request.occurrences - * The occurrences to create. - * @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 [BatchCreateOccurrencesResponse]{@link grafeas.v1beta1.BatchCreateOccurrencesResponse}. - * 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.batchCreateOccurrences(request); - */ - batchCreateOccurrences( - request?: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse, - protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest|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.batchCreateOccurrences(request, options, callback); - } - updateOccurrence( - request?: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IUpdateOccurrenceRequest|undefined, {}|undefined - ]>; - updateOccurrence( - request: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IUpdateOccurrenceRequest|null|undefined, - {}|null|undefined>): void; - updateOccurrence( - request: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, - callback: Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IUpdateOccurrenceRequest|null|undefined, - {}|null|undefined>): void; -/** - * Updates the specified occurrence. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the occurrence in the form of - * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - * @param {grafeas.v1beta1.Occurrence} request.occurrence - * The updated occurrence. - * @param {google.protobuf.FieldMask} request.updateMask - * The fields to update. - * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence}. - * 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.updateOccurrence(request); - */ - updateOccurrence( - request?: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IUpdateOccurrenceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IUpdateOccurrenceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1beta1.IOccurrence, - protos.grafeas.v1beta1.IUpdateOccurrenceRequest|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.updateOccurrence(request, options, callback); - } - getOccurrenceNote( - request?: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|undefined, {}|undefined - ]>; - getOccurrenceNote( - request: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|null|undefined, - {}|null|undefined>): void; - getOccurrenceNote( - request: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, - callback: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets the note attached to the specified occurrence. Consumer projects can - * use this method to get a note that belongs to a provider project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the occurrence in the form of - * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Note]{@link grafeas.v1beta1.Note}. - * 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.getOccurrenceNote(request); - */ - getOccurrenceNote( - request?: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetOccurrenceNoteRequest|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.getOccurrenceNote(request, options, callback); - } - getNote( - request?: protos.grafeas.v1beta1.IGetNoteRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetNoteRequest|undefined, {}|undefined - ]>; - getNote( - request: protos.grafeas.v1beta1.IGetNoteRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetNoteRequest|null|undefined, - {}|null|undefined>): void; - getNote( - request: protos.grafeas.v1beta1.IGetNoteRequest, - callback: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetNoteRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets the specified note. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the note in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Note]{@link grafeas.v1beta1.Note}. - * 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.getNote(request); - */ - getNote( - request?: protos.grafeas.v1beta1.IGetNoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetNoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetNoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IGetNoteRequest|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.getNote(request, options, callback); - } - deleteNote( - request?: protos.grafeas.v1beta1.IDeleteNoteRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteNoteRequest|undefined, {}|undefined - ]>; - deleteNote( - request: protos.grafeas.v1beta1.IDeleteNoteRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteNoteRequest|null|undefined, - {}|null|undefined>): void; - deleteNote( - request: protos.grafeas.v1beta1.IDeleteNoteRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteNoteRequest|null|undefined, - {}|null|undefined>): void; -/** - * Deletes the specified note. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the note in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.deleteNote(request); - */ - deleteNote( - request?: protos.grafeas.v1beta1.IDeleteNoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteNoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteNoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.grafeas.v1beta1.IDeleteNoteRequest|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.deleteNote(request, options, callback); - } - createNote( - request?: protos.grafeas.v1beta1.ICreateNoteRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.ICreateNoteRequest|undefined, {}|undefined - ]>; - createNote( - request: protos.grafeas.v1beta1.ICreateNoteRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.ICreateNoteRequest|null|undefined, - {}|null|undefined>): void; - createNote( - request: protos.grafeas.v1beta1.ICreateNoteRequest, - callback: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.ICreateNoteRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new note. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project in the form of `projects/[PROJECT_ID]`, under which - * the note is to be created. - * @param {string} request.noteId - * The ID to use for this note. - * @param {grafeas.v1beta1.Note} request.note - * The note to create. - * @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 [Note]{@link grafeas.v1beta1.Note}. - * 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.createNote(request); - */ - createNote( - request?: protos.grafeas.v1beta1.ICreateNoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.ICreateNoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.ICreateNoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.ICreateNoteRequest|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.createNote(request, options, callback); - } - batchCreateNotes( - request?: protos.grafeas.v1beta1.IBatchCreateNotesRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.IBatchCreateNotesResponse, - protos.grafeas.v1beta1.IBatchCreateNotesRequest|undefined, {}|undefined - ]>; - batchCreateNotes( - request: protos.grafeas.v1beta1.IBatchCreateNotesRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1beta1.IBatchCreateNotesResponse, - protos.grafeas.v1beta1.IBatchCreateNotesRequest|null|undefined, - {}|null|undefined>): void; - batchCreateNotes( - request: protos.grafeas.v1beta1.IBatchCreateNotesRequest, - callback: Callback< - protos.grafeas.v1beta1.IBatchCreateNotesResponse, - protos.grafeas.v1beta1.IBatchCreateNotesRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates new notes in batch. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project in the form of `projects/[PROJECT_ID]`, under which - * the notes are to be created. - * @param {number[]} request.notes - * The notes to create. - * @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 [BatchCreateNotesResponse]{@link grafeas.v1beta1.BatchCreateNotesResponse}. - * 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.batchCreateNotes(request); - */ - batchCreateNotes( - request?: protos.grafeas.v1beta1.IBatchCreateNotesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1beta1.IBatchCreateNotesResponse, - protos.grafeas.v1beta1.IBatchCreateNotesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1beta1.IBatchCreateNotesResponse, - protos.grafeas.v1beta1.IBatchCreateNotesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1beta1.IBatchCreateNotesResponse, - protos.grafeas.v1beta1.IBatchCreateNotesRequest|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.batchCreateNotes(request, options, callback); - } - updateNote( - request?: protos.grafeas.v1beta1.IUpdateNoteRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IUpdateNoteRequest|undefined, {}|undefined - ]>; - updateNote( - request: protos.grafeas.v1beta1.IUpdateNoteRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IUpdateNoteRequest|null|undefined, - {}|null|undefined>): void; - updateNote( - request: protos.grafeas.v1beta1.IUpdateNoteRequest, - callback: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IUpdateNoteRequest|null|undefined, - {}|null|undefined>): void; -/** - * Updates the specified note. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the note in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {grafeas.v1beta1.Note} request.note - * The updated note. - * @param {google.protobuf.FieldMask} request.updateMask - * The fields to update. - * @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 [Note]{@link grafeas.v1beta1.Note}. - * 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.updateNote(request); - */ - updateNote( - request?: protos.grafeas.v1beta1.IUpdateNoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IUpdateNoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IUpdateNoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1beta1.INote, - protos.grafeas.v1beta1.IUpdateNoteRequest|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.updateNote(request, options, callback); - } - getVulnerabilityOccurrencesSummary( - request?: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, - protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|undefined, {}|undefined - ]>; - getVulnerabilityOccurrencesSummary( - request: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, - options: CallOptions, - callback: Callback< - protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, - protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, - {}|null|undefined>): void; - getVulnerabilityOccurrencesSummary( - request: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, - callback: Callback< - protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, - protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets a summary of the number and severity of occurrences. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project to get a vulnerability summary for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @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 [VulnerabilityOccurrencesSummary]{@link grafeas.v1beta1.VulnerabilityOccurrencesSummary}. - * 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.getVulnerabilityOccurrencesSummary(request); - */ - getVulnerabilityOccurrencesSummary( - request?: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, - protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, - protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary, - protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest|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.getVulnerabilityOccurrencesSummary(request, options, callback); - } - - listOccurrences( - request?: protos.grafeas.v1beta1.IListOccurrencesRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.IOccurrence[], - protos.grafeas.v1beta1.IListOccurrencesRequest|null, - protos.grafeas.v1beta1.IListOccurrencesResponse - ]>; - listOccurrences( - request: protos.grafeas.v1beta1.IListOccurrencesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.grafeas.v1beta1.IListOccurrencesRequest, - protos.grafeas.v1beta1.IListOccurrencesResponse|null|undefined, - protos.grafeas.v1beta1.IOccurrence>): void; - listOccurrences( - request: protos.grafeas.v1beta1.IListOccurrencesRequest, - callback: PaginationCallback< - protos.grafeas.v1beta1.IListOccurrencesRequest, - protos.grafeas.v1beta1.IListOccurrencesResponse|null|undefined, - protos.grafeas.v1beta1.IOccurrence>): void; -/** - * Lists occurrences for the specified project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project to list occurrences for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence}. - * 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 `listOccurrencesAsync()` - * 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. - */ - listOccurrences( - request?: protos.grafeas.v1beta1.IListOccurrencesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.grafeas.v1beta1.IListOccurrencesRequest, - protos.grafeas.v1beta1.IListOccurrencesResponse|null|undefined, - protos.grafeas.v1beta1.IOccurrence>, - callback?: PaginationCallback< - protos.grafeas.v1beta1.IListOccurrencesRequest, - protos.grafeas.v1beta1.IListOccurrencesResponse|null|undefined, - protos.grafeas.v1beta1.IOccurrence>): - Promise<[ - protos.grafeas.v1beta1.IOccurrence[], - protos.grafeas.v1beta1.IListOccurrencesRequest|null, - protos.grafeas.v1beta1.IListOccurrencesResponse - ]>|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.listOccurrences(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 - * The name of the project to list occurrences for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence} 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 `listOccurrencesAsync()` - * 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. - */ - listOccurrencesStream( - request?: protos.grafeas.v1beta1.IListOccurrencesRequest, - 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.listOccurrences.createStream( - this.innerApiCalls.listOccurrences as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listOccurrences`, 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 - * The name of the project to list occurrences for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 - * [Occurrence]{@link grafeas.v1beta1.Occurrence}. 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.listOccurrencesAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listOccurrencesAsync( - request?: protos.grafeas.v1beta1.IListOccurrencesRequest, - 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.listOccurrences.asyncIterate( - this.innerApiCalls['listOccurrences'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - listNotes( - request?: protos.grafeas.v1beta1.IListNotesRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.INote[], - protos.grafeas.v1beta1.IListNotesRequest|null, - protos.grafeas.v1beta1.IListNotesResponse - ]>; - listNotes( - request: protos.grafeas.v1beta1.IListNotesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.grafeas.v1beta1.IListNotesRequest, - protos.grafeas.v1beta1.IListNotesResponse|null|undefined, - protos.grafeas.v1beta1.INote>): void; - listNotes( - request: protos.grafeas.v1beta1.IListNotesRequest, - callback: PaginationCallback< - protos.grafeas.v1beta1.IListNotesRequest, - protos.grafeas.v1beta1.IListNotesResponse|null|undefined, - protos.grafeas.v1beta1.INote>): void; -/** - * Lists notes for the specified project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the project to list notes for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of notes to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Note]{@link grafeas.v1beta1.Note}. - * 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 `listNotesAsync()` - * 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. - */ - listNotes( - request?: protos.grafeas.v1beta1.IListNotesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.grafeas.v1beta1.IListNotesRequest, - protos.grafeas.v1beta1.IListNotesResponse|null|undefined, - protos.grafeas.v1beta1.INote>, - callback?: PaginationCallback< - protos.grafeas.v1beta1.IListNotesRequest, - protos.grafeas.v1beta1.IListNotesResponse|null|undefined, - protos.grafeas.v1beta1.INote>): - Promise<[ - protos.grafeas.v1beta1.INote[], - protos.grafeas.v1beta1.IListNotesRequest|null, - protos.grafeas.v1beta1.IListNotesResponse - ]>|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.listNotes(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 - * The name of the project to list notes for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of notes to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Note]{@link grafeas.v1beta1.Note} 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 `listNotesAsync()` - * 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. - */ - listNotesStream( - request?: protos.grafeas.v1beta1.IListNotesRequest, - 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.listNotes.createStream( - this.innerApiCalls.listNotes as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listNotes`, 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 - * The name of the project to list notes for in the form of - * `projects/[PROJECT_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of notes to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 - * [Note]{@link grafeas.v1beta1.Note}. 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.listNotesAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listNotesAsync( - request?: protos.grafeas.v1beta1.IListNotesRequest, - 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.listNotes.asyncIterate( - this.innerApiCalls['listNotes'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - listNoteOccurrences( - request?: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, - options?: CallOptions): - Promise<[ - protos.grafeas.v1beta1.IOccurrence[], - protos.grafeas.v1beta1.IListNoteOccurrencesRequest|null, - protos.grafeas.v1beta1.IListNoteOccurrencesResponse - ]>; - listNoteOccurrences( - request: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.grafeas.v1beta1.IListNoteOccurrencesRequest, - protos.grafeas.v1beta1.IListNoteOccurrencesResponse|null|undefined, - protos.grafeas.v1beta1.IOccurrence>): void; - listNoteOccurrences( - request: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, - callback: PaginationCallback< - protos.grafeas.v1beta1.IListNoteOccurrencesRequest, - protos.grafeas.v1beta1.IListNoteOccurrencesResponse|null|undefined, - protos.grafeas.v1beta1.IOccurrence>): void; -/** - * Lists occurrences referencing the specified note. Provider projects can use - * this method to get all occurrences across consumer projects referencing the - * specified note. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The name of the note to list occurrences for in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence}. - * 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 `listNoteOccurrencesAsync()` - * 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. - */ - listNoteOccurrences( - request?: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.grafeas.v1beta1.IListNoteOccurrencesRequest, - protos.grafeas.v1beta1.IListNoteOccurrencesResponse|null|undefined, - protos.grafeas.v1beta1.IOccurrence>, - callback?: PaginationCallback< - protos.grafeas.v1beta1.IListNoteOccurrencesRequest, - protos.grafeas.v1beta1.IListNoteOccurrencesResponse|null|undefined, - protos.grafeas.v1beta1.IOccurrence>): - Promise<[ - protos.grafeas.v1beta1.IOccurrence[], - protos.grafeas.v1beta1.IListNoteOccurrencesRequest|null, - protos.grafeas.v1beta1.IListNoteOccurrencesResponse - ]>|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.listNoteOccurrences(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.name - * The name of the note to list occurrences for in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 [Occurrence]{@link grafeas.v1beta1.Occurrence} 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 `listNoteOccurrencesAsync()` - * 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. - */ - listNoteOccurrencesStream( - request?: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, - 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({ - 'name': request.name || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listNoteOccurrences.createStream( - this.innerApiCalls.listNoteOccurrences as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listNoteOccurrences`, 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.name - * The name of the note to list occurrences for in the form of - * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. - * @param {string} request.filter - * The filter expression. - * @param {number} request.pageSize - * Number of occurrences to return in the list. - * @param {string} request.pageToken - * Token to provide to skip to a particular spot in the list. - * @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 - * [Occurrence]{@link grafeas.v1beta1.Occurrence}. 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.listNoteOccurrencesAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listNoteOccurrencesAsync( - request?: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, - 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({ - 'name': request.name || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listNoteOccurrences.asyncIterate( - this.innerApiCalls['listNoteOccurrences'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * 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; - } - - /** - * 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.grafeasV1Beta1Stub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client_config.json deleted file mode 100644 index 8c9edc4..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_client_config.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "interfaces": { - "google.devtools.containeranalysis.v1beta1.GrafeasV1Beta1": { - "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": { - "GetOccurrence": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListOccurrences": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteOccurrence": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateOccurrence": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "BatchCreateOccurrences": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateOccurrence": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetOccurrenceNote": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetNote": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListNotes": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteNote": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateNote": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "BatchCreateNotes": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateNote": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListNoteOccurrences": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetVulnerabilityOccurrencesSummary": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_proto_list.json deleted file mode 100644 index 9ad38a4..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/grafeas_v1_beta1_proto_list.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - "../../protos/google/devtools/containeranalysis/v1beta1/attestation/attestation.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/build/build.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/common/common.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/containeranalysis.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/cvss/cvss.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/deployment/deployment.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/discovery/discovery.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/grafeas/grafeas.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/image/image.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/package/package.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/provenance/provenance.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/source/source.proto", - "../../protos/google/devtools/containeranalysis/v1beta1/vulnerability/vulnerability.proto" -] diff --git a/owl-bot-staging/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index 500064b..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {ContainerAnalysisV1Beta1Client} from './container_analysis_v1_beta1_client'; -export {GrafeasV1Beta1Client} from './grafeas_v1_beta1_client'; diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index e267adc..0000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const containeranalysis = require('@google-cloud/containeranalysis'); - -function main() { - const containerAnalysisV1Beta1Client = new containeranalysis.ContainerAnalysisV1Beta1Client(); - const grafeasV1Beta1Client = new containeranalysis.GrafeasV1Beta1Client(); -} - -main(); diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 057cc77..0000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {ContainerAnalysisV1Beta1Client, GrafeasV1Beta1Client} from '@google-cloud/containeranalysis'; - -// check that the client class type name can be used -function doStuffWithContainerAnalysisV1Beta1Client(client: ContainerAnalysisV1Beta1Client) { - client.close(); -} -function doStuffWithGrafeasV1Beta1Client(client: GrafeasV1Beta1Client) { - client.close(); -} - -function main() { - // check that the client instance can be created - const containerAnalysisV1Beta1Client = new ContainerAnalysisV1Beta1Client(); - doStuffWithContainerAnalysisV1Beta1Client(containerAnalysisV1Beta1Client); - // check that the client instance can be created - const grafeasV1Beta1Client = new GrafeasV1Beta1Client(); - doStuffWithGrafeasV1Beta1Client(grafeasV1Beta1Client); -} - -main(); diff --git a/owl-bot-staging/v1beta1/system-test/install.ts b/owl-bot-staging/v1beta1/system-test/install.ts deleted file mode 100644 index 1f850b5..0000000 --- a/owl-bot-staging/v1beta1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1beta1/test/gapic_container_analysis_v1_beta1_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_container_analysis_v1_beta1_v1beta1.ts deleted file mode 100644 index 43bd76c..0000000 --- a/owl-bot-staging/v1beta1/test/gapic_container_analysis_v1_beta1_v1beta1.ts +++ /dev/null @@ -1,880 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 containeranalysisv1beta1Module from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta1.ContainerAnalysisV1Beta1Client', () => { - it('has servicePath', () => { - const servicePath = containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.containerAnalysisV1Beta1Stub, undefined); - await client.initialize(); - assert(client.containerAnalysisV1Beta1Stub); - }); - - it('has close method', () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - 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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - 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('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getScanConfig', () => { - it('invokes getScanConfig without error', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.GetScanConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.GetScanConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()); - client.innerApiCalls.getScanConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getScanConfig( - request, - (err?: Error|null, result?: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.UpdateScanConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.UpdateScanConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()); - client.innerApiCalls.updateScanConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateScanConfig( - request, - (err?: Error|null, result?: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.UpdateScanConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "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('listScanConfigs', () => { - it('invokes listScanConfigs without error', async () => { - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ListScanConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ListScanConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - ]; - client.innerApiCalls.listScanConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listScanConfigs( - request, - (err?: Error|null, result?: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ListScanConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - ]; - client.descriptors.page.listScanConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listScanConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.devtools.containeranalysis.v1beta1.ScanConfig[] = []; - stream.on('data', (response: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.ScanConfig[] = []; - stream.on('data', (response: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ListScanConfigsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.ScanConfig()), - ]; - client.descriptors.page.listScanConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.devtools.containeranalysis.v1beta1.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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.devtools.containeranalysis.v1beta1.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.devtools.containeranalysis.v1beta1.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('Path templates', () => { - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - 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 containeranalysisv1beta1Module.v1beta1.ContainerAnalysisV1Beta1Client({ - 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)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1beta1/test/gapic_grafeas_v1_beta1_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_grafeas_v1_beta1_v1beta1.ts deleted file mode 100644 index f97e985..0000000 --- a/owl-bot-staging/v1beta1/test/gapic_grafeas_v1_beta1_v1beta1.ts +++ /dev/null @@ -1,1882 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as grafeasv1beta1Module from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta1.GrafeasV1Beta1Client', () => { - it('has servicePath', () => { - const servicePath = grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.grafeasV1Beta1Stub, undefined); - await client.initialize(); - assert(client.grafeasV1Beta1Stub); - }); - - it('has close method', () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - 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 grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - 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('getOccurrence', () => { - it('invokes getOccurrence without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); - client.innerApiCalls.getOccurrence = stubSimpleCall(expectedResponse); - const [response] = await client.getOccurrence(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getOccurrence without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); - client.innerApiCalls.getOccurrence = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOccurrence( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.IOccurrence|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getOccurrence with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getOccurrence = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOccurrence(request), expectedError); - assert((client.innerApiCalls.getOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('deleteOccurrence', () => { - it('invokes deleteOccurrence without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteOccurrence = stubSimpleCall(expectedResponse); - const [response] = await client.deleteOccurrence(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteOccurrence without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteOccurrence = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteOccurrence( - 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.deleteOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteOccurrence with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteOccurrence = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteOccurrence(request), expectedError); - assert((client.innerApiCalls.deleteOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('createOccurrence', () => { - it('invokes createOccurrence without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateOccurrenceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); - client.innerApiCalls.createOccurrence = stubSimpleCall(expectedResponse); - const [response] = await client.createOccurrence(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createOccurrence without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateOccurrenceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); - client.innerApiCalls.createOccurrence = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createOccurrence( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.IOccurrence|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createOccurrence with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateOccurrenceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createOccurrence = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createOccurrence(request), expectedError); - assert((client.innerApiCalls.createOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('batchCreateOccurrences', () => { - it('invokes batchCreateOccurrences without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateOccurrencesResponse()); - client.innerApiCalls.batchCreateOccurrences = stubSimpleCall(expectedResponse); - const [response] = await client.batchCreateOccurrences(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchCreateOccurrences without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateOccurrencesResponse()); - client.innerApiCalls.batchCreateOccurrences = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchCreateOccurrences( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.IBatchCreateOccurrencesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchCreateOccurrences with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchCreateOccurrences = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchCreateOccurrences(request), expectedError); - assert((client.innerApiCalls.batchCreateOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('updateOccurrence', () => { - it('invokes updateOccurrence without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); - client.innerApiCalls.updateOccurrence = stubSimpleCall(expectedResponse); - const [response] = await client.updateOccurrence(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateOccurrence without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()); - client.innerApiCalls.updateOccurrence = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateOccurrence( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.IOccurrence|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateOccurrence with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateOccurrenceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateOccurrence = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateOccurrence(request), expectedError); - assert((client.innerApiCalls.updateOccurrence as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getOccurrenceNote', () => { - it('invokes getOccurrenceNote without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); - client.innerApiCalls.getOccurrenceNote = stubSimpleCall(expectedResponse); - const [response] = await client.getOccurrenceNote(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getOccurrenceNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getOccurrenceNote without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); - client.innerApiCalls.getOccurrenceNote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOccurrenceNote( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.INote|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getOccurrenceNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getOccurrenceNote with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetOccurrenceNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getOccurrenceNote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOccurrenceNote(request), expectedError); - assert((client.innerApiCalls.getOccurrenceNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getNote', () => { - it('invokes getNote without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); - client.innerApiCalls.getNote = stubSimpleCall(expectedResponse); - const [response] = await client.getNote(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getNote without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); - client.innerApiCalls.getNote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getNote( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.INote|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getNote with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getNote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getNote(request), expectedError); - assert((client.innerApiCalls.getNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('deleteNote', () => { - it('invokes deleteNote without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteNote = stubSimpleCall(expectedResponse); - const [response] = await client.deleteNote(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteNote without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteNote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteNote( - 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.deleteNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteNote with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.DeleteNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteNote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteNote(request), expectedError); - assert((client.innerApiCalls.deleteNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('createNote', () => { - it('invokes createNote without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateNoteRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); - client.innerApiCalls.createNote = stubSimpleCall(expectedResponse); - const [response] = await client.createNote(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createNote without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateNoteRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); - client.innerApiCalls.createNote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createNote( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.INote|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createNote with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.CreateNoteRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createNote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createNote(request), expectedError); - assert((client.innerApiCalls.createNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('batchCreateNotes', () => { - it('invokes batchCreateNotes without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateNotesResponse()); - client.innerApiCalls.batchCreateNotes = stubSimpleCall(expectedResponse); - const [response] = await client.batchCreateNotes(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchCreateNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchCreateNotes without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateNotesResponse()); - client.innerApiCalls.batchCreateNotes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchCreateNotes( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.IBatchCreateNotesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchCreateNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchCreateNotes with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.BatchCreateNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchCreateNotes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchCreateNotes(request), expectedError); - assert((client.innerApiCalls.batchCreateNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('updateNote', () => { - it('invokes updateNote without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); - client.innerApiCalls.updateNote = stubSimpleCall(expectedResponse); - const [response] = await client.updateNote(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateNote without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.Note()); - client.innerApiCalls.updateNote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateNote( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.INote|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateNote with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.UpdateNoteRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateNote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateNote(request), expectedError); - assert((client.innerApiCalls.updateNote as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getVulnerabilityOccurrencesSummary', () => { - it('invokes getVulnerabilityOccurrencesSummary without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetVulnerabilityOccurrencesSummaryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.VulnerabilityOccurrencesSummary()); - client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCall(expectedResponse); - const [response] = await client.getVulnerabilityOccurrencesSummary(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getVulnerabilityOccurrencesSummary without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetVulnerabilityOccurrencesSummaryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.grafeas.v1beta1.VulnerabilityOccurrencesSummary()); - client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getVulnerabilityOccurrencesSummary( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.IVulnerabilityOccurrencesSummary|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getVulnerabilityOccurrencesSummary with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.GetVulnerabilityOccurrencesSummaryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getVulnerabilityOccurrencesSummary = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getVulnerabilityOccurrencesSummary(request), expectedError); - assert((client.innerApiCalls.getVulnerabilityOccurrencesSummary as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('listOccurrences', () => { - it('invokes listOccurrences without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - ]; - client.innerApiCalls.listOccurrences = stubSimpleCall(expectedResponse); - const [response] = await client.listOccurrences(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listOccurrences without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - ]; - client.innerApiCalls.listOccurrences = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOccurrences( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.IOccurrence[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listOccurrences with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listOccurrences = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOccurrences(request), expectedError); - assert((client.innerApiCalls.listOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listOccurrencesStream without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - ]; - client.descriptors.page.listOccurrences.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOccurrencesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1beta1.Occurrence[] = []; - stream.on('data', (response: protos.grafeas.v1beta1.Occurrence) => { - 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.listOccurrences.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOccurrences, request)); - assert.strictEqual( - (client.descriptors.page.listOccurrences.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listOccurrencesStream with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listOccurrences.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOccurrencesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1beta1.Occurrence[] = []; - stream.on('data', (response: protos.grafeas.v1beta1.Occurrence) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOccurrences.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOccurrences, request)); - assert.strictEqual( - (client.descriptors.page.listOccurrences.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listOccurrences without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - ]; - client.descriptors.page.listOccurrences.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.grafeas.v1beta1.IOccurrence[] = []; - const iterable = client.listOccurrencesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listOccurrences with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListOccurrencesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listOccurrences.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOccurrencesAsync(request); - await assert.rejects(async () => { - const responses: protos.grafeas.v1beta1.IOccurrence[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listOccurrences.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listNotes', () => { - it('invokes listNotes without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - ]; - client.innerApiCalls.listNotes = stubSimpleCall(expectedResponse); - const [response] = await client.listNotes(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listNotes without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - ]; - client.innerApiCalls.listNotes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listNotes( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.INote[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listNotes with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listNotes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listNotes(request), expectedError); - assert((client.innerApiCalls.listNotes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listNotesStream without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - ]; - client.descriptors.page.listNotes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listNotesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1beta1.Note[] = []; - stream.on('data', (response: protos.grafeas.v1beta1.Note) => { - 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.listNotes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNotes, request)); - assert.strictEqual( - (client.descriptors.page.listNotes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listNotesStream with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listNotes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listNotesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1beta1.Note[] = []; - stream.on('data', (response: protos.grafeas.v1beta1.Note) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listNotes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNotes, request)); - assert.strictEqual( - (client.descriptors.page.listNotes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listNotes without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - generateSampleMessage(new protos.grafeas.v1beta1.Note()), - ]; - client.descriptors.page.listNotes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.grafeas.v1beta1.INote[] = []; - const iterable = client.listNotesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listNotes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listNotes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listNotes with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNotesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listNotes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listNotesAsync(request); - await assert.rejects(async () => { - const responses: protos.grafeas.v1beta1.INote[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listNotes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listNotes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listNoteOccurrences', () => { - it('invokes listNoteOccurrences without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - ]; - client.innerApiCalls.listNoteOccurrences = stubSimpleCall(expectedResponse); - const [response] = await client.listNoteOccurrences(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listNoteOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listNoteOccurrences without error using callback', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - ]; - client.innerApiCalls.listNoteOccurrences = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listNoteOccurrences( - request, - (err?: Error|null, result?: protos.grafeas.v1beta1.IOccurrence[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listNoteOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listNoteOccurrences with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listNoteOccurrences = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listNoteOccurrences(request), expectedError); - assert((client.innerApiCalls.listNoteOccurrences as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listNoteOccurrencesStream without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - ]; - client.descriptors.page.listNoteOccurrences.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listNoteOccurrencesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1beta1.Occurrence[] = []; - stream.on('data', (response: protos.grafeas.v1beta1.Occurrence) => { - 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.listNoteOccurrences.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNoteOccurrences, request)); - assert.strictEqual( - (client.descriptors.page.listNoteOccurrences.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listNoteOccurrencesStream with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedError = new Error('expected'); - client.descriptors.page.listNoteOccurrences.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listNoteOccurrencesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.grafeas.v1beta1.Occurrence[] = []; - stream.on('data', (response: protos.grafeas.v1beta1.Occurrence) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listNoteOccurrences.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNoteOccurrences, request)); - assert.strictEqual( - (client.descriptors.page.listNoteOccurrences.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listNoteOccurrences without error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name=";const expectedResponse = [ - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - generateSampleMessage(new protos.grafeas.v1beta1.Occurrence()), - ]; - client.descriptors.page.listNoteOccurrences.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.grafeas.v1beta1.IOccurrence[] = []; - const iterable = client.listNoteOccurrencesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listNoteOccurrences with error', async () => { - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.grafeas.v1beta1.ListNoteOccurrencesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); - client.descriptors.page.listNoteOccurrences.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listNoteOccurrencesAsync(request); - await assert.rejects(async () => { - const responses: protos.grafeas.v1beta1.IOccurrence[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listNoteOccurrences.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('scanConfig', () => { - const fakePath = "/rendered/path/scanConfig"; - const expectedParameters = { - project: "projectValue", - scan_config: "scanConfigValue", - }; - const client = new grafeasv1beta1Module.v1beta1.GrafeasV1Beta1Client({ - 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)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1beta1/tsconfig.json b/owl-bot-staging/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c8..0000000 --- a/owl-bot-staging/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1beta1/webpack.config.js b/owl-bot-staging/v1beta1/webpack.config.js deleted file mode 100644 index f9beacf..0000000 --- a/owl-bot-staging/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'containeranalysis', - filename: './containeranalysis.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/src/v1/container_analysis_client.ts b/src/v1/container_analysis_client.ts index 56284b0..98099fa 100644 --- a/src/v1/container_analysis_client.ts +++ b/src/v1/container_analysis_client.ts @@ -302,7 +302,7 @@ export class ContainerAnalysisClient { // -- Service calls -- // ------------------- setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, + request?: protos.google.iam.v1.ISetIamPolicyRequest, options?: CallOptions ): Promise< [ @@ -359,7 +359,7 @@ export class ContainerAnalysisClient { * const [response] = await client.setIamPolicy(request); */ setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, + request?: protos.google.iam.v1.ISetIamPolicyRequest, optionsOrCallback?: | CallOptions | Callback< @@ -398,7 +398,7 @@ export class ContainerAnalysisClient { return this.innerApiCalls.setIamPolicy(request, options, callback); } getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, + request?: protos.google.iam.v1.IGetIamPolicyRequest, options?: CallOptions ): Promise< [ @@ -453,7 +453,7 @@ export class ContainerAnalysisClient { * const [response] = await client.getIamPolicy(request); */ getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, + request?: protos.google.iam.v1.IGetIamPolicyRequest, optionsOrCallback?: | CallOptions | Callback< @@ -492,7 +492,7 @@ export class ContainerAnalysisClient { return this.innerApiCalls.getIamPolicy(request, options, callback); } testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, + request?: protos.google.iam.v1.ITestIamPermissionsRequest, options?: CallOptions ): Promise< [ @@ -548,7 +548,7 @@ export class ContainerAnalysisClient { * const [response] = await client.testIamPermissions(request); */ testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, + request?: protos.google.iam.v1.ITestIamPermissionsRequest, optionsOrCallback?: | CallOptions | Callback< @@ -587,7 +587,7 @@ export class ContainerAnalysisClient { return this.innerApiCalls.testIamPermissions(request, options, callback); } getVulnerabilityOccurrencesSummary( - request: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, + request?: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, options?: CallOptions ): Promise< [ @@ -641,7 +641,7 @@ export class ContainerAnalysisClient { * const [response] = await client.getVulnerabilityOccurrencesSummary(request); */ getVulnerabilityOccurrencesSummary( - request: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, + request?: protos.google.devtools.containeranalysis.v1.IGetVulnerabilityOccurrencesSummaryRequest, optionsOrCallback?: | CallOptions | Callback< diff --git a/src/v1beta1/container_analysis_v1_beta1_client.ts b/src/v1beta1/container_analysis_v1_beta1_client.ts index b4ee7b6..f959e41 100644 --- a/src/v1beta1/container_analysis_v1_beta1_client.ts +++ b/src/v1beta1/container_analysis_v1_beta1_client.ts @@ -321,7 +321,7 @@ export class ContainerAnalysisV1Beta1Client { // -- Service calls -- // ------------------- setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, + request?: protos.google.iam.v1.ISetIamPolicyRequest, options?: CallOptions ): Promise< [ @@ -378,7 +378,7 @@ export class ContainerAnalysisV1Beta1Client { * const [response] = await client.setIamPolicy(request); */ setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, + request?: protos.google.iam.v1.ISetIamPolicyRequest, optionsOrCallback?: | CallOptions | Callback< @@ -417,7 +417,7 @@ export class ContainerAnalysisV1Beta1Client { return this.innerApiCalls.setIamPolicy(request, options, callback); } getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, + request?: protos.google.iam.v1.IGetIamPolicyRequest, options?: CallOptions ): Promise< [ @@ -472,7 +472,7 @@ export class ContainerAnalysisV1Beta1Client { * const [response] = await client.getIamPolicy(request); */ getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, + request?: protos.google.iam.v1.IGetIamPolicyRequest, optionsOrCallback?: | CallOptions | Callback< @@ -511,7 +511,7 @@ export class ContainerAnalysisV1Beta1Client { return this.innerApiCalls.getIamPolicy(request, options, callback); } testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, + request?: protos.google.iam.v1.ITestIamPermissionsRequest, options?: CallOptions ): Promise< [ @@ -567,7 +567,7 @@ export class ContainerAnalysisV1Beta1Client { * const [response] = await client.testIamPermissions(request); */ testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, + request?: protos.google.iam.v1.ITestIamPermissionsRequest, optionsOrCallback?: | CallOptions | Callback< @@ -606,7 +606,7 @@ export class ContainerAnalysisV1Beta1Client { return this.innerApiCalls.testIamPermissions(request, options, callback); } getScanConfig( - request: protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, + request?: protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, options?: CallOptions ): Promise< [ @@ -658,7 +658,7 @@ export class ContainerAnalysisV1Beta1Client { * const [response] = await client.getScanConfig(request); */ getScanConfig( - request: protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, + request?: protos.google.devtools.containeranalysis.v1beta1.IGetScanConfigRequest, optionsOrCallback?: | CallOptions | Callback< @@ -704,7 +704,7 @@ export class ContainerAnalysisV1Beta1Client { return this.innerApiCalls.getScanConfig(request, options, callback); } updateScanConfig( - request: protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, + request?: protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, options?: CallOptions ): Promise< [ @@ -758,7 +758,7 @@ export class ContainerAnalysisV1Beta1Client { * const [response] = await client.updateScanConfig(request); */ updateScanConfig( - request: protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, + request?: protos.google.devtools.containeranalysis.v1beta1.IUpdateScanConfigRequest, optionsOrCallback?: | CallOptions | Callback< @@ -805,7 +805,7 @@ export class ContainerAnalysisV1Beta1Client { } listScanConfigs( - request: protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, + request?: protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, options?: CallOptions ): Promise< [ @@ -863,7 +863,7 @@ export class ContainerAnalysisV1Beta1Client { * for more details and examples. */ listScanConfigs( - request: protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, + request?: protos.google.devtools.containeranalysis.v1beta1.IListScanConfigsRequest, optionsOrCallback?: | CallOptions | PaginationCallback< diff --git a/src/v1beta1/grafeas_v1_beta1_client.ts b/src/v1beta1/grafeas_v1_beta1_client.ts index 7dc20c8..2409431 100644 --- a/src/v1beta1/grafeas_v1_beta1_client.ts +++ b/src/v1beta1/grafeas_v1_beta1_client.ts @@ -336,7 +336,7 @@ export class GrafeasV1Beta1Client { // -- Service calls -- // ------------------- getOccurrence( - request: protos.grafeas.v1beta1.IGetOccurrenceRequest, + request?: protos.grafeas.v1beta1.IGetOccurrenceRequest, options?: CallOptions ): Promise< [ @@ -381,7 +381,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.getOccurrence(request); */ getOccurrence( - request: protos.grafeas.v1beta1.IGetOccurrenceRequest, + request?: protos.grafeas.v1beta1.IGetOccurrenceRequest, optionsOrCallback?: | CallOptions | Callback< @@ -420,7 +420,7 @@ export class GrafeasV1Beta1Client { return this.innerApiCalls.getOccurrence(request, options, callback); } deleteOccurrence( - request: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, + request?: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, options?: CallOptions ): Promise< [ @@ -467,7 +467,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.deleteOccurrence(request); */ deleteOccurrence( - request: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, + request?: protos.grafeas.v1beta1.IDeleteOccurrenceRequest, optionsOrCallback?: | CallOptions | Callback< @@ -506,7 +506,7 @@ export class GrafeasV1Beta1Client { return this.innerApiCalls.deleteOccurrence(request, options, callback); } createOccurrence( - request: protos.grafeas.v1beta1.ICreateOccurrenceRequest, + request?: protos.grafeas.v1beta1.ICreateOccurrenceRequest, options?: CallOptions ): Promise< [ @@ -553,7 +553,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.createOccurrence(request); */ createOccurrence( - request: protos.grafeas.v1beta1.ICreateOccurrenceRequest, + request?: protos.grafeas.v1beta1.ICreateOccurrenceRequest, optionsOrCallback?: | CallOptions | Callback< @@ -592,7 +592,7 @@ export class GrafeasV1Beta1Client { return this.innerApiCalls.createOccurrence(request, options, callback); } batchCreateOccurrences( - request: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, + request?: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, options?: CallOptions ): Promise< [ @@ -639,7 +639,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.batchCreateOccurrences(request); */ batchCreateOccurrences( - request: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, + request?: protos.grafeas.v1beta1.IBatchCreateOccurrencesRequest, optionsOrCallback?: | CallOptions | Callback< @@ -684,7 +684,7 @@ export class GrafeasV1Beta1Client { ); } updateOccurrence( - request: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, + request?: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, options?: CallOptions ): Promise< [ @@ -733,7 +733,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.updateOccurrence(request); */ updateOccurrence( - request: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, + request?: protos.grafeas.v1beta1.IUpdateOccurrenceRequest, optionsOrCallback?: | CallOptions | Callback< @@ -772,7 +772,7 @@ export class GrafeasV1Beta1Client { return this.innerApiCalls.updateOccurrence(request, options, callback); } getOccurrenceNote( - request: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, + request?: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, options?: CallOptions ): Promise< [ @@ -818,7 +818,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.getOccurrenceNote(request); */ getOccurrenceNote( - request: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, + request?: protos.grafeas.v1beta1.IGetOccurrenceNoteRequest, optionsOrCallback?: | CallOptions | Callback< @@ -857,7 +857,7 @@ export class GrafeasV1Beta1Client { return this.innerApiCalls.getOccurrenceNote(request, options, callback); } getNote( - request: protos.grafeas.v1beta1.IGetNoteRequest, + request?: protos.grafeas.v1beta1.IGetNoteRequest, options?: CallOptions ): Promise< [ @@ -902,7 +902,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.getNote(request); */ getNote( - request: protos.grafeas.v1beta1.IGetNoteRequest, + request?: protos.grafeas.v1beta1.IGetNoteRequest, optionsOrCallback?: | CallOptions | Callback< @@ -941,7 +941,7 @@ export class GrafeasV1Beta1Client { return this.innerApiCalls.getNote(request, options, callback); } deleteNote( - request: protos.grafeas.v1beta1.IDeleteNoteRequest, + request?: protos.grafeas.v1beta1.IDeleteNoteRequest, options?: CallOptions ): Promise< [ @@ -986,7 +986,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.deleteNote(request); */ deleteNote( - request: protos.grafeas.v1beta1.IDeleteNoteRequest, + request?: protos.grafeas.v1beta1.IDeleteNoteRequest, optionsOrCallback?: | CallOptions | Callback< @@ -1025,7 +1025,7 @@ export class GrafeasV1Beta1Client { return this.innerApiCalls.deleteNote(request, options, callback); } createNote( - request: protos.grafeas.v1beta1.ICreateNoteRequest, + request?: protos.grafeas.v1beta1.ICreateNoteRequest, options?: CallOptions ): Promise< [ @@ -1074,7 +1074,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.createNote(request); */ createNote( - request: protos.grafeas.v1beta1.ICreateNoteRequest, + request?: protos.grafeas.v1beta1.ICreateNoteRequest, optionsOrCallback?: | CallOptions | Callback< @@ -1113,7 +1113,7 @@ export class GrafeasV1Beta1Client { return this.innerApiCalls.createNote(request, options, callback); } batchCreateNotes( - request: protos.grafeas.v1beta1.IBatchCreateNotesRequest, + request?: protos.grafeas.v1beta1.IBatchCreateNotesRequest, options?: CallOptions ): Promise< [ @@ -1160,7 +1160,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.batchCreateNotes(request); */ batchCreateNotes( - request: protos.grafeas.v1beta1.IBatchCreateNotesRequest, + request?: protos.grafeas.v1beta1.IBatchCreateNotesRequest, optionsOrCallback?: | CallOptions | Callback< @@ -1199,7 +1199,7 @@ export class GrafeasV1Beta1Client { return this.innerApiCalls.batchCreateNotes(request, options, callback); } updateNote( - request: protos.grafeas.v1beta1.IUpdateNoteRequest, + request?: protos.grafeas.v1beta1.IUpdateNoteRequest, options?: CallOptions ): Promise< [ @@ -1248,7 +1248,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.updateNote(request); */ updateNote( - request: protos.grafeas.v1beta1.IUpdateNoteRequest, + request?: protos.grafeas.v1beta1.IUpdateNoteRequest, optionsOrCallback?: | CallOptions | Callback< @@ -1287,7 +1287,7 @@ export class GrafeasV1Beta1Client { return this.innerApiCalls.updateNote(request, options, callback); } getVulnerabilityOccurrencesSummary( - request: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, + request?: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, options?: CallOptions ): Promise< [ @@ -1341,7 +1341,7 @@ export class GrafeasV1Beta1Client { * const [response] = await client.getVulnerabilityOccurrencesSummary(request); */ getVulnerabilityOccurrencesSummary( - request: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, + request?: protos.grafeas.v1beta1.IGetVulnerabilityOccurrencesSummaryRequest, optionsOrCallback?: | CallOptions | Callback< @@ -1392,7 +1392,7 @@ export class GrafeasV1Beta1Client { } listOccurrences( - request: protos.grafeas.v1beta1.IListOccurrencesRequest, + request?: protos.grafeas.v1beta1.IListOccurrencesRequest, options?: CallOptions ): Promise< [ @@ -1446,7 +1446,7 @@ export class GrafeasV1Beta1Client { * for more details and examples. */ listOccurrences( - request: protos.grafeas.v1beta1.IListOccurrencesRequest, + request?: protos.grafeas.v1beta1.IListOccurrencesRequest, optionsOrCallback?: | CallOptions | PaginationCallback< @@ -1584,7 +1584,7 @@ export class GrafeasV1Beta1Client { ) as AsyncIterable; } listNotes( - request: protos.grafeas.v1beta1.IListNotesRequest, + request?: protos.grafeas.v1beta1.IListNotesRequest, options?: CallOptions ): Promise< [ @@ -1638,7 +1638,7 @@ export class GrafeasV1Beta1Client { * for more details and examples. */ listNotes( - request: protos.grafeas.v1beta1.IListNotesRequest, + request?: protos.grafeas.v1beta1.IListNotesRequest, optionsOrCallback?: | CallOptions | PaginationCallback< @@ -1776,7 +1776,7 @@ export class GrafeasV1Beta1Client { ) as AsyncIterable; } listNoteOccurrences( - request: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + request?: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, options?: CallOptions ): Promise< [ @@ -1832,7 +1832,7 @@ export class GrafeasV1Beta1Client { * for more details and examples. */ listNoteOccurrences( - request: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, + request?: protos.grafeas.v1beta1.IListNoteOccurrencesRequest, optionsOrCallback?: | CallOptions | PaginationCallback<