From 46292cdd5298bef165a6de7289725b1f6da9fc1f Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 16 Jul 2021 10:20:31 +0000 Subject: [PATCH 1/2] fix: Updating WORKSPACE files to use the newest version of the Typescript generator. Also removing the explicit generator tag for the IAMPolicy mixin for the kms and pubsub APIS as the generator will now read it from the .yaml file. PiperOrigin-RevId: 385101839 Source-Link: https://github.com/googleapis/googleapis/commit/80f404215a9346259db760d80d0671f28c433453 Source-Link: https://github.com/googleapis/googleapis-gen/commit/d3509d2520fb8db862129633f1cf8406d17454e1 --- owl-bot-staging/v1beta1/.eslintignore | 6 + owl-bot-staging/v1beta1/.eslintrc.json | 3 + owl-bot-staging/v1beta1/.gitignore | 14 + owl-bot-staging/v1beta1/.jsdoc.js | 55 + owl-bot-staging/v1beta1/.mocharc.js | 33 + owl-bot-staging/v1beta1/.prettierrc.js | 22 + owl-bot-staging/v1beta1/README.md | 1 + .../v1beta1/linkinator.config.json | 10 + owl-bot-staging/v1beta1/package.json | 64 + .../continuous_validation_logging.proto | 97 ++ .../v1beta1/resources.proto | 330 +++++ .../binaryauthorization/v1beta1/service.proto | 257 ++++ owl-bot-staging/v1beta1/src/index.ts | 25 + ...uthz_management_service_v1_beta1_client.ts | 1081 +++++++++++++++++ ...gement_service_v1_beta1_client_config.json | 61 + ...anagement_service_v1_beta1_proto_list.json | 5 + .../v1beta1/src/v1beta1/gapic_metadata.json | 97 ++ owl-bot-staging/v1beta1/src/v1beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + ...thz_management_service_v1_beta1_v1beta1.ts | 1000 +++++++++++++++ owl-bot-staging/v1beta1/tsconfig.json | 19 + owl-bot-staging/v1beta1/webpack.config.js | 64 + 24 files changed, 3371 insertions(+) create mode 100644 owl-bot-staging/v1beta1/.eslintignore create mode 100644 owl-bot-staging/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1beta1/.gitignore create mode 100644 owl-bot-staging/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1beta1/README.md create mode 100644 owl-bot-staging/v1beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1beta1/package.json create mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/continuous_validation_logging.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/resources.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/service.proto create mode 100644 owl-bot-staging/v1beta1/src/index.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client_config.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_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/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_binauthz_management_service_v1_beta1_v1beta1.ts create mode 100644 owl-bot-staging/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/v1beta1/webpack.config.js diff --git a/owl-bot-staging/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..eb5f5af --- /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/binary-authorization', + 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..438dbbe --- /dev/null +++ b/owl-bot-staging/v1beta1/README.md @@ -0,0 +1 @@ +Binaryauthorization: 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..08ae768 --- /dev/null +++ b/owl-bot-staging/v1beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/binary-authorization", + "version": "0.1.0", + "description": "Binaryauthorization client for Node.js", + "repository": "googleapis/nodejs-binaryauthorization", + "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 binaryauthorization", + "binaryauthorization", + "binauthz management service v1 beta1" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.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/cloud/binaryauthorization/v1beta1/continuous_validation_logging.proto b/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/continuous_validation_logging.proto new file mode 100644 index 0000000..4f7bfdd --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/continuous_validation_logging.proto @@ -0,0 +1,97 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.binaryauthorization.v1beta1; + +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.BinaryAuthorization.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/binaryauthorization/v1beta1;binaryauthorization"; +option java_multiple_files = true; +option java_outer_classname = "ContinuousValidationLoggingProto"; +option java_package = "com.google.cloud.binaryauthorization.v1beta1"; +option php_namespace = "Google\\Cloud\\BinaryAuthorization\\V1beta1"; +option ruby_package = "Google::Cloud::BinaryAuthorization::V1beta1"; + +// Represents an auditing event from Continuous Validation. +message ContinuousValidationEvent { + // An auditing event for one Pod. + message ContinuousValidationPodEvent { + // Container image with auditing details. + message ImageDetails { + // Result of the audit. + enum AuditResult { + // Unspecified result. This is an error. + AUDIT_RESULT_UNSPECIFIED = 0; + + // Image is allowed. + ALLOW = 1; + + // Image is denied. + DENY = 2; + } + + // The name of the image. + string image = 1; + + // The result of the audit for this image. + AuditResult result = 2; + + // Description of the above result. + string description = 3; + } + + // Audit time policy conformance verdict. + enum PolicyConformanceVerdict { + // We should always have a verdict. This is an error. + POLICY_CONFORMANCE_VERDICT_UNSPECIFIED = 0; + + // The pod violates the policy. + VIOLATES_POLICY = 1; + } + + // The name of the Pod. + string pod = 1; + + // Deploy time of the Pod from k8s. + google.protobuf.Timestamp deploy_time = 2; + + // Termination time of the Pod from k8s, or nothing if still running. + google.protobuf.Timestamp end_time = 3; + + // Auditing verdict for this Pod. + PolicyConformanceVerdict verdict = 4; + + // List of images with auditing details. + repeated ImageDetails images = 5; + } + + // An event describing that the project policy is unsupported by CV. + message UnsupportedPolicyEvent { + // A description of the unsupported policy. + string description = 1; + } + + // Type of CV event. + oneof event_type { + // Pod event. + ContinuousValidationPodEvent pod_event = 1; + + // Unsupported policy event. + UnsupportedPolicyEvent unsupported_policy_event = 2; + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/resources.proto b/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/resources.proto new file mode 100644 index 0000000..ea674a7 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/resources.proto @@ -0,0 +1,330 @@ +// Copyright 2021 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.cloud.binaryauthorization.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.BinaryAuthorization.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/binaryauthorization/v1beta1;binaryauthorization"; +option java_multiple_files = true; +option java_outer_classname = "BinaryAuthorizationResourcesProto"; +option java_package = "com.google.cloud.binaryauthorization.v1beta1"; +option php_namespace = "Google\\Cloud\\BinaryAuthorization\\V1beta1"; +option ruby_package = "Google::Cloud::BinaryAuthorization::V1beta1"; + +// A [policy][google.cloud.binaryauthorization.v1beta1.Policy] for container +// image binary authorization. +message Policy { + option (google.api.resource) = { + type: "binaryauthorization.googleapis.com/Policy" + pattern: "projects/{project}/policy" + }; + + enum GlobalPolicyEvaluationMode { + // Not specified: DISABLE is assumed. + GLOBAL_POLICY_EVALUATION_MODE_UNSPECIFIED = 0; + + // Enables global policy evaluation. + ENABLE = 1; + + // Disables global policy evaluation. + DISABLE = 2; + } + + // Output only. The resource name, in the format `projects/*/policy`. There is + // at most one policy per project. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. A descriptive comment. + string description = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Controls the evaluation of a Google-maintained global admission + // policy for common system-level images. Images not covered by the global + // policy will be subject to the project admission policy. This setting + // has no effect when specified inside a global admission policy. + GlobalPolicyEvaluationMode global_policy_evaluation_mode = 7 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Admission policy allowlisting. A matching admission request will + // always be permitted. This feature is typically used to exclude Google or + // third-party infrastructure images from Binary Authorization policies. + repeated AdmissionWhitelistPattern admission_whitelist_patterns = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Per-cluster admission rules. Cluster spec format: + // `location.clusterId`. There can be at most one admission rule per cluster + // spec. + // A `location` is either a compute zone (e.g. us-central1-a) or a region + // (e.g. us-central1). + // For `clusterId` syntax restrictions see + // https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters. + map cluster_admission_rules = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Required. Default admission rule for a cluster without a per-cluster, per- + // kubernetes-service-account, or per-istio-service-identity admission rule. + AdmissionRule default_admission_rule = 4 + [(google.api.field_behavior) = REQUIRED]; + + // Output only. Time when the policy was last updated. + google.protobuf.Timestamp update_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// An [admission allowlist +// pattern][google.cloud.binaryauthorization.v1beta1.AdmissionWhitelistPattern] +// exempts images from checks by [admission +// rules][google.cloud.binaryauthorization.v1beta1.AdmissionRule]. +message AdmissionWhitelistPattern { + // An image name pattern to allow, in the form `registry/path/to/image`. + // This supports a trailing `*` as a wildcard, but this is allowed only in + // text after the `registry/` part. + string name_pattern = 1; +} + +// An [admission rule][google.cloud.binaryauthorization.v1beta1.AdmissionRule] +// specifies either that all container images used in a pod creation request +// must be attested to by one or more +// [attestors][google.cloud.binaryauthorization.v1beta1.Attestor], that all pod +// creations will be allowed, or that all pod creations will be denied. +// +// Images matching an [admission allowlist +// pattern][google.cloud.binaryauthorization.v1beta1.AdmissionWhitelistPattern] +// are exempted from admission rules and will never block a pod creation. +message AdmissionRule { + enum EvaluationMode { + // Do not use. + EVALUATION_MODE_UNSPECIFIED = 0; + + // This rule allows all all pod creations. + ALWAYS_ALLOW = 1; + + // This rule allows a pod creation if all the attestors listed in + // 'require_attestations_by' have valid attestations for all of the + // images in the pod spec. + REQUIRE_ATTESTATION = 2; + + // This rule denies all pod creations. + ALWAYS_DENY = 3; + } + + // Defines the possible actions when a pod creation is denied by an admission + // rule. + enum EnforcementMode { + // Do not use. + ENFORCEMENT_MODE_UNSPECIFIED = 0; + + // Enforce the admission rule by blocking the pod creation. + ENFORCED_BLOCK_AND_AUDIT_LOG = 1; + + // Dryrun mode: Audit logging only. This will allow the pod creation as if + // the admission request had specified break-glass. + DRYRUN_AUDIT_LOG_ONLY = 2; + } + + // Required. How this admission rule will be evaluated. + EvaluationMode evaluation_mode = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The resource names of the attestors that must attest to + // a container image, in the format `projects/*/attestors/*`. Each + // attestor must exist before a policy can reference it. To add an attestor + // to a policy the principal issuing the policy change request must be able + // to read the attestor resource. + // + // Note: this field must be non-empty when the evaluation_mode field specifies + // REQUIRE_ATTESTATION, otherwise it must be empty. + repeated string require_attestations_by = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Required. The action when a pod creation is denied by the admission rule. + EnforcementMode enforcement_mode = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// An [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] that attests +// to container image artifacts. An existing attestor cannot be modified except +// where indicated. +message Attestor { + option (google.api.resource) = { + type: "binaryauthorization.googleapis.com/Attestor" + pattern: "projects/{project}/attestors/{attestor}" + }; + + // Required. The resource name, in the format: + // `projects/*/attestors/*`. This field may not be updated. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. A descriptive comment. This field may be updated. + // The field may be displayed in chooser dialogs. + string description = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Identifies an + // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] that attests + // to a container image artifact. This determines how an attestation will be + // stored, and how it will be used during policy enforcement. Updates may not + // change the attestor type, but individual attestor fields may be updated + oneof attestor_type { + // A Drydock ATTESTATION_AUTHORITY Note, created by the user. + UserOwnedDrydockNote user_owned_drydock_note = 3; + } + + // Output only. Time when the attestor was last updated. + google.protobuf.Timestamp update_time = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// An [user owned drydock +// note][google.cloud.binaryauthorization.v1beta1.UserOwnedDrydockNote] +// references a Drydock ATTESTATION_AUTHORITY Note created by the user. +message UserOwnedDrydockNote { + // Required. The Drydock resource name of a ATTESTATION_AUTHORITY Note, + // created by the user, in the format: `projects/*/notes/*` (or the legacy + // `providers/*/notes/*`). This field may not be updated. + // + // An attestation by this attestor is stored as a Drydock + // ATTESTATION_AUTHORITY Occurrence that names a container image and that + // links to this Note. Drydock is an external dependency. + string note_reference = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Public keys that verify attestations signed by this + // attestor. This field may be updated. + // + // If this field is non-empty, one of the specified public keys must + // verify that an attestation was signed by this attestor for the + // image specified in the admission request. + // + // If this field is empty, this attestor always returns that no + // valid attestations exist. + repeated AttestorPublicKey public_keys = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. This field will contain the service account email address + // that this Attestor will use as the principal when querying Container + // Analysis. Attestor administrators must grant this service account the + // IAM role needed to read attestations from the [note_reference][Note] in + // Container Analysis (`containeranalysis.notes.occurrences.viewer`). + // + // This email address is fixed for the lifetime of the Attestor, but callers + // should not make any other assumptions about the service account email; + // future versions may use an email based on a different naming pattern. + string delegation_service_account_email = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A public key in the PkixPublicKey format (see +// https://tools.ietf.org/html/rfc5280#section-4.1.2.7 for details). +// Public keys of this type are typically textually encoded using the PEM +// format. +message PkixPublicKey { + // Represents a signature algorithm and other information necessary to verify + // signatures with a given public key. + // This is based primarily on the public key types supported by Tink's + // PemKeyType, which is in turn based on KMS's supported signing algorithms. + // See https://cloud.google.com/kms/docs/algorithms. In the future, BinAuthz + // might support additional public key types independently of Tink and/or KMS. + enum SignatureAlgorithm { + // Not specified. + SIGNATURE_ALGORITHM_UNSPECIFIED = 0; + + // RSASSA-PSS 2048 bit key with a SHA256 digest. + RSA_PSS_2048_SHA256 = 1; + + // RSASSA-PSS 3072 bit key with a SHA256 digest. + RSA_PSS_3072_SHA256 = 2; + + // RSASSA-PSS 4096 bit key with a SHA256 digest. + RSA_PSS_4096_SHA256 = 3; + + // RSASSA-PSS 4096 bit key with a SHA512 digest. + RSA_PSS_4096_SHA512 = 4; + + // RSASSA-PKCS1-v1_5 with a 2048 bit key and a SHA256 digest. + RSA_SIGN_PKCS1_2048_SHA256 = 5; + + // RSASSA-PKCS1-v1_5 with a 3072 bit key and a SHA256 digest. + RSA_SIGN_PKCS1_3072_SHA256 = 6; + + // RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA256 digest. + RSA_SIGN_PKCS1_4096_SHA256 = 7; + + // RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA512 digest. + RSA_SIGN_PKCS1_4096_SHA512 = 8; + + // ECDSA on the NIST P-256 curve with a SHA256 digest. + ECDSA_P256_SHA256 = 9; + + // ECDSA on the NIST P-384 curve with a SHA384 digest. + ECDSA_P384_SHA384 = 10; + + // ECDSA on the NIST P-521 curve with a SHA512 digest. + ECDSA_P521_SHA512 = 11; + } + + // A PEM-encoded public key, as described in + // https://tools.ietf.org/html/rfc7468#section-13 + string public_key_pem = 1; + + // The signature algorithm used to verify a message against a signature using + // this key. + // These signature algorithm must match the structure and any object + // identifiers encoded in `public_key_pem` (i.e. this algorithm must match + // that of the public key). + SignatureAlgorithm signature_algorithm = 2; +} + +// An [attestor public +// key][google.cloud.binaryauthorization.v1beta1.AttestorPublicKey] that will be +// used to verify attestations signed by this attestor. +message AttestorPublicKey { + // Optional. A descriptive comment. This field may be updated. + string comment = 1 [(google.api.field_behavior) = OPTIONAL]; + + // The ID of this public key. + // Signatures verified by BinAuthz must include the ID of the public key that + // can be used to verify them, and that ID must match the contents of this + // field exactly. + // Additional restrictions on this field can be imposed based on which public + // key type is encapsulated. See the documentation on `public_key` cases below + // for details. + string id = 2; + + // Required. A public key reference or serialized instance. This field may be + // updated. + oneof public_key { + // ASCII-armored representation of a PGP public key, as the entire output by + // the command `gpg --export --armor foo@example.com` (either LF or CRLF + // line endings). + // When using this field, `id` should be left blank. The BinAuthz API + // handlers will calculate the ID and fill it in automatically. BinAuthz + // computes this ID as the OpenPGP RFC4880 V4 fingerprint, represented as + // upper-case hex. If `id` is provided by the caller, it will be + // overwritten by the API-calculated ID. + string ascii_armored_pgp_public_key = 3; + + // A raw PKIX SubjectPublicKeyInfo format public key. + // + // NOTE: `id` may be explicitly provided by the caller when using this + // type of public key, but it MUST be a valid RFC3986 URI. If `id` is left + // blank, a default one will be computed based on the digest of the DER + // encoding of the public key. + PkixPublicKey pkix_public_key = 5; + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/service.proto b/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/service.proto new file mode 100644 index 0000000..3f6c5ab --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/service.proto @@ -0,0 +1,257 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.cloud.binaryauthorization.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/binaryauthorization/v1beta1/resources.proto"; +import "google/protobuf/empty.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.BinaryAuthorization.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/binaryauthorization/v1beta1;binaryauthorization"; +option java_multiple_files = true; +option java_outer_classname = "BinaryAuthorizationServiceProto"; +option java_package = "com.google.cloud.binaryauthorization.v1beta1"; +option php_namespace = "Google\\Cloud\\BinaryAuthorization\\V1beta1"; +option ruby_package = "Google::Cloud::BinaryAuthorization::V1beta1"; + +// Customer-facing API for Cloud Binary Authorization. + +// Google Cloud Management Service for Binary Authorization admission policies +// and attestation authorities. +// +// This API implements a REST model with the following objects: +// +// * [Policy][google.cloud.binaryauthorization.v1beta1.Policy] +// * [Attestor][google.cloud.binaryauthorization.v1beta1.Attestor] +service BinauthzManagementServiceV1Beta1 { + option (google.api.default_host) = "binaryauthorization.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // A [policy][google.cloud.binaryauthorization.v1beta1.Policy] specifies the + // [attestors][google.cloud.binaryauthorization.v1beta1.Attestor] that must + // attest to a container image, before the project is allowed to deploy that + // image. There is at most one policy per project. All image admission + // requests are permitted if a project has no policy. + // + // Gets the [policy][google.cloud.binaryauthorization.v1beta1.Policy] for this + // project. Returns a default + // [policy][google.cloud.binaryauthorization.v1beta1.Policy] if the project + // does not have one. + rpc GetPolicy(GetPolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/policy}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates or updates a project's + // [policy][google.cloud.binaryauthorization.v1beta1.Policy], and returns a + // copy of the new [policy][google.cloud.binaryauthorization.v1beta1.Policy]. + // A policy is always updated as a whole, to avoid race conditions with + // concurrent policy enforcement (or management!) requests. Returns NOT_FOUND + // if the project does not exist, INVALID_ARGUMENT if the request is + // malformed. + rpc UpdatePolicy(UpdatePolicyRequest) returns (Policy) { + option (google.api.http) = { + put: "/v1beta1/{policy.name=projects/*/policy}" + body: "policy" + }; + option (google.api.method_signature) = "policy"; + } + + // Creates an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor], + // and returns a copy of the new + // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. Returns + // NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is + // malformed, ALREADY_EXISTS if the + // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] already + // exists. + rpc CreateAttestor(CreateAttestorRequest) returns (Attestor) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*}/attestors" + body: "attestor" + }; + option (google.api.method_signature) = "parent,attestor_id,attestor"; + } + + // Gets an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. + // Returns NOT_FOUND if the + // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not + // exist. + rpc GetAttestor(GetAttestorRequest) returns (Attestor) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/attestors/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. + // Returns NOT_FOUND if the + // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not + // exist. + rpc UpdateAttestor(UpdateAttestorRequest) returns (Attestor) { + option (google.api.http) = { + put: "/v1beta1/{attestor.name=projects/*/attestors/*}" + body: "attestor" + }; + option (google.api.method_signature) = "attestor"; + } + + // Lists [attestors][google.cloud.binaryauthorization.v1beta1.Attestor]. + // Returns INVALID_ARGUMENT if the project does not exist. + rpc ListAttestors(ListAttestorsRequest) returns (ListAttestorsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*}/attestors" + }; + option (google.api.method_signature) = "parent"; + } + + // Deletes an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. + // Returns NOT_FOUND if the + // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not + // exist. + rpc DeleteAttestor(DeleteAttestorRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/attestors/*}" + }; + option (google.api.method_signature) = "name"; + } +} + +// Request message for [BinauthzManagementService.GetPolicy][]. +message GetPolicyRequest { + // Required. The resource name of the + // [policy][google.cloud.binaryauthorization.v1beta1.Policy] to retrieve, in + // the format `projects/*/policy`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "binaryauthorization.googleapis.com/Policy" + } + ]; +} + +// Request message for [BinauthzManagementService.UpdatePolicy][]. +message UpdatePolicyRequest { + // Required. A new or updated + // [policy][google.cloud.binaryauthorization.v1beta1.Policy] value. The + // service will overwrite the [policy + // name][google.cloud.binaryauthorization.v1beta1.Policy.name] field with the + // resource name in the request URL, in the format `projects/*/policy`. + Policy policy = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for [BinauthzManagementService.CreateAttestor][]. +message CreateAttestorRequest { + // Required. The parent of this + // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The + // [attestors][google.cloud.binaryauthorization.v1beta1.Attestor] ID. + string attestor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The initial + // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] value. The + // service will overwrite the [attestor + // name][google.cloud.binaryauthorization.v1beta1.Attestor.name] field with + // the resource name, in the format `projects/*/attestors/*`. + Attestor attestor = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for [BinauthzManagementService.GetAttestor][]. +message GetAttestorRequest { + // Required. The name of the + // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] to retrieve, + // in the format `projects/*/attestors/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "binaryauthorization.googleapis.com/Attestor" + } + ]; +} + +// Request message for [BinauthzManagementService.UpdateAttestor][]. +message UpdateAttestorRequest { + // Required. The updated + // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] value. The + // service will overwrite the [attestor + // name][google.cloud.binaryauthorization.v1beta1.Attestor.name] field with + // the resource name in the request URL, in the format + // `projects/*/attestors/*`. + Attestor attestor = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for [BinauthzManagementService.ListAttestors][]. +message ListAttestorsRequest { + // Required. The resource name of the project associated with the + // [attestors][google.cloud.binaryauthorization.v1beta1.Attestor], in the + // format `projects/*`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Requested page size. The server may return fewer results than requested. If + // unspecified, the server will pick an appropriate default. + int32 page_size = 2; + + // A token identifying a page of results the server should return. Typically, + // this is the value of + // [ListAttestorsResponse.next_page_token][google.cloud.binaryauthorization.v1beta1.ListAttestorsResponse.next_page_token] + // returned from the previous call to the `ListAttestors` method. + string page_token = 3; +} + +// Response message for [BinauthzManagementService.ListAttestors][]. +message ListAttestorsResponse { + // The list of [attestors][google.cloud.binaryauthorization.v1beta1.Attestor]. + repeated Attestor attestors = 1; + + // A token to retrieve the next page of results. Pass this value in the + // [ListAttestorsRequest.page_token][google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest.page_token] + // field in the subsequent call to the `ListAttestors` method to retrieve the + // next page of results. + string next_page_token = 2; +} + +// Request message for [BinauthzManagementService.DeleteAttestor][]. +message DeleteAttestorRequest { + // Required. The name of the + // [attestors][google.cloud.binaryauthorization.v1beta1.Attestor] to delete, + // in the format `projects/*/attestors/*`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "binaryauthorization.googleapis.com/Attestor" + } + ]; +} diff --git a/owl-bot-staging/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts new file mode 100644 index 0000000..8f67f78 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const BinauthzManagementServiceV1Beta1Client = v1beta1.BinauthzManagementServiceV1Beta1Client; +type BinauthzManagementServiceV1Beta1Client = v1beta1.BinauthzManagementServiceV1Beta1Client; +export {v1beta1, BinauthzManagementServiceV1Beta1Client}; +export default {v1beta1, BinauthzManagementServiceV1Beta1Client}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client.ts new file mode 100644 index 0000000..4de3b7d --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client.ts @@ -0,0 +1,1081 @@ +// 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/binauthz_management_service_v1_beta1_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './binauthz_management_service_v1_beta1_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Google Cloud Management Service for Binary Authorization admission policies + * and attestation authorities. + * + * This API implements a REST model with the following objects: + * + * * {@link google.cloud.binaryauthorization.v1beta1.Policy|Policy} + * * {@link google.cloud.binaryauthorization.v1beta1.Attestor|Attestor} + * @class + * @memberof v1beta1 + */ +export class BinauthzManagementServiceV1Beta1Client { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + binauthzManagementServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of BinauthzManagementServiceV1Beta1Client. + * + * @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 BinauthzManagementServiceV1Beta1Client; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + attestorPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/attestors/{attestor}' + ), + policyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/policy' + ), + 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 = { + listAttestors: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'attestors') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.binauthzManagementServiceV1Beta1Stub) { + return this.binauthzManagementServiceV1Beta1Stub; + } + + // Put together the "service stub" for + // google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1. + this.binauthzManagementServiceV1Beta1Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const binauthzManagementServiceV1Beta1StubMethods = + ['getPolicy', 'updatePolicy', 'createAttestor', 'getAttestor', 'updateAttestor', 'listAttestors', 'deleteAttestor']; + for (const methodName of binauthzManagementServiceV1Beta1StubMethods) { + const callPromise = this.binauthzManagementServiceV1Beta1Stub.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.binauthzManagementServiceV1Beta1Stub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'binaryauthorization.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 'binaryauthorization.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 -- + // ------------------- + getPolicy( + request?: protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|undefined, {}|undefined + ]>; + getPolicy( + request: protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|null|undefined, + {}|null|undefined>): void; + getPolicy( + request: protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|null|undefined, + {}|null|undefined>): void; +/** + * A {@link google.cloud.binaryauthorization.v1beta1.Policy|policy} specifies the + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors} that must + * attest to a container image, before the project is allowed to deploy that + * image. There is at most one policy per project. All image admission + * requests are permitted if a project has no policy. + * + * Gets the {@link google.cloud.binaryauthorization.v1beta1.Policy|policy} for this + * project. Returns a default + * {@link google.cloud.binaryauthorization.v1beta1.Policy|policy} if the project + * does not have one. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link google.cloud.binaryauthorization.v1beta1.Policy|policy} to retrieve, in + * the format `projects/* /policy`. + * @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.cloud.binaryauthorization.v1beta1.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.getPolicy(request); + */ + getPolicy( + request?: protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|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.getPolicy(request, options, callback); + } + updatePolicy( + request?: protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|undefined, {}|undefined + ]>; + updatePolicy( + request: protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>): void; + updatePolicy( + request: protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates or updates a project's + * {@link google.cloud.binaryauthorization.v1beta1.Policy|policy}, and returns a + * copy of the new {@link google.cloud.binaryauthorization.v1beta1.Policy|policy}. + * A policy is always updated as a whole, to avoid race conditions with + * concurrent policy enforcement (or management!) requests. Returns NOT_FOUND + * if the project does not exist, INVALID_ARGUMENT if the request is + * malformed. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.binaryauthorization.v1beta1.Policy} request.policy + * Required. A new or updated + * {@link google.cloud.binaryauthorization.v1beta1.Policy|policy} value. The + * service will overwrite the [policy + * name][google.cloud.binaryauthorization.v1beta1.Policy.name] field with the + * resource name in the request URL, in the format `projects/* /policy`. + * @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.cloud.binaryauthorization.v1beta1.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.updatePolicy(request); + */ + updatePolicy( + request?: protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IPolicy, + protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|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({ + 'policy.name': request.policy!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updatePolicy(request, options, callback); + } + createAttestor( + request?: protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|undefined, {}|undefined + ]>; + createAttestor( + request: protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|null|undefined, + {}|null|undefined>): void; + createAttestor( + request: protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates an {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}, + * and returns a copy of the new + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}. Returns + * NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is + * malformed, ALREADY_EXISTS if the + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} already + * exists. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent of this + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}. + * @param {string} request.attestorId + * Required. The + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors} ID. + * @param {google.cloud.binaryauthorization.v1beta1.Attestor} request.attestor + * Required. The initial + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} value. The + * service will overwrite the [attestor + * name][google.cloud.binaryauthorization.v1beta1.Attestor.name] field with + * the resource name, in the format `projects/* /attestors/*`. + * @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 [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor}. + * 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.createAttestor(request); + */ + createAttestor( + request?: protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|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.createAttestor(request, options, callback); + } + getAttestor( + request?: protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|undefined, {}|undefined + ]>; + getAttestor( + request: protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|null|undefined, + {}|null|undefined>): void; + getAttestor( + request: protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets an {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}. + * Returns NOT_FOUND if the + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} does not + * exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} to retrieve, + * in the format `projects/* /attestors/*`. + * @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 [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor}. + * 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.getAttestor(request); + */ + getAttestor( + request?: protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|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.getAttestor(request, options, callback); + } + updateAttestor( + request?: protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|undefined, {}|undefined + ]>; + updateAttestor( + request: protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|null|undefined, + {}|null|undefined>): void; + updateAttestor( + request: protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates an {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}. + * Returns NOT_FOUND if the + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} does not + * exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.binaryauthorization.v1beta1.Attestor} request.attestor + * Required. The updated + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} value. The + * service will overwrite the [attestor + * name][google.cloud.binaryauthorization.v1beta1.Attestor.name] field with + * the resource name in the request URL, in the format + * `projects/* /attestors/*`. + * @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 [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor}. + * 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.updateAttestor(request); + */ + updateAttestor( + request?: protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IAttestor, + protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|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({ + 'attestor.name': request.attestor!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateAttestor(request, options, callback); + } + deleteAttestor( + request?: protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|undefined, {}|undefined + ]>; + deleteAttestor( + request: protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|null|undefined, + {}|null|undefined>): void; + deleteAttestor( + request: protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes an {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}. + * Returns NOT_FOUND if the + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} does not + * exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors} to delete, + * in the format `projects/* /attestors/*`. + * @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.deleteAttestor(request); + */ + deleteAttestor( + request?: protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|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.deleteAttestor(request, options, callback); + } + + listAttestors( + request?: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IAttestor[], + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest|null, + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse + ]>; + listAttestors( + request: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse|null|undefined, + protos.google.cloud.binaryauthorization.v1beta1.IAttestor>): void; + listAttestors( + request: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, + callback: PaginationCallback< + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse|null|undefined, + protos.google.cloud.binaryauthorization.v1beta1.IAttestor>): void; +/** + * Lists {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors}. + * Returns INVALID_ARGUMENT if the project does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the project associated with the + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors}, in the + * format `projects/*`. + * @param {number} request.pageSize + * Requested page size. The server may return fewer results than requested. If + * unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. Typically, + * this is the value of + * {@link google.cloud.binaryauthorization.v1beta1.ListAttestorsResponse.next_page_token|ListAttestorsResponse.next_page_token} + * returned from the previous call to the `ListAttestors` method. + * @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 [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor}. + * 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 `listAttestorsAsync()` + * 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. + */ + listAttestors( + request?: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse|null|undefined, + protos.google.cloud.binaryauthorization.v1beta1.IAttestor>, + callback?: PaginationCallback< + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse|null|undefined, + protos.google.cloud.binaryauthorization.v1beta1.IAttestor>): + Promise<[ + protos.google.cloud.binaryauthorization.v1beta1.IAttestor[], + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest|null, + protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse + ]>|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.listAttestors(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the project associated with the + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors}, in the + * format `projects/*`. + * @param {number} request.pageSize + * Requested page size. The server may return fewer results than requested. If + * unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. Typically, + * this is the value of + * {@link google.cloud.binaryauthorization.v1beta1.ListAttestorsResponse.next_page_token|ListAttestorsResponse.next_page_token} + * returned from the previous call to the `ListAttestors` method. + * @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 [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor} 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 `listAttestorsAsync()` + * 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. + */ + listAttestorsStream( + request?: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, + 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.listAttestors.createStream( + this.innerApiCalls.listAttestors as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listAttestors`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the project associated with the + * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors}, in the + * format `projects/*`. + * @param {number} request.pageSize + * Requested page size. The server may return fewer results than requested. If + * unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * A token identifying a page of results the server should return. Typically, + * this is the value of + * {@link google.cloud.binaryauthorization.v1beta1.ListAttestorsResponse.next_page_token|ListAttestorsResponse.next_page_token} + * returned from the previous call to the `ListAttestors` method. + * @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 + * [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor}. 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.listAttestorsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listAttestorsAsync( + request?: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, + 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.listAttestors.asyncIterate( + this.innerApiCalls['listAttestors'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attestor resource name string. + * + * @param {string} project + * @param {string} attestor + * @returns {string} Resource name string. + */ + attestorPath(project:string,attestor:string) { + return this.pathTemplates.attestorPathTemplate.render({ + project: project, + attestor: attestor, + }); + } + + /** + * Parse the project from Attestor resource. + * + * @param {string} attestorName + * A fully-qualified path representing Attestor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttestorName(attestorName: string) { + return this.pathTemplates.attestorPathTemplate.match(attestorName).project; + } + + /** + * Parse the attestor from Attestor resource. + * + * @param {string} attestorName + * A fully-qualified path representing Attestor resource. + * @returns {string} A string representing the attestor. + */ + matchAttestorFromAttestorName(attestorName: string) { + return this.pathTemplates.attestorPathTemplate.match(attestorName).attestor; + } + + /** + * Return a fully-qualified policy resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + policyPath(project:string) { + return this.pathTemplates.policyPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Policy resource. + * + * @param {string} policyName + * A fully-qualified path representing Policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPolicyName(policyName: string) { + return this.pathTemplates.policyPathTemplate.match(policyName).project; + } + + /** + * 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.binauthzManagementServiceV1Beta1Stub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client_config.json new file mode 100644 index 0000000..8a493c0 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client_config.json @@ -0,0 +1,61 @@ +{ + "interfaces": { + "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1": { + "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": { + "GetPolicy": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdatePolicy": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateAttestor": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAttestor": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateAttestor": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListAttestors": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteAttestor": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_proto_list.json new file mode 100644 index 0000000..4991b0d --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/binaryauthorization/v1beta1/continuous_validation_logging.proto", + "../../protos/google/cloud/binaryauthorization/v1beta1/resources.proto", + "../../protos/google/cloud/binaryauthorization/v1beta1/service.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..bd8f02e --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,97 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.binaryauthorization.v1beta1", + "libraryPackage": "@google-cloud/binary-authorization", + "services": { + "BinauthzManagementServiceV1Beta1": { + "clients": { + "grpc": { + "libraryClient": "BinauthzManagementServiceV1Beta1Client", + "rpcs": { + "GetPolicy": { + "methods": [ + "getPolicy" + ] + }, + "UpdatePolicy": { + "methods": [ + "updatePolicy" + ] + }, + "CreateAttestor": { + "methods": [ + "createAttestor" + ] + }, + "GetAttestor": { + "methods": [ + "getAttestor" + ] + }, + "UpdateAttestor": { + "methods": [ + "updateAttestor" + ] + }, + "DeleteAttestor": { + "methods": [ + "deleteAttestor" + ] + }, + "ListAttestors": { + "methods": [ + "listAttestors", + "listAttestorsStream", + "listAttestorsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "BinauthzManagementServiceV1Beta1Client", + "rpcs": { + "GetPolicy": { + "methods": [ + "getPolicy" + ] + }, + "UpdatePolicy": { + "methods": [ + "updatePolicy" + ] + }, + "CreateAttestor": { + "methods": [ + "createAttestor" + ] + }, + "GetAttestor": { + "methods": [ + "getAttestor" + ] + }, + "UpdateAttestor": { + "methods": [ + "updateAttestor" + ] + }, + "DeleteAttestor": { + "methods": [ + "deleteAttestor" + ] + }, + "ListAttestors": { + "methods": [ + "listAttestors", + "listAttestorsStream", + "listAttestorsAsync" + ] + } + } + } + } + } + } +} 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..e73278c --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {BinauthzManagementServiceV1Beta1Client} from './binauthz_management_service_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..5a1b190 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const binaryauthorization = require('@google-cloud/binary-authorization'); + +function main() { + const binauthzManagementServiceV1Beta1Client = new binaryauthorization.BinauthzManagementServiceV1Beta1Client(); +} + +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..7450492 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {BinauthzManagementServiceV1Beta1Client} from '@google-cloud/binary-authorization'; + +// check that the client class type name can be used +function doStuffWithBinauthzManagementServiceV1Beta1Client(client: BinauthzManagementServiceV1Beta1Client) { + client.close(); +} + +function main() { + // check that the client instance can be created + const binauthzManagementServiceV1Beta1Client = new BinauthzManagementServiceV1Beta1Client(); + doStuffWithBinauthzManagementServiceV1Beta1Client(binauthzManagementServiceV1Beta1Client); +} + +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_binauthz_management_service_v1_beta1_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_binauthz_management_service_v1_beta1_v1beta1.ts new file mode 100644 index 0000000..e791adc --- /dev/null +++ b/owl-bot-staging/v1beta1/test/gapic_binauthz_management_service_v1_beta1_v1beta1.ts @@ -0,0 +1,1000 @@ +// 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 binauthzmanagementservicev1beta1Module 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.BinauthzManagementServiceV1Beta1Client', () => { + it('has servicePath', () => { + const servicePath = binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.binauthzManagementServiceV1Beta1Stub, undefined); + await client.initialize(); + assert(client.binauthzManagementServiceV1Beta1Stub); + }); + + it('has close method', () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + 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 binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + 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('getPolicy', () => { + it('invokes getPolicy without error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetPolicyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Policy()); + client.innerApiCalls.getPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getPolicy without error using callback', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetPolicyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Policy()); + client.innerApiCalls.getPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getPolicy with error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetPolicyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getPolicy(request), expectedError); + assert((client.innerApiCalls.getPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updatePolicy', () => { + it('invokes updatePolicy without error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdatePolicyRequest()); + request.policy = {}; + request.policy.name = ''; + const expectedHeaderRequestParams = "policy.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Policy()); + client.innerApiCalls.updatePolicy = stubSimpleCall(expectedResponse); + const [response] = await client.updatePolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updatePolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updatePolicy without error using callback', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdatePolicyRequest()); + request.policy = {}; + request.policy.name = ''; + const expectedHeaderRequestParams = "policy.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Policy()); + client.innerApiCalls.updatePolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePolicy( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updatePolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updatePolicy with error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdatePolicyRequest()); + request.policy = {}; + request.policy.name = ''; + const expectedHeaderRequestParams = "policy.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updatePolicy(request), expectedError); + assert((client.innerApiCalls.updatePolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('createAttestor', () => { + it('invokes createAttestor without error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.CreateAttestorRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); + client.innerApiCalls.createAttestor = stubSimpleCall(expectedResponse); + const [response] = await client.createAttestor(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createAttestor without error using callback', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.CreateAttestorRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); + client.innerApiCalls.createAttestor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAttestor( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IAttestor|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createAttestor with error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.CreateAttestorRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createAttestor = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createAttestor(request), expectedError); + assert((client.innerApiCalls.createAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getAttestor', () => { + it('invokes getAttestor without error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetAttestorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); + client.innerApiCalls.getAttestor = stubSimpleCall(expectedResponse); + const [response] = await client.getAttestor(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getAttestor without error using callback', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetAttestorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); + client.innerApiCalls.getAttestor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttestor( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IAttestor|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getAttestor with error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetAttestorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttestor = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAttestor(request), expectedError); + assert((client.innerApiCalls.getAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updateAttestor', () => { + it('invokes updateAttestor without error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdateAttestorRequest()); + request.attestor = {}; + request.attestor.name = ''; + const expectedHeaderRequestParams = "attestor.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); + client.innerApiCalls.updateAttestor = stubSimpleCall(expectedResponse); + const [response] = await client.updateAttestor(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateAttestor without error using callback', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdateAttestorRequest()); + request.attestor = {}; + request.attestor.name = ''; + const expectedHeaderRequestParams = "attestor.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); + client.innerApiCalls.updateAttestor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttestor( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IAttestor|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateAttestor with error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdateAttestorRequest()); + request.attestor = {}; + request.attestor.name = ''; + const expectedHeaderRequestParams = "attestor.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttestor = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateAttestor(request), expectedError); + assert((client.innerApiCalls.updateAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('deleteAttestor', () => { + it('invokes deleteAttestor without error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.DeleteAttestorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteAttestor = stubSimpleCall(expectedResponse); + const [response] = await client.deleteAttestor(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteAttestor without error using callback', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.DeleteAttestorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteAttestor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteAttestor( + 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.deleteAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteAttestor with error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.DeleteAttestorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAttestor = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteAttestor(request), expectedError); + assert((client.innerApiCalls.deleteAttestor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listAttestors', () => { + it('invokes listAttestors without error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + ]; + client.innerApiCalls.listAttestors = stubSimpleCall(expectedResponse); + const [response] = await client.listAttestors(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listAttestors as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listAttestors without error using callback', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + ]; + client.innerApiCalls.listAttestors = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAttestors( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IAttestor[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listAttestors as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listAttestors with error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listAttestors = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listAttestors(request), expectedError); + assert((client.innerApiCalls.listAttestors as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listAttestorsStream without error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + ]; + client.descriptors.page.listAttestors.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listAttestorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.binaryauthorization.v1beta1.Attestor[] = []; + stream.on('data', (response: protos.google.cloud.binaryauthorization.v1beta1.Attestor) => { + 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.listAttestors.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listAttestors, request)); + assert.strictEqual( + (client.descriptors.page.listAttestors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listAttestorsStream with error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listAttestors.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listAttestorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.binaryauthorization.v1beta1.Attestor[] = []; + stream.on('data', (response: protos.google.cloud.binaryauthorization.v1beta1.Attestor) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listAttestors.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listAttestors, request)); + assert.strictEqual( + (client.descriptors.page.listAttestors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listAttestors without error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), + ]; + client.descriptors.page.listAttestors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.binaryauthorization.v1beta1.IAttestor[] = []; + const iterable = client.listAttestorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listAttestors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listAttestors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listAttestors with error', async () => { + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listAttestors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAttestorsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.binaryauthorization.v1beta1.IAttestor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listAttestors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listAttestors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('attestor', () => { + const fakePath = "/rendered/path/attestor"; + const expectedParameters = { + project: "projectValue", + attestor: "attestorValue", + }; + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attestorPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.attestorPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('attestorPath', () => { + const result = client.attestorPath("projectValue", "attestorValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.attestorPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAttestorName', () => { + const result = client.matchProjectFromAttestorName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.attestorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAttestorFromAttestorName', () => { + const result = client.matchAttestorFromAttestorName(fakePath); + assert.strictEqual(result, "attestorValue"); + assert((client.pathTemplates.attestorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('policy', () => { + const fakePath = "/rendered/path/policy"; + const expectedParameters = { + project: "projectValue", + }; + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.policyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.policyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('policyPath', () => { + const result = client.policyPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.policyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPolicyName', () => { + const result = client.matchProjectFromPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.policyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1beta1/tsconfig.json b/owl-bot-staging/v1beta1/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1beta1/webpack.config.js b/owl-bot-staging/v1beta1/webpack.config.js new file mode 100644 index 0000000..58a92d5 --- /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: 'BinauthzManagementServiceV1Beta1', + filename: './binauthz-management-service-v1-beta1.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From 56923c4b622d02a8c796b40b41aac25c84708e08 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 16 Jul 2021 10:21:25 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md --- owl-bot-staging/v1beta1/.eslintignore | 6 - owl-bot-staging/v1beta1/.eslintrc.json | 3 - owl-bot-staging/v1beta1/.gitignore | 14 - owl-bot-staging/v1beta1/.jsdoc.js | 55 - owl-bot-staging/v1beta1/.mocharc.js | 33 - owl-bot-staging/v1beta1/.prettierrc.js | 22 - owl-bot-staging/v1beta1/README.md | 1 - .../v1beta1/linkinator.config.json | 10 - owl-bot-staging/v1beta1/package.json | 64 - .../continuous_validation_logging.proto | 97 -- .../v1beta1/resources.proto | 330 ----- .../binaryauthorization/v1beta1/service.proto | 257 ---- owl-bot-staging/v1beta1/src/index.ts | 25 - ...uthz_management_service_v1_beta1_client.ts | 1081 ----------------- ...gement_service_v1_beta1_client_config.json | 61 - ...anagement_service_v1_beta1_proto_list.json | 5 - .../v1beta1/src/v1beta1/gapic_metadata.json | 97 -- owl-bot-staging/v1beta1/src/v1beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - ...thz_management_service_v1_beta1_v1beta1.ts | 1000 --------------- owl-bot-staging/v1beta1/tsconfig.json | 19 - owl-bot-staging/v1beta1/webpack.config.js | 64 - ...uthz_management_service_v1_beta1_client.ts | 11 +- 25 files changed, 10 insertions(+), 3372 deletions(-) delete mode 100644 owl-bot-staging/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1beta1/.gitignore delete mode 100644 owl-bot-staging/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1beta1/README.md delete mode 100644 owl-bot-staging/v1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1beta1/package.json delete mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/continuous_validation_logging.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/resources.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/service.proto delete mode 100644 owl-bot-staging/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client_config.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_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/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_binauthz_management_service_v1_beta1_v1beta1.ts delete mode 100644 owl-bot-staging/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1beta1/webpack.config.js diff --git a/owl-bot-staging/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 eb5f5af..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/binary-authorization', - 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 438dbbe..0000000 --- a/owl-bot-staging/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Binaryauthorization: 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 08ae768..0000000 --- a/owl-bot-staging/v1beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/binary-authorization", - "version": "0.1.0", - "description": "Binaryauthorization client for Node.js", - "repository": "googleapis/nodejs-binaryauthorization", - "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 binaryauthorization", - "binaryauthorization", - "binauthz management service v1 beta1" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.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/cloud/binaryauthorization/v1beta1/continuous_validation_logging.proto b/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/continuous_validation_logging.proto deleted file mode 100644 index 4f7bfdd..0000000 --- a/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/continuous_validation_logging.proto +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.binaryauthorization.v1beta1; - -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.Cloud.BinaryAuthorization.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/binaryauthorization/v1beta1;binaryauthorization"; -option java_multiple_files = true; -option java_outer_classname = "ContinuousValidationLoggingProto"; -option java_package = "com.google.cloud.binaryauthorization.v1beta1"; -option php_namespace = "Google\\Cloud\\BinaryAuthorization\\V1beta1"; -option ruby_package = "Google::Cloud::BinaryAuthorization::V1beta1"; - -// Represents an auditing event from Continuous Validation. -message ContinuousValidationEvent { - // An auditing event for one Pod. - message ContinuousValidationPodEvent { - // Container image with auditing details. - message ImageDetails { - // Result of the audit. - enum AuditResult { - // Unspecified result. This is an error. - AUDIT_RESULT_UNSPECIFIED = 0; - - // Image is allowed. - ALLOW = 1; - - // Image is denied. - DENY = 2; - } - - // The name of the image. - string image = 1; - - // The result of the audit for this image. - AuditResult result = 2; - - // Description of the above result. - string description = 3; - } - - // Audit time policy conformance verdict. - enum PolicyConformanceVerdict { - // We should always have a verdict. This is an error. - POLICY_CONFORMANCE_VERDICT_UNSPECIFIED = 0; - - // The pod violates the policy. - VIOLATES_POLICY = 1; - } - - // The name of the Pod. - string pod = 1; - - // Deploy time of the Pod from k8s. - google.protobuf.Timestamp deploy_time = 2; - - // Termination time of the Pod from k8s, or nothing if still running. - google.protobuf.Timestamp end_time = 3; - - // Auditing verdict for this Pod. - PolicyConformanceVerdict verdict = 4; - - // List of images with auditing details. - repeated ImageDetails images = 5; - } - - // An event describing that the project policy is unsupported by CV. - message UnsupportedPolicyEvent { - // A description of the unsupported policy. - string description = 1; - } - - // Type of CV event. - oneof event_type { - // Pod event. - ContinuousValidationPodEvent pod_event = 1; - - // Unsupported policy event. - UnsupportedPolicyEvent unsupported_policy_event = 2; - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/resources.proto b/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/resources.proto deleted file mode 100644 index ea674a7..0000000 --- a/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/resources.proto +++ /dev/null @@ -1,330 +0,0 @@ -// Copyright 2021 Google LLC. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.cloud.binaryauthorization.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.Cloud.BinaryAuthorization.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/binaryauthorization/v1beta1;binaryauthorization"; -option java_multiple_files = true; -option java_outer_classname = "BinaryAuthorizationResourcesProto"; -option java_package = "com.google.cloud.binaryauthorization.v1beta1"; -option php_namespace = "Google\\Cloud\\BinaryAuthorization\\V1beta1"; -option ruby_package = "Google::Cloud::BinaryAuthorization::V1beta1"; - -// A [policy][google.cloud.binaryauthorization.v1beta1.Policy] for container -// image binary authorization. -message Policy { - option (google.api.resource) = { - type: "binaryauthorization.googleapis.com/Policy" - pattern: "projects/{project}/policy" - }; - - enum GlobalPolicyEvaluationMode { - // Not specified: DISABLE is assumed. - GLOBAL_POLICY_EVALUATION_MODE_UNSPECIFIED = 0; - - // Enables global policy evaluation. - ENABLE = 1; - - // Disables global policy evaluation. - DISABLE = 2; - } - - // Output only. The resource name, in the format `projects/*/policy`. There is - // at most one policy per project. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. A descriptive comment. - string description = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Controls the evaluation of a Google-maintained global admission - // policy for common system-level images. Images not covered by the global - // policy will be subject to the project admission policy. This setting - // has no effect when specified inside a global admission policy. - GlobalPolicyEvaluationMode global_policy_evaluation_mode = 7 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Admission policy allowlisting. A matching admission request will - // always be permitted. This feature is typically used to exclude Google or - // third-party infrastructure images from Binary Authorization policies. - repeated AdmissionWhitelistPattern admission_whitelist_patterns = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Per-cluster admission rules. Cluster spec format: - // `location.clusterId`. There can be at most one admission rule per cluster - // spec. - // A `location` is either a compute zone (e.g. us-central1-a) or a region - // (e.g. us-central1). - // For `clusterId` syntax restrictions see - // https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters. - map cluster_admission_rules = 3 - [(google.api.field_behavior) = OPTIONAL]; - - // Required. Default admission rule for a cluster without a per-cluster, per- - // kubernetes-service-account, or per-istio-service-identity admission rule. - AdmissionRule default_admission_rule = 4 - [(google.api.field_behavior) = REQUIRED]; - - // Output only. Time when the policy was last updated. - google.protobuf.Timestamp update_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// An [admission allowlist -// pattern][google.cloud.binaryauthorization.v1beta1.AdmissionWhitelistPattern] -// exempts images from checks by [admission -// rules][google.cloud.binaryauthorization.v1beta1.AdmissionRule]. -message AdmissionWhitelistPattern { - // An image name pattern to allow, in the form `registry/path/to/image`. - // This supports a trailing `*` as a wildcard, but this is allowed only in - // text after the `registry/` part. - string name_pattern = 1; -} - -// An [admission rule][google.cloud.binaryauthorization.v1beta1.AdmissionRule] -// specifies either that all container images used in a pod creation request -// must be attested to by one or more -// [attestors][google.cloud.binaryauthorization.v1beta1.Attestor], that all pod -// creations will be allowed, or that all pod creations will be denied. -// -// Images matching an [admission allowlist -// pattern][google.cloud.binaryauthorization.v1beta1.AdmissionWhitelistPattern] -// are exempted from admission rules and will never block a pod creation. -message AdmissionRule { - enum EvaluationMode { - // Do not use. - EVALUATION_MODE_UNSPECIFIED = 0; - - // This rule allows all all pod creations. - ALWAYS_ALLOW = 1; - - // This rule allows a pod creation if all the attestors listed in - // 'require_attestations_by' have valid attestations for all of the - // images in the pod spec. - REQUIRE_ATTESTATION = 2; - - // This rule denies all pod creations. - ALWAYS_DENY = 3; - } - - // Defines the possible actions when a pod creation is denied by an admission - // rule. - enum EnforcementMode { - // Do not use. - ENFORCEMENT_MODE_UNSPECIFIED = 0; - - // Enforce the admission rule by blocking the pod creation. - ENFORCED_BLOCK_AND_AUDIT_LOG = 1; - - // Dryrun mode: Audit logging only. This will allow the pod creation as if - // the admission request had specified break-glass. - DRYRUN_AUDIT_LOG_ONLY = 2; - } - - // Required. How this admission rule will be evaluated. - EvaluationMode evaluation_mode = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The resource names of the attestors that must attest to - // a container image, in the format `projects/*/attestors/*`. Each - // attestor must exist before a policy can reference it. To add an attestor - // to a policy the principal issuing the policy change request must be able - // to read the attestor resource. - // - // Note: this field must be non-empty when the evaluation_mode field specifies - // REQUIRE_ATTESTATION, otherwise it must be empty. - repeated string require_attestations_by = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Required. The action when a pod creation is denied by the admission rule. - EnforcementMode enforcement_mode = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// An [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] that attests -// to container image artifacts. An existing attestor cannot be modified except -// where indicated. -message Attestor { - option (google.api.resource) = { - type: "binaryauthorization.googleapis.com/Attestor" - pattern: "projects/{project}/attestors/{attestor}" - }; - - // Required. The resource name, in the format: - // `projects/*/attestors/*`. This field may not be updated. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. A descriptive comment. This field may be updated. - // The field may be displayed in chooser dialogs. - string description = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Required. Identifies an - // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] that attests - // to a container image artifact. This determines how an attestation will be - // stored, and how it will be used during policy enforcement. Updates may not - // change the attestor type, but individual attestor fields may be updated - oneof attestor_type { - // A Drydock ATTESTATION_AUTHORITY Note, created by the user. - UserOwnedDrydockNote user_owned_drydock_note = 3; - } - - // Output only. Time when the attestor was last updated. - google.protobuf.Timestamp update_time = 4 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// An [user owned drydock -// note][google.cloud.binaryauthorization.v1beta1.UserOwnedDrydockNote] -// references a Drydock ATTESTATION_AUTHORITY Note created by the user. -message UserOwnedDrydockNote { - // Required. The Drydock resource name of a ATTESTATION_AUTHORITY Note, - // created by the user, in the format: `projects/*/notes/*` (or the legacy - // `providers/*/notes/*`). This field may not be updated. - // - // An attestation by this attestor is stored as a Drydock - // ATTESTATION_AUTHORITY Occurrence that names a container image and that - // links to this Note. Drydock is an external dependency. - string note_reference = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Public keys that verify attestations signed by this - // attestor. This field may be updated. - // - // If this field is non-empty, one of the specified public keys must - // verify that an attestation was signed by this attestor for the - // image specified in the admission request. - // - // If this field is empty, this attestor always returns that no - // valid attestations exist. - repeated AttestorPublicKey public_keys = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. This field will contain the service account email address - // that this Attestor will use as the principal when querying Container - // Analysis. Attestor administrators must grant this service account the - // IAM role needed to read attestations from the [note_reference][Note] in - // Container Analysis (`containeranalysis.notes.occurrences.viewer`). - // - // This email address is fixed for the lifetime of the Attestor, but callers - // should not make any other assumptions about the service account email; - // future versions may use an email based on a different naming pattern. - string delegation_service_account_email = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A public key in the PkixPublicKey format (see -// https://tools.ietf.org/html/rfc5280#section-4.1.2.7 for details). -// Public keys of this type are typically textually encoded using the PEM -// format. -message PkixPublicKey { - // Represents a signature algorithm and other information necessary to verify - // signatures with a given public key. - // This is based primarily on the public key types supported by Tink's - // PemKeyType, which is in turn based on KMS's supported signing algorithms. - // See https://cloud.google.com/kms/docs/algorithms. In the future, BinAuthz - // might support additional public key types independently of Tink and/or KMS. - enum SignatureAlgorithm { - // Not specified. - SIGNATURE_ALGORITHM_UNSPECIFIED = 0; - - // RSASSA-PSS 2048 bit key with a SHA256 digest. - RSA_PSS_2048_SHA256 = 1; - - // RSASSA-PSS 3072 bit key with a SHA256 digest. - RSA_PSS_3072_SHA256 = 2; - - // RSASSA-PSS 4096 bit key with a SHA256 digest. - RSA_PSS_4096_SHA256 = 3; - - // RSASSA-PSS 4096 bit key with a SHA512 digest. - RSA_PSS_4096_SHA512 = 4; - - // RSASSA-PKCS1-v1_5 with a 2048 bit key and a SHA256 digest. - RSA_SIGN_PKCS1_2048_SHA256 = 5; - - // RSASSA-PKCS1-v1_5 with a 3072 bit key and a SHA256 digest. - RSA_SIGN_PKCS1_3072_SHA256 = 6; - - // RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA256 digest. - RSA_SIGN_PKCS1_4096_SHA256 = 7; - - // RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA512 digest. - RSA_SIGN_PKCS1_4096_SHA512 = 8; - - // ECDSA on the NIST P-256 curve with a SHA256 digest. - ECDSA_P256_SHA256 = 9; - - // ECDSA on the NIST P-384 curve with a SHA384 digest. - ECDSA_P384_SHA384 = 10; - - // ECDSA on the NIST P-521 curve with a SHA512 digest. - ECDSA_P521_SHA512 = 11; - } - - // A PEM-encoded public key, as described in - // https://tools.ietf.org/html/rfc7468#section-13 - string public_key_pem = 1; - - // The signature algorithm used to verify a message against a signature using - // this key. - // These signature algorithm must match the structure and any object - // identifiers encoded in `public_key_pem` (i.e. this algorithm must match - // that of the public key). - SignatureAlgorithm signature_algorithm = 2; -} - -// An [attestor public -// key][google.cloud.binaryauthorization.v1beta1.AttestorPublicKey] that will be -// used to verify attestations signed by this attestor. -message AttestorPublicKey { - // Optional. A descriptive comment. This field may be updated. - string comment = 1 [(google.api.field_behavior) = OPTIONAL]; - - // The ID of this public key. - // Signatures verified by BinAuthz must include the ID of the public key that - // can be used to verify them, and that ID must match the contents of this - // field exactly. - // Additional restrictions on this field can be imposed based on which public - // key type is encapsulated. See the documentation on `public_key` cases below - // for details. - string id = 2; - - // Required. A public key reference or serialized instance. This field may be - // updated. - oneof public_key { - // ASCII-armored representation of a PGP public key, as the entire output by - // the command `gpg --export --armor foo@example.com` (either LF or CRLF - // line endings). - // When using this field, `id` should be left blank. The BinAuthz API - // handlers will calculate the ID and fill it in automatically. BinAuthz - // computes this ID as the OpenPGP RFC4880 V4 fingerprint, represented as - // upper-case hex. If `id` is provided by the caller, it will be - // overwritten by the API-calculated ID. - string ascii_armored_pgp_public_key = 3; - - // A raw PKIX SubjectPublicKeyInfo format public key. - // - // NOTE: `id` may be explicitly provided by the caller when using this - // type of public key, but it MUST be a valid RFC3986 URI. If `id` is left - // blank, a default one will be computed based on the digest of the DER - // encoding of the public key. - PkixPublicKey pkix_public_key = 5; - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/service.proto b/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/service.proto deleted file mode 100644 index 3f6c5ab..0000000 --- a/owl-bot-staging/v1beta1/protos/google/cloud/binaryauthorization/v1beta1/service.proto +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright 2019 Google LLC. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.cloud.binaryauthorization.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/binaryauthorization/v1beta1/resources.proto"; -import "google/protobuf/empty.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.Cloud.BinaryAuthorization.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/binaryauthorization/v1beta1;binaryauthorization"; -option java_multiple_files = true; -option java_outer_classname = "BinaryAuthorizationServiceProto"; -option java_package = "com.google.cloud.binaryauthorization.v1beta1"; -option php_namespace = "Google\\Cloud\\BinaryAuthorization\\V1beta1"; -option ruby_package = "Google::Cloud::BinaryAuthorization::V1beta1"; - -// Customer-facing API for Cloud Binary Authorization. - -// Google Cloud Management Service for Binary Authorization admission policies -// and attestation authorities. -// -// This API implements a REST model with the following objects: -// -// * [Policy][google.cloud.binaryauthorization.v1beta1.Policy] -// * [Attestor][google.cloud.binaryauthorization.v1beta1.Attestor] -service BinauthzManagementServiceV1Beta1 { - option (google.api.default_host) = "binaryauthorization.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // A [policy][google.cloud.binaryauthorization.v1beta1.Policy] specifies the - // [attestors][google.cloud.binaryauthorization.v1beta1.Attestor] that must - // attest to a container image, before the project is allowed to deploy that - // image. There is at most one policy per project. All image admission - // requests are permitted if a project has no policy. - // - // Gets the [policy][google.cloud.binaryauthorization.v1beta1.Policy] for this - // project. Returns a default - // [policy][google.cloud.binaryauthorization.v1beta1.Policy] if the project - // does not have one. - rpc GetPolicy(GetPolicyRequest) returns (Policy) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/policy}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates or updates a project's - // [policy][google.cloud.binaryauthorization.v1beta1.Policy], and returns a - // copy of the new [policy][google.cloud.binaryauthorization.v1beta1.Policy]. - // A policy is always updated as a whole, to avoid race conditions with - // concurrent policy enforcement (or management!) requests. Returns NOT_FOUND - // if the project does not exist, INVALID_ARGUMENT if the request is - // malformed. - rpc UpdatePolicy(UpdatePolicyRequest) returns (Policy) { - option (google.api.http) = { - put: "/v1beta1/{policy.name=projects/*/policy}" - body: "policy" - }; - option (google.api.method_signature) = "policy"; - } - - // Creates an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor], - // and returns a copy of the new - // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. Returns - // NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is - // malformed, ALREADY_EXISTS if the - // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] already - // exists. - rpc CreateAttestor(CreateAttestorRequest) returns (Attestor) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*}/attestors" - body: "attestor" - }; - option (google.api.method_signature) = "parent,attestor_id,attestor"; - } - - // Gets an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. - // Returns NOT_FOUND if the - // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not - // exist. - rpc GetAttestor(GetAttestorRequest) returns (Attestor) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/attestors/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. - // Returns NOT_FOUND if the - // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not - // exist. - rpc UpdateAttestor(UpdateAttestorRequest) returns (Attestor) { - option (google.api.http) = { - put: "/v1beta1/{attestor.name=projects/*/attestors/*}" - body: "attestor" - }; - option (google.api.method_signature) = "attestor"; - } - - // Lists [attestors][google.cloud.binaryauthorization.v1beta1.Attestor]. - // Returns INVALID_ARGUMENT if the project does not exist. - rpc ListAttestors(ListAttestorsRequest) returns (ListAttestorsResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*}/attestors" - }; - option (google.api.method_signature) = "parent"; - } - - // Deletes an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. - // Returns NOT_FOUND if the - // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not - // exist. - rpc DeleteAttestor(DeleteAttestorRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/attestors/*}" - }; - option (google.api.method_signature) = "name"; - } -} - -// Request message for [BinauthzManagementService.GetPolicy][]. -message GetPolicyRequest { - // Required. The resource name of the - // [policy][google.cloud.binaryauthorization.v1beta1.Policy] to retrieve, in - // the format `projects/*/policy`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "binaryauthorization.googleapis.com/Policy" - } - ]; -} - -// Request message for [BinauthzManagementService.UpdatePolicy][]. -message UpdatePolicyRequest { - // Required. A new or updated - // [policy][google.cloud.binaryauthorization.v1beta1.Policy] value. The - // service will overwrite the [policy - // name][google.cloud.binaryauthorization.v1beta1.Policy.name] field with the - // resource name in the request URL, in the format `projects/*/policy`. - Policy policy = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for [BinauthzManagementService.CreateAttestor][]. -message CreateAttestorRequest { - // Required. The parent of this - // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The - // [attestors][google.cloud.binaryauthorization.v1beta1.Attestor] ID. - string attestor_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The initial - // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] value. The - // service will overwrite the [attestor - // name][google.cloud.binaryauthorization.v1beta1.Attestor.name] field with - // the resource name, in the format `projects/*/attestors/*`. - Attestor attestor = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for [BinauthzManagementService.GetAttestor][]. -message GetAttestorRequest { - // Required. The name of the - // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] to retrieve, - // in the format `projects/*/attestors/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "binaryauthorization.googleapis.com/Attestor" - } - ]; -} - -// Request message for [BinauthzManagementService.UpdateAttestor][]. -message UpdateAttestorRequest { - // Required. The updated - // [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] value. The - // service will overwrite the [attestor - // name][google.cloud.binaryauthorization.v1beta1.Attestor.name] field with - // the resource name in the request URL, in the format - // `projects/*/attestors/*`. - Attestor attestor = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for [BinauthzManagementService.ListAttestors][]. -message ListAttestorsRequest { - // Required. The resource name of the project associated with the - // [attestors][google.cloud.binaryauthorization.v1beta1.Attestor], in the - // format `projects/*`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Requested page size. The server may return fewer results than requested. If - // unspecified, the server will pick an appropriate default. - int32 page_size = 2; - - // A token identifying a page of results the server should return. Typically, - // this is the value of - // [ListAttestorsResponse.next_page_token][google.cloud.binaryauthorization.v1beta1.ListAttestorsResponse.next_page_token] - // returned from the previous call to the `ListAttestors` method. - string page_token = 3; -} - -// Response message for [BinauthzManagementService.ListAttestors][]. -message ListAttestorsResponse { - // The list of [attestors][google.cloud.binaryauthorization.v1beta1.Attestor]. - repeated Attestor attestors = 1; - - // A token to retrieve the next page of results. Pass this value in the - // [ListAttestorsRequest.page_token][google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest.page_token] - // field in the subsequent call to the `ListAttestors` method to retrieve the - // next page of results. - string next_page_token = 2; -} - -// Request message for [BinauthzManagementService.DeleteAttestor][]. -message DeleteAttestorRequest { - // Required. The name of the - // [attestors][google.cloud.binaryauthorization.v1beta1.Attestor] to delete, - // in the format `projects/*/attestors/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "binaryauthorization.googleapis.com/Attestor" - } - ]; -} diff --git a/owl-bot-staging/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts deleted file mode 100644 index 8f67f78..0000000 --- a/owl-bot-staging/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1beta1 from './v1beta1'; -const BinauthzManagementServiceV1Beta1Client = v1beta1.BinauthzManagementServiceV1Beta1Client; -type BinauthzManagementServiceV1Beta1Client = v1beta1.BinauthzManagementServiceV1Beta1Client; -export {v1beta1, BinauthzManagementServiceV1Beta1Client}; -export default {v1beta1, BinauthzManagementServiceV1Beta1Client}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client.ts deleted file mode 100644 index 4de3b7d..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client.ts +++ /dev/null @@ -1,1081 +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/binauthz_management_service_v1_beta1_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './binauthz_management_service_v1_beta1_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Google Cloud Management Service for Binary Authorization admission policies - * and attestation authorities. - * - * This API implements a REST model with the following objects: - * - * * {@link google.cloud.binaryauthorization.v1beta1.Policy|Policy} - * * {@link google.cloud.binaryauthorization.v1beta1.Attestor|Attestor} - * @class - * @memberof v1beta1 - */ -export class BinauthzManagementServiceV1Beta1Client { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - binauthzManagementServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of BinauthzManagementServiceV1Beta1Client. - * - * @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 BinauthzManagementServiceV1Beta1Client; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - attestorPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/attestors/{attestor}' - ), - policyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/policy' - ), - 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 = { - listAttestors: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'attestors') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.binauthzManagementServiceV1Beta1Stub) { - return this.binauthzManagementServiceV1Beta1Stub; - } - - // Put together the "service stub" for - // google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1. - this.binauthzManagementServiceV1Beta1Stub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const binauthzManagementServiceV1Beta1StubMethods = - ['getPolicy', 'updatePolicy', 'createAttestor', 'getAttestor', 'updateAttestor', 'listAttestors', 'deleteAttestor']; - for (const methodName of binauthzManagementServiceV1Beta1StubMethods) { - const callPromise = this.binauthzManagementServiceV1Beta1Stub.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.binauthzManagementServiceV1Beta1Stub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'binaryauthorization.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 'binaryauthorization.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 -- - // ------------------- - getPolicy( - request?: protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|undefined, {}|undefined - ]>; - getPolicy( - request: protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|null|undefined, - {}|null|undefined>): void; - getPolicy( - request: protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest, - callback: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|null|undefined, - {}|null|undefined>): void; -/** - * A {@link google.cloud.binaryauthorization.v1beta1.Policy|policy} specifies the - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors} that must - * attest to a container image, before the project is allowed to deploy that - * image. There is at most one policy per project. All image admission - * requests are permitted if a project has no policy. - * - * Gets the {@link google.cloud.binaryauthorization.v1beta1.Policy|policy} for this - * project. Returns a default - * {@link google.cloud.binaryauthorization.v1beta1.Policy|policy} if the project - * does not have one. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link google.cloud.binaryauthorization.v1beta1.Policy|policy} to retrieve, in - * the format `projects/* /policy`. - * @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.cloud.binaryauthorization.v1beta1.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.getPolicy(request); - */ - getPolicy( - request?: protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IGetPolicyRequest|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.getPolicy(request, options, callback); - } - updatePolicy( - request?: protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|undefined, {}|undefined - ]>; - updatePolicy( - request: protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|null|undefined, - {}|null|undefined>): void; - updatePolicy( - request: protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest, - callback: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates or updates a project's - * {@link google.cloud.binaryauthorization.v1beta1.Policy|policy}, and returns a - * copy of the new {@link google.cloud.binaryauthorization.v1beta1.Policy|policy}. - * A policy is always updated as a whole, to avoid race conditions with - * concurrent policy enforcement (or management!) requests. Returns NOT_FOUND - * if the project does not exist, INVALID_ARGUMENT if the request is - * malformed. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.binaryauthorization.v1beta1.Policy} request.policy - * Required. A new or updated - * {@link google.cloud.binaryauthorization.v1beta1.Policy|policy} value. The - * service will overwrite the [policy - * name][google.cloud.binaryauthorization.v1beta1.Policy.name] field with the - * resource name in the request URL, in the format `projects/* /policy`. - * @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.cloud.binaryauthorization.v1beta1.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.updatePolicy(request); - */ - updatePolicy( - request?: protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IPolicy, - protos.google.cloud.binaryauthorization.v1beta1.IUpdatePolicyRequest|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({ - 'policy.name': request.policy!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updatePolicy(request, options, callback); - } - createAttestor( - request?: protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|undefined, {}|undefined - ]>; - createAttestor( - request: protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|null|undefined, - {}|null|undefined>): void; - createAttestor( - request: protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest, - callback: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates an {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}, - * and returns a copy of the new - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}. Returns - * NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is - * malformed, ALREADY_EXISTS if the - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} already - * exists. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent of this - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}. - * @param {string} request.attestorId - * Required. The - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors} ID. - * @param {google.cloud.binaryauthorization.v1beta1.Attestor} request.attestor - * Required. The initial - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} value. The - * service will overwrite the [attestor - * name][google.cloud.binaryauthorization.v1beta1.Attestor.name] field with - * the resource name, in the format `projects/* /attestors/*`. - * @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 [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor}. - * 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.createAttestor(request); - */ - createAttestor( - request?: protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.ICreateAttestorRequest|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.createAttestor(request, options, callback); - } - getAttestor( - request?: protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|undefined, {}|undefined - ]>; - getAttestor( - request: protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|null|undefined, - {}|null|undefined>): void; - getAttestor( - request: protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest, - callback: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|null|undefined, - {}|null|undefined>): void; -/** - * Gets an {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}. - * Returns NOT_FOUND if the - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} does not - * exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} to retrieve, - * in the format `projects/* /attestors/*`. - * @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 [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor}. - * 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.getAttestor(request); - */ - getAttestor( - request?: protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IGetAttestorRequest|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.getAttestor(request, options, callback); - } - updateAttestor( - request?: protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|undefined, {}|undefined - ]>; - updateAttestor( - request: protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|null|undefined, - {}|null|undefined>): void; - updateAttestor( - request: protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest, - callback: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|null|undefined, - {}|null|undefined>): void; -/** - * Updates an {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}. - * Returns NOT_FOUND if the - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} does not - * exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.binaryauthorization.v1beta1.Attestor} request.attestor - * Required. The updated - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} value. The - * service will overwrite the [attestor - * name][google.cloud.binaryauthorization.v1beta1.Attestor.name] field with - * the resource name in the request URL, in the format - * `projects/* /attestors/*`. - * @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 [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor}. - * 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.updateAttestor(request); - */ - updateAttestor( - request?: protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IAttestor, - protos.google.cloud.binaryauthorization.v1beta1.IUpdateAttestorRequest|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({ - 'attestor.name': request.attestor!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateAttestor(request, options, callback); - } - deleteAttestor( - request?: protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|undefined, {}|undefined - ]>; - deleteAttestor( - request: protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|null|undefined, - {}|null|undefined>): void; - deleteAttestor( - request: protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|null|undefined, - {}|null|undefined>): void; -/** - * Deletes an {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor}. - * Returns NOT_FOUND if the - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestor} does not - * exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors} to delete, - * in the format `projects/* /attestors/*`. - * @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.deleteAttestor(request); - */ - deleteAttestor( - request?: protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.binaryauthorization.v1beta1.IDeleteAttestorRequest|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.deleteAttestor(request, options, callback); - } - - listAttestors( - request?: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IAttestor[], - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest|null, - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse - ]>; - listAttestors( - request: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse|null|undefined, - protos.google.cloud.binaryauthorization.v1beta1.IAttestor>): void; - listAttestors( - request: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, - callback: PaginationCallback< - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse|null|undefined, - protos.google.cloud.binaryauthorization.v1beta1.IAttestor>): void; -/** - * Lists {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors}. - * Returns INVALID_ARGUMENT if the project does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the project associated with the - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors}, in the - * format `projects/*`. - * @param {number} request.pageSize - * Requested page size. The server may return fewer results than requested. If - * unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. Typically, - * this is the value of - * {@link google.cloud.binaryauthorization.v1beta1.ListAttestorsResponse.next_page_token|ListAttestorsResponse.next_page_token} - * returned from the previous call to the `ListAttestors` method. - * @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 [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor}. - * 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 `listAttestorsAsync()` - * 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. - */ - listAttestors( - request?: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse|null|undefined, - protos.google.cloud.binaryauthorization.v1beta1.IAttestor>, - callback?: PaginationCallback< - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse|null|undefined, - protos.google.cloud.binaryauthorization.v1beta1.IAttestor>): - Promise<[ - protos.google.cloud.binaryauthorization.v1beta1.IAttestor[], - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest|null, - protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsResponse - ]>|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.listAttestors(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the project associated with the - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors}, in the - * format `projects/*`. - * @param {number} request.pageSize - * Requested page size. The server may return fewer results than requested. If - * unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. Typically, - * this is the value of - * {@link google.cloud.binaryauthorization.v1beta1.ListAttestorsResponse.next_page_token|ListAttestorsResponse.next_page_token} - * returned from the previous call to the `ListAttestors` method. - * @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 [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor} 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 `listAttestorsAsync()` - * 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. - */ - listAttestorsStream( - request?: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, - 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.listAttestors.createStream( - this.innerApiCalls.listAttestors as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listAttestors`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the project associated with the - * {@link google.cloud.binaryauthorization.v1beta1.Attestor|attestors}, in the - * format `projects/*`. - * @param {number} request.pageSize - * Requested page size. The server may return fewer results than requested. If - * unspecified, the server will pick an appropriate default. - * @param {string} request.pageToken - * A token identifying a page of results the server should return. Typically, - * this is the value of - * {@link google.cloud.binaryauthorization.v1beta1.ListAttestorsResponse.next_page_token|ListAttestorsResponse.next_page_token} - * returned from the previous call to the `ListAttestors` method. - * @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 - * [Attestor]{@link google.cloud.binaryauthorization.v1beta1.Attestor}. 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.listAttestorsAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listAttestorsAsync( - request?: protos.google.cloud.binaryauthorization.v1beta1.IListAttestorsRequest, - 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.listAttestors.asyncIterate( - this.innerApiCalls['listAttestors'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified attestor resource name string. - * - * @param {string} project - * @param {string} attestor - * @returns {string} Resource name string. - */ - attestorPath(project:string,attestor:string) { - return this.pathTemplates.attestorPathTemplate.render({ - project: project, - attestor: attestor, - }); - } - - /** - * Parse the project from Attestor resource. - * - * @param {string} attestorName - * A fully-qualified path representing Attestor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAttestorName(attestorName: string) { - return this.pathTemplates.attestorPathTemplate.match(attestorName).project; - } - - /** - * Parse the attestor from Attestor resource. - * - * @param {string} attestorName - * A fully-qualified path representing Attestor resource. - * @returns {string} A string representing the attestor. - */ - matchAttestorFromAttestorName(attestorName: string) { - return this.pathTemplates.attestorPathTemplate.match(attestorName).attestor; - } - - /** - * Return a fully-qualified policy resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - policyPath(project:string) { - return this.pathTemplates.policyPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Policy resource. - * - * @param {string} policyName - * A fully-qualified path representing Policy resource. - * @returns {string} A string representing the project. - */ - matchProjectFromPolicyName(policyName: string) { - return this.pathTemplates.policyPathTemplate.match(policyName).project; - } - - /** - * 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.binauthzManagementServiceV1Beta1Stub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client_config.json deleted file mode 100644 index 8a493c0..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client_config.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "interfaces": { - "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1": { - "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": { - "GetPolicy": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdatePolicy": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateAttestor": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetAttestor": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateAttestor": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListAttestors": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteAttestor": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_proto_list.json deleted file mode 100644 index 4991b0d..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/binaryauthorization/v1beta1/continuous_validation_logging.proto", - "../../protos/google/cloud/binaryauthorization/v1beta1/resources.proto", - "../../protos/google/cloud/binaryauthorization/v1beta1/service.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 bd8f02e..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.binaryauthorization.v1beta1", - "libraryPackage": "@google-cloud/binary-authorization", - "services": { - "BinauthzManagementServiceV1Beta1": { - "clients": { - "grpc": { - "libraryClient": "BinauthzManagementServiceV1Beta1Client", - "rpcs": { - "GetPolicy": { - "methods": [ - "getPolicy" - ] - }, - "UpdatePolicy": { - "methods": [ - "updatePolicy" - ] - }, - "CreateAttestor": { - "methods": [ - "createAttestor" - ] - }, - "GetAttestor": { - "methods": [ - "getAttestor" - ] - }, - "UpdateAttestor": { - "methods": [ - "updateAttestor" - ] - }, - "DeleteAttestor": { - "methods": [ - "deleteAttestor" - ] - }, - "ListAttestors": { - "methods": [ - "listAttestors", - "listAttestorsStream", - "listAttestorsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "BinauthzManagementServiceV1Beta1Client", - "rpcs": { - "GetPolicy": { - "methods": [ - "getPolicy" - ] - }, - "UpdatePolicy": { - "methods": [ - "updatePolicy" - ] - }, - "CreateAttestor": { - "methods": [ - "createAttestor" - ] - }, - "GetAttestor": { - "methods": [ - "getAttestor" - ] - }, - "UpdateAttestor": { - "methods": [ - "updateAttestor" - ] - }, - "DeleteAttestor": { - "methods": [ - "deleteAttestor" - ] - }, - "ListAttestors": { - "methods": [ - "listAttestors", - "listAttestorsStream", - "listAttestorsAsync" - ] - } - } - } - } - } - } -} 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 e73278c..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {BinauthzManagementServiceV1Beta1Client} from './binauthz_management_service_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 5a1b190..0000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const binaryauthorization = require('@google-cloud/binary-authorization'); - -function main() { - const binauthzManagementServiceV1Beta1Client = new binaryauthorization.BinauthzManagementServiceV1Beta1Client(); -} - -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 7450492..0000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {BinauthzManagementServiceV1Beta1Client} from '@google-cloud/binary-authorization'; - -// check that the client class type name can be used -function doStuffWithBinauthzManagementServiceV1Beta1Client(client: BinauthzManagementServiceV1Beta1Client) { - client.close(); -} - -function main() { - // check that the client instance can be created - const binauthzManagementServiceV1Beta1Client = new BinauthzManagementServiceV1Beta1Client(); - doStuffWithBinauthzManagementServiceV1Beta1Client(binauthzManagementServiceV1Beta1Client); -} - -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_binauthz_management_service_v1_beta1_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_binauthz_management_service_v1_beta1_v1beta1.ts deleted file mode 100644 index e791adc..0000000 --- a/owl-bot-staging/v1beta1/test/gapic_binauthz_management_service_v1_beta1_v1beta1.ts +++ /dev/null @@ -1,1000 +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 binauthzmanagementservicev1beta1Module 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.BinauthzManagementServiceV1Beta1Client', () => { - it('has servicePath', () => { - const servicePath = binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.binauthzManagementServiceV1Beta1Stub, undefined); - await client.initialize(); - assert(client.binauthzManagementServiceV1Beta1Stub); - }); - - it('has close method', () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - 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 binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - 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('getPolicy', () => { - it('invokes getPolicy without error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetPolicyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Policy()); - client.innerApiCalls.getPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getPolicy without error using callback', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetPolicyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Policy()); - client.innerApiCalls.getPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPolicy( - request, - (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getPolicy with error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetPolicyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPolicy(request), expectedError); - assert((client.innerApiCalls.getPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('updatePolicy', () => { - it('invokes updatePolicy without error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdatePolicyRequest()); - request.policy = {}; - request.policy.name = ''; - const expectedHeaderRequestParams = "policy.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Policy()); - client.innerApiCalls.updatePolicy = stubSimpleCall(expectedResponse); - const [response] = await client.updatePolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updatePolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updatePolicy without error using callback', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdatePolicyRequest()); - request.policy = {}; - request.policy.name = ''; - const expectedHeaderRequestParams = "policy.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Policy()); - client.innerApiCalls.updatePolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updatePolicy( - request, - (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updatePolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updatePolicy with error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdatePolicyRequest()); - request.policy = {}; - request.policy.name = ''; - const expectedHeaderRequestParams = "policy.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updatePolicy(request), expectedError); - assert((client.innerApiCalls.updatePolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('createAttestor', () => { - it('invokes createAttestor without error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.CreateAttestorRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); - client.innerApiCalls.createAttestor = stubSimpleCall(expectedResponse); - const [response] = await client.createAttestor(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createAttestor without error using callback', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.CreateAttestorRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); - client.innerApiCalls.createAttestor = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAttestor( - request, - (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IAttestor|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createAttestor with error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.CreateAttestorRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createAttestor = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createAttestor(request), expectedError); - assert((client.innerApiCalls.createAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getAttestor', () => { - it('invokes getAttestor without error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetAttestorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); - client.innerApiCalls.getAttestor = stubSimpleCall(expectedResponse); - const [response] = await client.getAttestor(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAttestor without error using callback', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetAttestorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); - client.innerApiCalls.getAttestor = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAttestor( - request, - (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IAttestor|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getAttestor with error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.GetAttestorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttestor = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttestor(request), expectedError); - assert((client.innerApiCalls.getAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('updateAttestor', () => { - it('invokes updateAttestor without error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdateAttestorRequest()); - request.attestor = {}; - request.attestor.name = ''; - const expectedHeaderRequestParams = "attestor.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); - client.innerApiCalls.updateAttestor = stubSimpleCall(expectedResponse); - const [response] = await client.updateAttestor(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAttestor without error using callback', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdateAttestorRequest()); - request.attestor = {}; - request.attestor.name = ''; - const expectedHeaderRequestParams = "attestor.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()); - client.innerApiCalls.updateAttestor = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAttestor( - request, - (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IAttestor|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateAttestor with error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.UpdateAttestorRequest()); - request.attestor = {}; - request.attestor.name = ''; - const expectedHeaderRequestParams = "attestor.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAttestor = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateAttestor(request), expectedError); - assert((client.innerApiCalls.updateAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('deleteAttestor', () => { - it('invokes deleteAttestor without error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.DeleteAttestorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteAttestor = stubSimpleCall(expectedResponse); - const [response] = await client.deleteAttestor(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteAttestor without error using callback', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.DeleteAttestorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteAttestor = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteAttestor( - 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.deleteAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteAttestor with error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.DeleteAttestorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAttestor = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteAttestor(request), expectedError); - assert((client.innerApiCalls.deleteAttestor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('listAttestors', () => { - it('invokes listAttestors without error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - ]; - client.innerApiCalls.listAttestors = stubSimpleCall(expectedResponse); - const [response] = await client.listAttestors(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listAttestors as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listAttestors without error using callback', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - ]; - client.innerApiCalls.listAttestors = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAttestors( - request, - (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1beta1.IAttestor[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listAttestors as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listAttestors with error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listAttestors = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAttestors(request), expectedError); - assert((client.innerApiCalls.listAttestors as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listAttestorsStream without error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - ]; - client.descriptors.page.listAttestors.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAttestorsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.binaryauthorization.v1beta1.Attestor[] = []; - stream.on('data', (response: protos.google.cloud.binaryauthorization.v1beta1.Attestor) => { - 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.listAttestors.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttestors, request)); - assert.strictEqual( - (client.descriptors.page.listAttestors.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listAttestorsStream with error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listAttestors.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAttestorsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.binaryauthorization.v1beta1.Attestor[] = []; - stream.on('data', (response: protos.google.cloud.binaryauthorization.v1beta1.Attestor) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAttestors.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttestors, request)); - assert.strictEqual( - (client.descriptors.page.listAttestors.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listAttestors without error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.Attestor()), - ]; - client.descriptors.page.listAttestors.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.binaryauthorization.v1beta1.IAttestor[] = []; - const iterable = client.listAttestorsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAttestors.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listAttestors.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listAttestors with error', async () => { - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listAttestors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAttestorsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.binaryauthorization.v1beta1.IAttestor[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAttestors.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listAttestors.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('attestor', () => { - const fakePath = "/rendered/path/attestor"; - const expectedParameters = { - project: "projectValue", - attestor: "attestorValue", - }; - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.attestorPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attestorPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attestorPath', () => { - const result = client.attestorPath("projectValue", "attestorValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attestorPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttestorName', () => { - const result = client.matchProjectFromAttestorName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attestorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttestorFromAttestorName', () => { - const result = client.matchAttestorFromAttestorName(fakePath); - assert.strictEqual(result, "attestorValue"); - assert((client.pathTemplates.attestorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('policy', () => { - const fakePath = "/rendered/path/policy"; - const expectedParameters = { - project: "projectValue", - }; - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.policyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.policyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('policyPath', () => { - const result = client.policyPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.policyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPolicyName', () => { - const result = client.matchProjectFromPolicyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.policyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new binauthzmanagementservicev1beta1Module.v1beta1.BinauthzManagementServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1beta1/tsconfig.json b/owl-bot-staging/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c8..0000000 --- a/owl-bot-staging/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1beta1/webpack.config.js b/owl-bot-staging/v1beta1/webpack.config.js deleted file mode 100644 index 58a92d5..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: 'BinauthzManagementServiceV1Beta1', - filename: './binauthz-management-service-v1-beta1.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/src/v1beta1/binauthz_management_service_v1_beta1_client.ts b/src/v1beta1/binauthz_management_service_v1_beta1_client.ts index a2d3bc8..226eea2 100644 --- a/src/v1beta1/binauthz_management_service_v1_beta1_client.ts +++ b/src/v1beta1/binauthz_management_service_v1_beta1_client.ts @@ -54,6 +54,7 @@ const version = require('../../../package.json').version; export class BinauthzManagementServiceV1Beta1Client { private _terminated = false; private _opts: ClientOptions; + private _providedCustomServicePath: boolean; private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; @@ -65,6 +66,7 @@ export class BinauthzManagementServiceV1Beta1Client { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; binauthzManagementServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; @@ -109,6 +111,9 @@ export class BinauthzManagementServiceV1Beta1Client { .constructor as typeof BinauthzManagementServiceV1Beta1Client; const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; const fallback = @@ -194,6 +199,9 @@ export class BinauthzManagementServiceV1Beta1Client { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; } /** @@ -223,7 +231,8 @@ export class BinauthzManagementServiceV1Beta1Client { : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.binaryauthorization.v1beta1 .BinauthzManagementServiceV1Beta1, - this._opts + this._opts, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides