diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 0000000..cfc348e --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 0000000..7821534 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 0000000..5d32b23 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 0000000..7300b9d --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2021 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/binaryauthorization', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 0000000..50bc7f7 --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 0000000..84f4713 --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 0000000..438dbbe --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Binaryauthorization: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 0000000..29a223b --- /dev/null +++ b/owl-bot-staging/v1/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 0000000..a164b6b --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,66 @@ +{ + "name": "@google-cloud/binaryauthorization", + "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", + "system policy v1", + "validation helper v1" + ], + "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.19.0" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@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": "^9.0.2", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.1", + "ts-loader": "^9.2.3", + "typescript": "^4.3.4", + "webpack": "^5.39.1", + "webpack-cli": "^4.7.2" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1/protos/google/cloud/binaryauthorization/v1/resources.proto b/owl-bot-staging/v1/protos/google/cloud/binaryauthorization/v1/resources.proto new file mode 100644 index 0000000..9d72a9f --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/binaryauthorization/v1/resources.proto @@ -0,0 +1,334 @@ +// 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.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.BinaryAuthorization.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/binaryauthorization/v1;binaryauthorization"; +option java_multiple_files = false; +option java_package = "com.google.protos.google.cloud.binaryauthorization.v1"; +option php_namespace = "Google\\Cloud\\BinaryAuthorization\\V1"; +option ruby_package = "Google::Cloud::BinaryAuthorization::V1"; + +// A [policy][google.cloud.binaryauthorization.v1.Policy] for container image binary authorization. +message Policy { + option (google.api.resource) = { + type: "binaryauthorization.googleapis.com/Policy" + pattern: "projects/{project}/policy" + pattern: "locations/{location}/policy" + }; + + enum GlobalPolicyEvaluationMode { + // Not specified: DISABLE is assumed. + GLOBAL_POLICY_EVALUATION_MODE_UNSPECIFIED = 0; + + // Enables system policy evaluation. + ENABLE = 1; + + // Disables system 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]; + + // Optional. Per-kubernetes-namespace admission rules. K8s namespace spec format: + // [a-z.-]+, e.g. 'some-namespace' + map kubernetes_namespace_admission_rules = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Per-kubernetes-service-account admission rules. Service account + // spec format: `namespace:serviceaccount`. e.g. 'test-ns:default' + map kubernetes_service_account_admission_rules = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Per-istio-service-identity admission rules. Istio service + // identity spec format: + // spiffe:///ns//sa/ or + // /ns//sa/ + // e.g. spiffe://example.com/ns/test-ns/sa/default + map istio_service_identity_admission_rules = 9 [(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.v1.AdmissionWhitelistPattern] exempts images +// from checks by [admission rules][google.cloud.binaryauthorization.v1.AdmissionRule]. +message AdmissionWhitelistPattern { + // An image name pattern to allowlist, in the form `registry/path/to/image`. + // This supports a trailing `*` wildcard, but this is allowed only in + // text after the `registry/` part. This also supports a trailing `**` + // wildcard which matches subdirectories of a given entry. + string name_pattern = 1; +} + +// An [admission rule][google.cloud.binaryauthorization.v1.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.v1.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.v1.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.v1.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]; + + oneof attestor_type { + // This specifies how an attestation will be read, and how it will be used + // during policy enforcement. + UserOwnedGrafeasNote user_owned_grafeas_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 Grafeas note][google.cloud.binaryauthorization.v1.UserOwnedGrafeasNote] references a Grafeas +// Attestation.Authority Note created by the user. +message UserOwnedGrafeasNote { + // Required. The Grafeas resource name of a Attestation.Authority Note, + // created by the user, in the format: `projects/*/notes/*`. This field may + // not be updated. + // + // An attestation by this attestor is stored as a Grafeas + // Attestation.Authority Occurrence that names a container image and that + // links to this Note. Grafeas 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 { + option allow_alias = true; + + // 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-256 curve with a SHA256 digest. + EC_SIGN_P256_SHA256 = 9; + + // ECDSA on the NIST P-384 curve with a SHA384 digest. + ECDSA_P384_SHA384 = 10; + + // ECDSA on the NIST P-384 curve with a SHA384 digest. + EC_SIGN_P384_SHA384 = 10; + + // ECDSA on the NIST P-521 curve with a SHA512 digest. + ECDSA_P521_SHA512 = 11; + + // ECDSA on the NIST P-521 curve with a SHA512 digest. + EC_SIGN_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.v1.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; + + 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/v1/protos/google/cloud/binaryauthorization/v1/service.proto b/owl-bot-staging/v1/protos/google/cloud/binaryauthorization/v1/service.proto new file mode 100644 index 0000000..e063aac --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/binaryauthorization/v1/service.proto @@ -0,0 +1,312 @@ +// 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.v1; + +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/v1/resources.proto"; +import "google/protobuf/empty.proto"; +import "grafeas/v1/attestation.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.BinaryAuthorization.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/binaryauthorization/v1;binaryauthorization"; +option java_multiple_files = false; +option java_package = "com.google.protos.google.cloud.binaryauthorization.v1"; +option php_namespace = "Google\\Cloud\\BinaryAuthorization\\V1"; +option ruby_package = "Google::Cloud::BinaryAuthorization::V1"; + +// 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.v1.Policy] +// * [Attestor][google.cloud.binaryauthorization.v1.Attestor] +service BinauthzManagementServiceV1 { + 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.v1.Policy] specifies the [attestors][google.cloud.binaryauthorization.v1.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.v1.Policy] for this project. Returns a default + // [policy][google.cloud.binaryauthorization.v1.Policy] if the project does not have one. + rpc GetPolicy(GetPolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/v1/{name=projects/*/policy}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates or updates a project's [policy][google.cloud.binaryauthorization.v1.Policy], and returns a copy of the + // new [policy][google.cloud.binaryauthorization.v1.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: "/v1/{policy.name=projects/*/policy}" + body: "policy" + }; + option (google.api.method_signature) = "policy"; + } + + // Creates an [attestor][google.cloud.binaryauthorization.v1.Attestor], and returns a copy of the new + // [attestor][google.cloud.binaryauthorization.v1.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.v1.Attestor] already exists. + rpc CreateAttestor(CreateAttestorRequest) returns (Attestor) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/attestors" + body: "attestor" + }; + option (google.api.method_signature) = "parent,attestor_id,attestor"; + } + + // Gets an [attestor][google.cloud.binaryauthorization.v1.Attestor]. + // Returns NOT_FOUND if the [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. + rpc GetAttestor(GetAttestorRequest) returns (Attestor) { + option (google.api.http) = { + get: "/v1/{name=projects/*/attestors/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates an [attestor][google.cloud.binaryauthorization.v1.Attestor]. + // Returns NOT_FOUND if the [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. + rpc UpdateAttestor(UpdateAttestorRequest) returns (Attestor) { + option (google.api.http) = { + put: "/v1/{attestor.name=projects/*/attestors/*}" + body: "attestor" + }; + option (google.api.method_signature) = "attestor"; + } + + // Lists [attestors][google.cloud.binaryauthorization.v1.Attestor]. + // Returns INVALID_ARGUMENT if the project does not exist. + rpc ListAttestors(ListAttestorsRequest) returns (ListAttestorsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/attestors" + }; + option (google.api.method_signature) = "parent"; + } + + // Deletes an [attestor][google.cloud.binaryauthorization.v1.Attestor]. Returns NOT_FOUND if the + // [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. + rpc DeleteAttestor(DeleteAttestorRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/attestors/*}" + }; + option (google.api.method_signature) = "name"; + } +} + +// API for working with the system policy. +service SystemPolicyV1 { + option (google.api.default_host) = "binaryauthorization.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Gets the current system policy in the specified location. + rpc GetSystemPolicy(GetSystemPolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/v1/{name=locations/*/policy}" + }; + option (google.api.method_signature) = "name"; + } +} + +// BinAuthz Attestor verification +service ValidationHelperV1 { + option (google.api.default_host) = "binaryauthorization.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Returns whether the given Attestation for the given image URI + // was signed by the given Attestor + rpc ValidateAttestationOccurrence(ValidateAttestationOccurrenceRequest) returns (ValidateAttestationOccurrenceResponse) { + option (google.api.http) = { + post: "/v1/{attestor=projects/*/attestors/*}:validateAttestationOccurrence" + body: "*" + }; + } +} + +// Request message for [BinauthzManagementService.GetPolicy][]. +message GetPolicyRequest { + // Required. The resource name of the [policy][google.cloud.binaryauthorization.v1.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.v1.Policy] value. The service will + // overwrite the [policy name][google.cloud.binaryauthorization.v1.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.v1.Attestor]. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The [attestors][google.cloud.binaryauthorization.v1.Attestor] ID. + string attestor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The initial [attestor][google.cloud.binaryauthorization.v1.Attestor] value. The service will + // overwrite the [attestor name][google.cloud.binaryauthorization.v1.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.v1.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.v1.Attestor] value. The service will + // overwrite the [attestor name][google.cloud.binaryauthorization.v1.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.v1.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.v1.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.v1.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.v1.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.v1.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" + } + ]; +} + +// Request to read the current system policy. +message GetSystemPolicyRequest { + // Required. The resource name, in the format `locations/*/policy`. + // Note that the system policy is not associated with a project. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "binaryauthorization.googleapis.com/Policy" + } + ]; +} + +// Request message for +// [ValidationHelperV1.ValidateAttestationOccurrence][google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence]. +message ValidateAttestationOccurrenceRequest { + // Required. The resource name of the [Attestor][google.cloud.binaryauthorization.v1.Attestor] of the + // [occurrence][grafeas.v1.Occurrence], in the format + // `projects/*/attestors/*`. + string attestor = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. An [AttestationOccurrence][grafeas.v1.AttestationOccurrence] to + // be checked that it can be verified by the Attestor. It does not have to be + // an existing entity in Container Analysis. It must otherwise be a valid + // AttestationOccurrence. + grafeas.v1.AttestationOccurrence attestation = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The resource name of the [Note][grafeas.v1.Note] to which the + // containing [Occurrence][grafeas.v1.Occurrence] is associated. + string occurrence_note = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. The URI of the artifact (e.g. container image) that is the + // subject of the containing [Occurrence][grafeas.v1.Occurrence]. + string occurrence_resource_uri = 4 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for +// [ValidationHelperV1.ValidateAttestationOccurrence][google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence]. +message ValidateAttestationOccurrenceResponse { + // The enum returned in the "result" field. + enum Result { + // Unspecified. + RESULT_UNSPECIFIED = 0; + + // The Attestation was able to verified by the Attestor. + VERIFIED = 1; + + // The Attestation was not able to verified by the Attestor. + ATTESTATION_NOT_VERIFIABLE = 2; + } + + // The result of the Attestation validation. + Result result = 1; + + // The reason for denial if the Attestation couldn't be validated. + string denial_reason = 2; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.create_attestor.js b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.create_attestor.js new file mode 100644 index 0000000..b6bf5be --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.create_attestor.js @@ -0,0 +1,65 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent, attestorId, attestor) { + // [START binaryauthorization_create_attestor_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent of this [attestor][google.cloud.binaryauthorization.v1.Attestor]. + */ + // const parent = 'abc123' + /** + * Required. The [attestors][google.cloud.binaryauthorization.v1.Attestor] ID. + */ + // const attestorId = 'abc123' + /** + * Required. The initial [attestor][google.cloud.binaryauthorization.v1.Attestor] value. The service will + * overwrite the [attestor name][google.cloud.binaryauthorization.v1.Attestor.name] field with the resource name, + * in the format `projects/* /attestors/*`. + */ + // const attestor = '' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Client} = require('@google-cloud/binaryauthorization').v1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Client(); + + async function createAttestor() { + // Construct request + const request = { + parent, + attestorId, + attestor, + }; + + // Run request + const response = await binaryauthorizationClient.createAttestor(request); + console.log(response); + } + + createAttestor(); + // [END binaryauthorization_create_attestor_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.delete_attestor.js b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.delete_attestor.js new file mode 100644 index 0000000..32deda9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.delete_attestor.js @@ -0,0 +1,54 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START binaryauthorization_delete_attestor_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the [attestors][google.cloud.binaryauthorization.v1.Attestor] to delete, in the format + * `projects/* /attestors/*`. + */ + // const name = 'abc123' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Client} = require('@google-cloud/binaryauthorization').v1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Client(); + + async function deleteAttestor() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await binaryauthorizationClient.deleteAttestor(request); + console.log(response); + } + + deleteAttestor(); + // [END binaryauthorization_delete_attestor_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.get_attestor.js b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.get_attestor.js new file mode 100644 index 0000000..841c8af --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.get_attestor.js @@ -0,0 +1,54 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START binaryauthorization_get_attestor_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the [attestor][google.cloud.binaryauthorization.v1.Attestor] to retrieve, in the format + * `projects/* /attestors/*`. + */ + // const name = 'abc123' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Client} = require('@google-cloud/binaryauthorization').v1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Client(); + + async function getAttestor() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await binaryauthorizationClient.getAttestor(request); + console.log(response); + } + + getAttestor(); + // [END binaryauthorization_get_attestor_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.get_policy.js b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.get_policy.js new file mode 100644 index 0000000..85d0420 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.get_policy.js @@ -0,0 +1,54 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START binaryauthorization_get_policy_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [policy][google.cloud.binaryauthorization.v1.Policy] to retrieve, + * in the format `projects/* /policy`. + */ + // const name = 'abc123' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Client} = require('@google-cloud/binaryauthorization').v1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Client(); + + async function getPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await binaryauthorizationClient.getPolicy(request); + console.log(response); + } + + getPolicy(); + // [END binaryauthorization_get_policy_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.list_attestors.js b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.list_attestors.js new file mode 100644 index 0000000..0b0740d --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.list_attestors.js @@ -0,0 +1,67 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent) { + // [START binaryauthorization_list_attestors_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the project associated with the + * [attestors][google.cloud.binaryauthorization.v1.Attestor], in the format `projects/*`. + */ + // const parent = 'abc123' + /** + * Requested page size. The server may return fewer results than requested. If + * unspecified, the server will pick an appropriate default. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results the server should return. Typically, + * this is the value of [ListAttestorsResponse.next_page_token][google.cloud.binaryauthorization.v1.ListAttestorsResponse.next_page_token] returned + * from the previous call to the `ListAttestors` method. + */ + // const pageToken = 'abc123' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Client} = require('@google-cloud/binaryauthorization').v1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Client(); + + async function listAttestors() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await binaryauthorizationClient.listAttestorsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listAttestors(); + // [END binaryauthorization_list_attestors_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.update_attestor.js b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.update_attestor.js new file mode 100644 index 0000000..29b1303 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.update_attestor.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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(attestor) { + // [START binaryauthorization_update_attestor_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The updated [attestor][google.cloud.binaryauthorization.v1.Attestor] value. The service will + * overwrite the [attestor name][google.cloud.binaryauthorization.v1.Attestor.name] field with the resource name + * in the request URL, in the format `projects/* /attestors/*`. + */ + // const attestor = '' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Client} = require('@google-cloud/binaryauthorization').v1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Client(); + + async function updateAttestor() { + // Construct request + const request = { + attestor, + }; + + // Run request + const response = await binaryauthorizationClient.updateAttestor(request); + console.log(response); + } + + updateAttestor(); + // [END binaryauthorization_update_attestor_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.update_policy.js b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.update_policy.js new file mode 100644 index 0000000..69f5a03 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/binauthz_management_service_v1.update_policy.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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(policy) { + // [START binaryauthorization_update_policy_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A new or updated [policy][google.cloud.binaryauthorization.v1.Policy] value. The service will + * overwrite the [policy name][google.cloud.binaryauthorization.v1.Policy.name] field with the resource name in + * the request URL, in the format `projects/* /policy`. + */ + // const policy = '' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Client} = require('@google-cloud/binaryauthorization').v1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Client(); + + async function updatePolicy() { + // Construct request + const request = { + policy, + }; + + // Run request + const response = await binaryauthorizationClient.updatePolicy(request); + console.log(response); + } + + updatePolicy(); + // [END binaryauthorization_update_policy_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/system_policy_v1.get_system_policy.js b/owl-bot-staging/v1/samples/generated/v1/system_policy_v1.get_system_policy.js new file mode 100644 index 0000000..fec2bd2 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/system_policy_v1.get_system_policy.js @@ -0,0 +1,54 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START binaryauthorization_get_system_policy_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name, in the format `locations/* /policy`. + * Note that the system policy is not associated with a project. + */ + // const name = 'abc123' + + // Imports the Binaryauthorization library + const {SystemPolicyV1Client} = require('@google-cloud/binaryauthorization').v1; + + // Instantiates a client + const binaryauthorizationClient = new SystemPolicyV1Client(); + + async function getSystemPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await binaryauthorizationClient.getSystemPolicy(request); + console.log(response); + } + + getSystemPolicy(); + // [END binaryauthorization_get_system_policy_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/validation_helper_v1.validate_attestation_occurrence.js b/owl-bot-staging/v1/samples/generated/v1/validation_helper_v1.validate_attestation_occurrence.js new file mode 100644 index 0000000..10803d9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/validation_helper_v1.validate_attestation_occurrence.js @@ -0,0 +1,75 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(attestor, attestation, occurrenceNote, occurrenceResourceUri) { + // [START binaryauthorization_validate_attestation_occurrence_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [Attestor][google.cloud.binaryauthorization.v1.Attestor] of the + * [occurrence][grafeas.v1.Occurrence], in the format + * `projects/* /attestors/*`. + */ + // const attestor = 'abc123' + /** + * Required. An [AttestationOccurrence][grafeas.v1.AttestationOccurrence] to + * be checked that it can be verified by the Attestor. It does not have to be + * an existing entity in Container Analysis. It must otherwise be a valid + * AttestationOccurrence. + */ + // const attestation = '' + /** + * Required. The resource name of the [Note][grafeas.v1.Note] to which the + * containing [Occurrence][grafeas.v1.Occurrence] is associated. + */ + // const occurrenceNote = 'abc123' + /** + * Required. The URI of the artifact (e.g. container image) that is the + * subject of the containing [Occurrence][grafeas.v1.Occurrence]. + */ + // const occurrenceResourceUri = 'abc123' + + // Imports the Binaryauthorization library + const {ValidationHelperV1Client} = require('@google-cloud/binaryauthorization').v1; + + // Instantiates a client + const binaryauthorizationClient = new ValidationHelperV1Client(); + + async function validateAttestationOccurrence() { + // Construct request + const request = { + attestor, + attestation, + occurrenceNote, + occurrenceResourceUri, + }; + + // Run request + const response = await binaryauthorizationClient.validateAttestationOccurrence(request); + console.log(response); + } + + validateAttestationOccurrence(); + // [END binaryauthorization_validate_attestation_occurrence_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 0000000..ddd37fe --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,29 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const BinauthzManagementServiceV1Client = v1.BinauthzManagementServiceV1Client; +type BinauthzManagementServiceV1Client = v1.BinauthzManagementServiceV1Client; +const SystemPolicyV1Client = v1.SystemPolicyV1Client; +type SystemPolicyV1Client = v1.SystemPolicyV1Client; +const ValidationHelperV1Client = v1.ValidationHelperV1Client; +type ValidationHelperV1Client = v1.ValidationHelperV1Client; +export {v1, BinauthzManagementServiceV1Client, SystemPolicyV1Client, ValidationHelperV1Client}; +export default {v1, BinauthzManagementServiceV1Client, SystemPolicyV1Client, ValidationHelperV1Client}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/binauthz_management_service_v1_client.ts b/owl-bot-staging/v1/src/v1/binauthz_management_service_v1_client.ts new file mode 100644 index 0000000..f86f23b --- /dev/null +++ b/owl-bot-staging/v1/src/v1/binauthz_management_service_v1_client.ts @@ -0,0 +1,1119 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/binauthz_management_service_v1_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_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.v1.Policy|Policy} + * * {@link google.cloud.binaryauthorization.v1.Attestor|Attestor} + * @class + * @memberof v1 + */ +export class BinauthzManagementServiceV1Client { + 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}; + binauthzManagementServiceV1Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of BinauthzManagementServiceV1Client. + * + * @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 BinauthzManagementServiceV1Client; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attestorPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/attestors/{attestor}' + ), + locationPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'locations/{location}/policy' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/policy' + ), + }; + + // 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.v1.BinauthzManagementServiceV1', 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.binauthzManagementServiceV1Stub) { + return this.binauthzManagementServiceV1Stub; + } + + // Put together the "service stub" for + // google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1. + this.binauthzManagementServiceV1Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1, + 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 binauthzManagementServiceV1StubMethods = + ['getPolicy', 'updatePolicy', 'createAttestor', 'getAttestor', 'updateAttestor', 'listAttestors', 'deleteAttestor']; + for (const methodName of binauthzManagementServiceV1StubMethods) { + const callPromise = this.binauthzManagementServiceV1Stub.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.binauthzManagementServiceV1Stub; + } + + /** + * 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.v1.IGetPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetPolicyRequest|undefined, {}|undefined + ]>; + getPolicy( + request: protos.google.cloud.binaryauthorization.v1.IGetPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetPolicyRequest|null|undefined, + {}|null|undefined>): void; + getPolicy( + request: protos.google.cloud.binaryauthorization.v1.IGetPolicyRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetPolicyRequest|null|undefined, + {}|null|undefined>): void; +/** + * A {@link google.cloud.binaryauthorization.v1.Policy|policy} specifies the {@link google.cloud.binaryauthorization.v1.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.v1.Policy|policy} for this project. Returns a default + * {@link google.cloud.binaryauthorization.v1.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.v1.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.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getPolicy(request); + * + * @example include:samples/generated/v1/binauthz_management_service_v1.get_policy.js + * region_tag:binaryauthorization_get_policy_sample + * + */ + getPolicy( + request?: protos.google.cloud.binaryauthorization.v1.IGetPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.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.v1.IUpdatePolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IUpdatePolicyRequest|undefined, {}|undefined + ]>; + updatePolicy( + request: protos.google.cloud.binaryauthorization.v1.IUpdatePolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>): void; + updatePolicy( + request: protos.google.cloud.binaryauthorization.v1.IUpdatePolicyRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates or updates a project's {@link google.cloud.binaryauthorization.v1.Policy|policy}, and returns a copy of the + * new {@link google.cloud.binaryauthorization.v1.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.v1.Policy} request.policy + * Required. A new or updated {@link google.cloud.binaryauthorization.v1.Policy|policy} value. The service will + * overwrite the {@link google.cloud.binaryauthorization.v1.Policy.name|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.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updatePolicy(request); + * + * @example include:samples/generated/v1/binauthz_management_service_v1.update_policy.js + * region_tag:binaryauthorization_update_policy_sample + * + */ + updatePolicy( + request?: protos.google.cloud.binaryauthorization.v1.IUpdatePolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IUpdatePolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.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.v1.ICreateAttestorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.ICreateAttestorRequest|undefined, {}|undefined + ]>; + createAttestor( + request: protos.google.cloud.binaryauthorization.v1.ICreateAttestorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.ICreateAttestorRequest|null|undefined, + {}|null|undefined>): void; + createAttestor( + request: protos.google.cloud.binaryauthorization.v1.ICreateAttestorRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.ICreateAttestorRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates an {@link google.cloud.binaryauthorization.v1.Attestor|attestor}, and returns a copy of the new + * {@link google.cloud.binaryauthorization.v1.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.v1.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.v1.Attestor|attestor}. + * @param {string} request.attestorId + * Required. The {@link google.cloud.binaryauthorization.v1.Attestor|attestors} ID. + * @param {google.cloud.binaryauthorization.v1.Attestor} request.attestor + * Required. The initial {@link google.cloud.binaryauthorization.v1.Attestor|attestor} value. The service will + * overwrite the {@link google.cloud.binaryauthorization.v1.Attestor.name|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.v1.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); + * + * @example include:samples/generated/v1/binauthz_management_service_v1.create_attestor.js + * region_tag:binaryauthorization_create_attestor_sample + * + */ + createAttestor( + request?: protos.google.cloud.binaryauthorization.v1.ICreateAttestorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.ICreateAttestorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.ICreateAttestorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.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.v1.IGetAttestorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.IGetAttestorRequest|undefined, {}|undefined + ]>; + getAttestor( + request: protos.google.cloud.binaryauthorization.v1.IGetAttestorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.IGetAttestorRequest|null|undefined, + {}|null|undefined>): void; + getAttestor( + request: protos.google.cloud.binaryauthorization.v1.IGetAttestorRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.IGetAttestorRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets an {@link google.cloud.binaryauthorization.v1.Attestor|attestor}. + * Returns NOT_FOUND if the {@link google.cloud.binaryauthorization.v1.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.v1.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.v1.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); + * + * @example include:samples/generated/v1/binauthz_management_service_v1.get_attestor.js + * region_tag:binaryauthorization_get_attestor_sample + * + */ + getAttestor( + request?: protos.google.cloud.binaryauthorization.v1.IGetAttestorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.IGetAttestorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.IGetAttestorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.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.v1.IUpdateAttestorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.IUpdateAttestorRequest|undefined, {}|undefined + ]>; + updateAttestor( + request: protos.google.cloud.binaryauthorization.v1.IUpdateAttestorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.IUpdateAttestorRequest|null|undefined, + {}|null|undefined>): void; + updateAttestor( + request: protos.google.cloud.binaryauthorization.v1.IUpdateAttestorRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.IUpdateAttestorRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates an {@link google.cloud.binaryauthorization.v1.Attestor|attestor}. + * Returns NOT_FOUND if the {@link google.cloud.binaryauthorization.v1.Attestor|attestor} does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.binaryauthorization.v1.Attestor} request.attestor + * Required. The updated {@link google.cloud.binaryauthorization.v1.Attestor|attestor} value. The service will + * overwrite the {@link google.cloud.binaryauthorization.v1.Attestor.name|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.v1.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); + * + * @example include:samples/generated/v1/binauthz_management_service_v1.update_attestor.js + * region_tag:binaryauthorization_update_attestor_sample + * + */ + updateAttestor( + request?: protos.google.cloud.binaryauthorization.v1.IUpdateAttestorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.IUpdateAttestorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.IUpdateAttestorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IAttestor, + protos.google.cloud.binaryauthorization.v1.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.v1.IDeleteAttestorRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1.IDeleteAttestorRequest|undefined, {}|undefined + ]>; + deleteAttestor( + request: protos.google.cloud.binaryauthorization.v1.IDeleteAttestorRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1.IDeleteAttestorRequest|null|undefined, + {}|null|undefined>): void; + deleteAttestor( + request: protos.google.cloud.binaryauthorization.v1.IDeleteAttestorRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1.IDeleteAttestorRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes an {@link google.cloud.binaryauthorization.v1.Attestor|attestor}. Returns NOT_FOUND if the + * {@link google.cloud.binaryauthorization.v1.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.v1.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); + * + * @example include:samples/generated/v1/binauthz_management_service_v1.delete_attestor.js + * region_tag:binaryauthorization_delete_attestor_sample + * + */ + deleteAttestor( + request?: protos.google.cloud.binaryauthorization.v1.IDeleteAttestorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1.IDeleteAttestorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1.IDeleteAttestorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.binaryauthorization.v1.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.v1.IListAttestorsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IAttestor[], + protos.google.cloud.binaryauthorization.v1.IListAttestorsRequest|null, + protos.google.cloud.binaryauthorization.v1.IListAttestorsResponse + ]>; + listAttestors( + request: protos.google.cloud.binaryauthorization.v1.IListAttestorsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.binaryauthorization.v1.IListAttestorsRequest, + protos.google.cloud.binaryauthorization.v1.IListAttestorsResponse|null|undefined, + protos.google.cloud.binaryauthorization.v1.IAttestor>): void; + listAttestors( + request: protos.google.cloud.binaryauthorization.v1.IListAttestorsRequest, + callback: PaginationCallback< + protos.google.cloud.binaryauthorization.v1.IListAttestorsRequest, + protos.google.cloud.binaryauthorization.v1.IListAttestorsResponse|null|undefined, + protos.google.cloud.binaryauthorization.v1.IAttestor>): void; +/** + * Lists {@link google.cloud.binaryauthorization.v1.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.v1.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.v1.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.v1.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. + * + * @example include:samples/generated/v1/binauthz_management_service_v1.list_attestors.js + * region_tag:binaryauthorization_list_attestors_sample + * + */ + listAttestors( + request?: protos.google.cloud.binaryauthorization.v1.IListAttestorsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.binaryauthorization.v1.IListAttestorsRequest, + protos.google.cloud.binaryauthorization.v1.IListAttestorsResponse|null|undefined, + protos.google.cloud.binaryauthorization.v1.IAttestor>, + callback?: PaginationCallback< + protos.google.cloud.binaryauthorization.v1.IListAttestorsRequest, + protos.google.cloud.binaryauthorization.v1.IListAttestorsResponse|null|undefined, + protos.google.cloud.binaryauthorization.v1.IAttestor>): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IAttestor[], + protos.google.cloud.binaryauthorization.v1.IListAttestorsRequest|null, + protos.google.cloud.binaryauthorization.v1.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.v1.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.v1.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.v1.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. + * + * @example include:samples/generated/v1/binauthz_management_service_v1.list_attestors.js + * region_tag:binaryauthorization_list_attestors_sample + * + */ + listAttestorsStream( + request?: protos.google.cloud.binaryauthorization.v1.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 defaultCallSettings = this._defaults['listAttestors']; + const callSettings = defaultCallSettings.merge(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.v1.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.v1.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.v1.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 + * } + * + * @example include:samples/generated/v1/binauthz_management_service_v1.list_attestors.js + * region_tag:binaryauthorization_list_attestors_sample + * + */ + listAttestorsAsync( + request?: protos.google.cloud.binaryauthorization.v1.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 defaultCallSettings = this._defaults['listAttestors']; + const callSettings = defaultCallSettings.merge(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 locationPolicy resource name string. + * + * @param {string} location + * @returns {string} Resource name string. + */ + locationPolicyPath(location:string) { + return this.pathTemplates.locationPolicyPathTemplate.render({ + location: location, + }); + } + + /** + * Parse the location from LocationPolicy resource. + * + * @param {string} locationPolicyName + * A fully-qualified path representing location_policy resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationPolicyName(locationPolicyName: string) { + return this.pathTemplates.locationPolicyPathTemplate.match(locationPolicyName).location; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified projectPolicy resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPolicyPath(project:string) { + return this.pathTemplates.projectPolicyPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from ProjectPolicy resource. + * + * @param {string} projectPolicyName + * A fully-qualified path representing project_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectPolicyName(projectPolicyName: string) { + return this.pathTemplates.projectPolicyPathTemplate.match(projectPolicyName).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.binauthzManagementServiceV1Stub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/binauthz_management_service_v1_client_config.json b/owl-bot-staging/v1/src/v1/binauthz_management_service_v1_client_config.json new file mode 100644 index 0000000..d8357fd --- /dev/null +++ b/owl-bot-staging/v1/src/v1/binauthz_management_service_v1_client_config.json @@ -0,0 +1,61 @@ +{ + "interfaces": { + "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1": { + "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/v1/src/v1/binauthz_management_service_v1_proto_list.json b/owl-bot-staging/v1/src/v1/binauthz_management_service_v1_proto_list.json new file mode 100644 index 0000000..2e7010a --- /dev/null +++ b/owl-bot-staging/v1/src/v1/binauthz_management_service_v1_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/binaryauthorization/v1/resources.proto", + "../../protos/google/cloud/binaryauthorization/v1/service.proto", + "../../protos/grafeas/v1/attestation.proto", + "../../protos/grafeas/v1/common.proto" +] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 0000000..8944b91 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,145 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.binaryauthorization.v1", + "libraryPackage": "@google-cloud/binaryauthorization", + "services": { + "BinauthzManagementServiceV1": { + "clients": { + "grpc": { + "libraryClient": "BinauthzManagementServiceV1Client", + "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": "BinauthzManagementServiceV1Client", + "rpcs": { + "GetPolicy": { + "methods": [ + "getPolicy" + ] + }, + "UpdatePolicy": { + "methods": [ + "updatePolicy" + ] + }, + "CreateAttestor": { + "methods": [ + "createAttestor" + ] + }, + "GetAttestor": { + "methods": [ + "getAttestor" + ] + }, + "UpdateAttestor": { + "methods": [ + "updateAttestor" + ] + }, + "DeleteAttestor": { + "methods": [ + "deleteAttestor" + ] + }, + "ListAttestors": { + "methods": [ + "listAttestors", + "listAttestorsStream", + "listAttestorsAsync" + ] + } + } + } + } + }, + "SystemPolicyV1": { + "clients": { + "grpc": { + "libraryClient": "SystemPolicyV1Client", + "rpcs": { + "GetSystemPolicy": { + "methods": [ + "getSystemPolicy" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SystemPolicyV1Client", + "rpcs": { + "GetSystemPolicy": { + "methods": [ + "getSystemPolicy" + ] + } + } + } + } + }, + "ValidationHelperV1": { + "clients": { + "grpc": { + "libraryClient": "ValidationHelperV1Client", + "rpcs": { + "ValidateAttestationOccurrence": { + "methods": [ + "validateAttestationOccurrence" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ValidationHelperV1Client", + "rpcs": { + "ValidateAttestationOccurrence": { + "methods": [ + "validateAttestationOccurrence" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 0000000..956991f --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,21 @@ +// 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 {BinauthzManagementServiceV1Client} from './binauthz_management_service_v1_client'; +export {SystemPolicyV1Client} from './system_policy_v1_client'; +export {ValidationHelperV1Client} from './validation_helper_v1_client'; diff --git a/owl-bot-staging/v1/src/v1/system_policy_v1_client.ts b/owl-bot-staging/v1/src/v1/system_policy_v1_client.ts new file mode 100644 index 0000000..09693a3 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/system_policy_v1_client.ts @@ -0,0 +1,497 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/system_policy_v1_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './system_policy_v1_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * API for working with the system policy. + * @class + * @memberof v1 + */ +export class SystemPolicyV1Client { + 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}; + systemPolicyV1Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SystemPolicyV1Client. + * + * @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 SystemPolicyV1Client; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attestorPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/attestors/{attestor}' + ), + locationPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'locations/{location}/policy' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/policy' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.binaryauthorization.v1.SystemPolicyV1', 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.systemPolicyV1Stub) { + return this.systemPolicyV1Stub; + } + + // Put together the "service stub" for + // google.cloud.binaryauthorization.v1.SystemPolicyV1. + this.systemPolicyV1Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.binaryauthorization.v1.SystemPolicyV1') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.binaryauthorization.v1.SystemPolicyV1, + 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 systemPolicyV1StubMethods = + ['getSystemPolicy']; + for (const methodName of systemPolicyV1StubMethods) { + const callPromise = this.systemPolicyV1Stub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.systemPolicyV1Stub; + } + + /** + * 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 -- + // ------------------- + getSystemPolicy( + request?: protos.google.cloud.binaryauthorization.v1.IGetSystemPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetSystemPolicyRequest|undefined, {}|undefined + ]>; + getSystemPolicy( + request: protos.google.cloud.binaryauthorization.v1.IGetSystemPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetSystemPolicyRequest|null|undefined, + {}|null|undefined>): void; + getSystemPolicy( + request: protos.google.cloud.binaryauthorization.v1.IGetSystemPolicyRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetSystemPolicyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets the current system policy in the specified location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name, in the format `locations/* /policy`. + * Note that the system policy is not associated with a project. + * @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.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getSystemPolicy(request); + * + * @example include:samples/generated/v1/system_policy_v1.get_system_policy.js + * region_tag:binaryauthorization_get_system_policy_sample + * + */ + getSystemPolicy( + request?: protos.google.cloud.binaryauthorization.v1.IGetSystemPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetSystemPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetSystemPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IPolicy, + protos.google.cloud.binaryauthorization.v1.IGetSystemPolicyRequest|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.getSystemPolicy(request, options, callback); + } + + // -------------------- + // -- 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 locationPolicy resource name string. + * + * @param {string} location + * @returns {string} Resource name string. + */ + locationPolicyPath(location:string) { + return this.pathTemplates.locationPolicyPathTemplate.render({ + location: location, + }); + } + + /** + * Parse the location from LocationPolicy resource. + * + * @param {string} locationPolicyName + * A fully-qualified path representing location_policy resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationPolicyName(locationPolicyName: string) { + return this.pathTemplates.locationPolicyPathTemplate.match(locationPolicyName).location; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified projectPolicy resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPolicyPath(project:string) { + return this.pathTemplates.projectPolicyPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from ProjectPolicy resource. + * + * @param {string} projectPolicyName + * A fully-qualified path representing project_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectPolicyName(projectPolicyName: string) { + return this.pathTemplates.projectPolicyPathTemplate.match(projectPolicyName).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.systemPolicyV1Stub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/system_policy_v1_client_config.json b/owl-bot-staging/v1/src/v1/system_policy_v1_client_config.json new file mode 100644 index 0000000..1d25944 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/system_policy_v1_client_config.json @@ -0,0 +1,30 @@ +{ + "interfaces": { + "google.cloud.binaryauthorization.v1.SystemPolicyV1": { + "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": { + "GetSystemPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/system_policy_v1_proto_list.json b/owl-bot-staging/v1/src/v1/system_policy_v1_proto_list.json new file mode 100644 index 0000000..2e7010a --- /dev/null +++ b/owl-bot-staging/v1/src/v1/system_policy_v1_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/binaryauthorization/v1/resources.proto", + "../../protos/google/cloud/binaryauthorization/v1/service.proto", + "../../protos/grafeas/v1/attestation.proto", + "../../protos/grafeas/v1/common.proto" +] diff --git a/owl-bot-staging/v1/src/v1/validation_helper_v1_client.ts b/owl-bot-staging/v1/src/v1/validation_helper_v1_client.ts new file mode 100644 index 0000000..1ba907f --- /dev/null +++ b/owl-bot-staging/v1/src/v1/validation_helper_v1_client.ts @@ -0,0 +1,510 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/validation_helper_v1_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './validation_helper_v1_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * BinAuthz Attestor verification + * @class + * @memberof v1 + */ +export class ValidationHelperV1Client { + 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}; + validationHelperV1Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ValidationHelperV1Client. + * + * @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 ValidationHelperV1Client; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attestorPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/attestors/{attestor}' + ), + locationPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'locations/{location}/policy' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/policy' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.binaryauthorization.v1.ValidationHelperV1', 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.validationHelperV1Stub) { + return this.validationHelperV1Stub; + } + + // Put together the "service stub" for + // google.cloud.binaryauthorization.v1.ValidationHelperV1. + this.validationHelperV1Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.binaryauthorization.v1.ValidationHelperV1') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.binaryauthorization.v1.ValidationHelperV1, + 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 validationHelperV1StubMethods = + ['validateAttestationOccurrence']; + for (const methodName of validationHelperV1StubMethods) { + const callPromise = this.validationHelperV1Stub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.validationHelperV1Stub; + } + + /** + * 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 -- + // ------------------- + validateAttestationOccurrence( + request?: protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceResponse, + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceRequest|undefined, {}|undefined + ]>; + validateAttestationOccurrence( + request: protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceResponse, + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceRequest|null|undefined, + {}|null|undefined>): void; + validateAttestationOccurrence( + request: protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceRequest, + callback: Callback< + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceResponse, + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceRequest|null|undefined, + {}|null|undefined>): void; +/** + * Returns whether the given Attestation for the given image URI + * was signed by the given Attestor + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attestor + * Required. The resource name of the {@link google.cloud.binaryauthorization.v1.Attestor|Attestor} of the + * {@link grafeas.v1.Occurrence|occurrence}, in the format + * `projects/* /attestors/*`. + * @param {grafeas.v1.AttestationOccurrence} request.attestation + * Required. An {@link grafeas.v1.AttestationOccurrence|AttestationOccurrence} to + * be checked that it can be verified by the Attestor. It does not have to be + * an existing entity in Container Analysis. It must otherwise be a valid + * AttestationOccurrence. + * @param {string} request.occurrenceNote + * Required. The resource name of the {@link grafeas.v1.Note|Note} to which the + * containing {@link grafeas.v1.Occurrence|Occurrence} is associated. + * @param {string} request.occurrenceResourceUri + * Required. The URI of the artifact (e.g. container image) that is the + * subject of the containing {@link grafeas.v1.Occurrence|Occurrence}. + * @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 [ValidateAttestationOccurrenceResponse]{@link google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceResponse}. + * 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.validateAttestationOccurrence(request); + * + * @example include:samples/generated/v1/validation_helper_v1.validate_attestation_occurrence.js + * region_tag:binaryauthorization_validate_attestation_occurrence_sample + * + */ + validateAttestationOccurrence( + request?: protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceResponse, + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceResponse, + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceResponse, + protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceRequest|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': request.attestor || '', + }); + this.initialize(); + return this.innerApiCalls.validateAttestationOccurrence(request, options, callback); + } + + // -------------------- + // -- 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 locationPolicy resource name string. + * + * @param {string} location + * @returns {string} Resource name string. + */ + locationPolicyPath(location:string) { + return this.pathTemplates.locationPolicyPathTemplate.render({ + location: location, + }); + } + + /** + * Parse the location from LocationPolicy resource. + * + * @param {string} locationPolicyName + * A fully-qualified path representing location_policy resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationPolicyName(locationPolicyName: string) { + return this.pathTemplates.locationPolicyPathTemplate.match(locationPolicyName).location; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified projectPolicy resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPolicyPath(project:string) { + return this.pathTemplates.projectPolicyPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from ProjectPolicy resource. + * + * @param {string} projectPolicyName + * A fully-qualified path representing project_policy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectPolicyName(projectPolicyName: string) { + return this.pathTemplates.projectPolicyPathTemplate.match(projectPolicyName).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.validationHelperV1Stub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/validation_helper_v1_client_config.json b/owl-bot-staging/v1/src/v1/validation_helper_v1_client_config.json new file mode 100644 index 0000000..7c2d8e6 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/validation_helper_v1_client_config.json @@ -0,0 +1,30 @@ +{ + "interfaces": { + "google.cloud.binaryauthorization.v1.ValidationHelperV1": { + "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": { + "ValidateAttestationOccurrence": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/validation_helper_v1_proto_list.json b/owl-bot-staging/v1/src/v1/validation_helper_v1_proto_list.json new file mode 100644 index 0000000..2e7010a --- /dev/null +++ b/owl-bot-staging/v1/src/v1/validation_helper_v1_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/binaryauthorization/v1/resources.proto", + "../../protos/google/cloud/binaryauthorization/v1/service.proto", + "../../protos/grafeas/v1/attestation.proto", + "../../protos/grafeas/v1/common.proto" +] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..cff77ce --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,29 @@ +// 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/binaryauthorization'); + +function main() { + const binauthzManagementServiceV1Client = new binaryauthorization.BinauthzManagementServiceV1Client(); + const systemPolicyV1Client = new binaryauthorization.SystemPolicyV1Client(); + const validationHelperV1Client = new binaryauthorization.ValidationHelperV1Client(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..cb97e05 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,44 @@ +// 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 {BinauthzManagementServiceV1Client, SystemPolicyV1Client, ValidationHelperV1Client} from '@google-cloud/binaryauthorization'; + +// check that the client class type name can be used +function doStuffWithBinauthzManagementServiceV1Client(client: BinauthzManagementServiceV1Client) { + client.close(); +} +function doStuffWithSystemPolicyV1Client(client: SystemPolicyV1Client) { + client.close(); +} +function doStuffWithValidationHelperV1Client(client: ValidationHelperV1Client) { + client.close(); +} + +function main() { + // check that the client instance can be created + const binauthzManagementServiceV1Client = new BinauthzManagementServiceV1Client(); + doStuffWithBinauthzManagementServiceV1Client(binauthzManagementServiceV1Client); + // check that the client instance can be created + const systemPolicyV1Client = new SystemPolicyV1Client(); + doStuffWithSystemPolicyV1Client(systemPolicyV1Client); + // check that the client instance can be created + const validationHelperV1Client = new ValidationHelperV1Client(); + doStuffWithValidationHelperV1Client(validationHelperV1Client); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1/test/gapic_binauthz_management_service_v1_v1.ts b/owl-bot-staging/v1/test/gapic_binauthz_management_service_v1_v1.ts new file mode 100644 index 0000000..406484b --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_binauthz_management_service_v1_v1.ts @@ -0,0 +1,1031 @@ +// 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 binauthzmanagementservicev1Module from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.BinauthzManagementServiceV1Client', () => { + it('has servicePath', () => { + const servicePath = binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.binauthzManagementServiceV1Stub, undefined); + await client.initialize(); + assert(client.binauthzManagementServiceV1Stub); + }); + + it('has close method', () => { + const client = new binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + 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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + 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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.GetPolicyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.GetPolicyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Policy()); + client.innerApiCalls.getPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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.v1.Policy()); + client.innerApiCalls.updatePolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePolicy( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.CreateAttestorRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.CreateAttestorRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()); + client.innerApiCalls.createAttestor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAttestor( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.GetAttestorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.GetAttestorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()); + client.innerApiCalls.getAttestor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttestor( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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.v1.Attestor()); + client.innerApiCalls.updateAttestor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttestor( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()), + ]; + client.innerApiCalls.listAttestors = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAttestors( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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.v1.Attestor[] = []; + stream.on('data', (response: protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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.v1.Attestor[] = []; + stream.on('data', (response: protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.ListAttestorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()), + generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Attestor()), + ]; + client.descriptors.page.listAttestors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.binaryauthorization.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.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.v1.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 binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + 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('locationPolicy', () => { + const fakePath = "/rendered/path/locationPolicy"; + const expectedParameters = { + location: "locationValue", + }; + const client = new binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPolicyPath', () => { + const result = client.locationPolicyPath("locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchLocationFromLocationPolicyName', () => { + const result = client.matchLocationFromLocationPolicyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectPolicy', () => { + const fakePath = "/rendered/path/projectPolicy"; + const expectedParameters = { + project: "projectValue", + }; + const client = new binauthzmanagementservicev1Module.v1.BinauthzManagementServiceV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPolicyPath', () => { + const result = client.projectPolicyPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectPolicyName', () => { + const result = client.matchProjectFromProjectPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/test/gapic_system_policy_v1_v1.ts b/owl-bot-staging/v1/test/gapic_system_policy_v1_v1.ts new file mode 100644 index 0000000..5020631 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_system_policy_v1_v1.ts @@ -0,0 +1,335 @@ +// 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 systempolicyv1Module from '../src'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1.SystemPolicyV1Client', () => { + it('has servicePath', () => { + const servicePath = systempolicyv1Module.v1.SystemPolicyV1Client.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = systempolicyv1Module.v1.SystemPolicyV1Client.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = systempolicyv1Module.v1.SystemPolicyV1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new systempolicyv1Module.v1.SystemPolicyV1Client(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.systemPolicyV1Stub, undefined); + await client.initialize(); + assert(client.systemPolicyV1Stub); + }); + + it('has close method', () => { + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + 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 systempolicyv1Module.v1.SystemPolicyV1Client({ + 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('getSystemPolicy', () => { + it('invokes getSystemPolicy without error', async () => { + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.GetSystemPolicyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Policy()); + client.innerApiCalls.getSystemPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getSystemPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getSystemPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getSystemPolicy without error using callback', async () => { + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.GetSystemPolicyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.Policy()); + client.innerApiCalls.getSystemPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSystemPolicy( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getSystemPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getSystemPolicy with error', async () => { + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.GetSystemPolicyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getSystemPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSystemPolicy(request), expectedError); + assert((client.innerApiCalls.getSystemPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('Path templates', () => { + + describe('attestor', () => { + const fakePath = "/rendered/path/attestor"; + const expectedParameters = { + project: "projectValue", + attestor: "attestorValue", + }; + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + 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('locationPolicy', () => { + const fakePath = "/rendered/path/locationPolicy"; + const expectedParameters = { + location: "locationValue", + }; + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPolicyPath', () => { + const result = client.locationPolicyPath("locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchLocationFromLocationPolicyName', () => { + const result = client.matchLocationFromLocationPolicyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectPolicy', () => { + const fakePath = "/rendered/path/projectPolicy"; + const expectedParameters = { + project: "projectValue", + }; + const client = new systempolicyv1Module.v1.SystemPolicyV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPolicyPath', () => { + const result = client.projectPolicyPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectPolicyName', () => { + const result = client.matchProjectFromProjectPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/test/gapic_validation_helper_v1_v1.ts b/owl-bot-staging/v1/test/gapic_validation_helper_v1_v1.ts new file mode 100644 index 0000000..a8e7258 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_validation_helper_v1_v1.ts @@ -0,0 +1,335 @@ +// 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 validationhelperv1Module from '../src'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1.ValidationHelperV1Client', () => { + it('has servicePath', () => { + const servicePath = validationhelperv1Module.v1.ValidationHelperV1Client.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = validationhelperv1Module.v1.ValidationHelperV1Client.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = validationhelperv1Module.v1.ValidationHelperV1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new validationhelperv1Module.v1.ValidationHelperV1Client(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.validationHelperV1Stub, undefined); + await client.initialize(); + assert(client.validationHelperV1Stub); + }); + + it('has close method', () => { + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + 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 validationhelperv1Module.v1.ValidationHelperV1Client({ + 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('validateAttestationOccurrence', () => { + it('invokes validateAttestationOccurrence without error', async () => { + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceRequest()); + request.attestor = ''; + const expectedHeaderRequestParams = "attestor="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceResponse()); + client.innerApiCalls.validateAttestationOccurrence = stubSimpleCall(expectedResponse); + const [response] = await client.validateAttestationOccurrence(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.validateAttestationOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes validateAttestationOccurrence without error using callback', async () => { + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceRequest()); + request.attestor = ''; + const expectedHeaderRequestParams = "attestor="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceResponse()); + client.innerApiCalls.validateAttestationOccurrence = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.validateAttestationOccurrence( + request, + (err?: Error|null, result?: protos.google.cloud.binaryauthorization.v1.IValidateAttestationOccurrenceResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.validateAttestationOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes validateAttestationOccurrence with error', async () => { + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceRequest()); + request.attestor = ''; + const expectedHeaderRequestParams = "attestor="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.validateAttestationOccurrence = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.validateAttestationOccurrence(request), expectedError); + assert((client.innerApiCalls.validateAttestationOccurrence as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('Path templates', () => { + + describe('attestor', () => { + const fakePath = "/rendered/path/attestor"; + const expectedParameters = { + project: "projectValue", + attestor: "attestorValue", + }; + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + 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('locationPolicy', () => { + const fakePath = "/rendered/path/locationPolicy"; + const expectedParameters = { + location: "locationValue", + }; + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPolicyPath', () => { + const result = client.locationPolicyPath("locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchLocationFromLocationPolicyName', () => { + const result = client.matchLocationFromLocationPolicyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectPolicy', () => { + const fakePath = "/rendered/path/projectPolicy"; + const expectedParameters = { + project: "projectValue", + }; + const client = new validationhelperv1Module.v1.ValidationHelperV1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPolicyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPolicyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPolicyPath', () => { + const result = client.projectPolicyPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPolicyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectPolicyName', () => { + const result = client.matchProjectFromProjectPolicyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPolicyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 0000000..2188a41 --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'BinauthzManagementServiceV1', + filename: './binauthz-management-service-v1.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v1beta1/.eslintignore b/owl-bot-staging/v1beta1/.eslintignore new file mode 100644 index 0000000..cfc348e --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1beta1/.eslintrc.json b/owl-bot-staging/v1beta1/.eslintrc.json new file mode 100644 index 0000000..7821534 --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1beta1/.gitignore b/owl-bot-staging/v1beta1/.gitignore new file mode 100644 index 0000000..5d32b23 --- /dev/null +++ b/owl-bot-staging/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1beta1/.jsdoc.js b/owl-bot-staging/v1beta1/.jsdoc.js new file mode 100644 index 0000000..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..a47810e --- /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.19.0" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@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": "^9.0.2", + "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..b596df9 --- /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 system policy evaluation. + ENABLE = 1; + + // Disables system 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/samples/generated/v1beta1/binauthz_management_service_v1_beta1.create_attestor.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.create_attestor.js new file mode 100644 index 0000000..c89189c --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.create_attestor.js @@ -0,0 +1,69 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent, attestorId, attestor) { + // [START binaryauthorization_create_attestor_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent of this + * [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. + */ + // const parent = 'abc123' + /** + * Required. The + * [attestors][google.cloud.binaryauthorization.v1beta1.Attestor] ID. + */ + // const attestorId = 'abc123' + /** + * 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/*`. + */ + // const attestor = '' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Beta1Client} = require('@google-cloud/binary-authorization').v1beta1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Beta1Client(); + + async function createAttestor() { + // Construct request + const request = { + parent, + attestorId, + attestor, + }; + + // Run request + const response = await binaryauthorizationClient.createAttestor(request); + console.log(response); + } + + createAttestor(); + // [END binaryauthorization_create_attestor_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.delete_attestor.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.delete_attestor.js new file mode 100644 index 0000000..88ee07d --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.delete_attestor.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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START binaryauthorization_delete_attestor_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the + * [attestors][google.cloud.binaryauthorization.v1beta1.Attestor] to delete, + * in the format `projects/* /attestors/*`. + */ + // const name = 'abc123' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Beta1Client} = require('@google-cloud/binary-authorization').v1beta1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Beta1Client(); + + async function deleteAttestor() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await binaryauthorizationClient.deleteAttestor(request); + console.log(response); + } + + deleteAttestor(); + // [END binaryauthorization_delete_attestor_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.get_attestor.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.get_attestor.js new file mode 100644 index 0000000..6662e06 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.get_attestor.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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START binaryauthorization_get_attestor_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the + * [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] to retrieve, + * in the format `projects/* /attestors/*`. + */ + // const name = 'abc123' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Beta1Client} = require('@google-cloud/binary-authorization').v1beta1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Beta1Client(); + + async function getAttestor() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await binaryauthorizationClient.getAttestor(request); + console.log(response); + } + + getAttestor(); + // [END binaryauthorization_get_attestor_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.get_policy.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.get_policy.js new file mode 100644 index 0000000..f79116d --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.get_policy.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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START binaryauthorization_get_policy_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the + * [policy][google.cloud.binaryauthorization.v1beta1.Policy] to retrieve, in + * the format `projects/* /policy`. + */ + // const name = 'abc123' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Beta1Client} = require('@google-cloud/binary-authorization').v1beta1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Beta1Client(); + + async function getPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await binaryauthorizationClient.getPolicy(request); + console.log(response); + } + + getPolicy(); + // [END binaryauthorization_get_policy_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.list_attestors.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.list_attestors.js new file mode 100644 index 0000000..1f8fc09 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.list_attestors.js @@ -0,0 +1,69 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent) { + // [START binaryauthorization_list_attestors_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the project associated with the + * [attestors][google.cloud.binaryauthorization.v1beta1.Attestor], in the + * format `projects/*`. + */ + // const parent = 'abc123' + /** + * Requested page size. The server may return fewer results than requested. If + * unspecified, the server will pick an appropriate default. + */ + // const pageSize = 1234 + /** + * 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. + */ + // const pageToken = 'abc123' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Beta1Client} = require('@google-cloud/binary-authorization').v1beta1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Beta1Client(); + + async function listAttestors() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await binaryauthorizationClient.listAttestorsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listAttestors(); + // [END binaryauthorization_list_attestors_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.update_attestor.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.update_attestor.js new file mode 100644 index 0000000..ada11c3 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.update_attestor.js @@ -0,0 +1,58 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(attestor) { + // [START binaryauthorization_update_attestor_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * 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/*`. + */ + // const attestor = '' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Beta1Client} = require('@google-cloud/binary-authorization').v1beta1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Beta1Client(); + + async function updateAttestor() { + // Construct request + const request = { + attestor, + }; + + // Run request + const response = await binaryauthorizationClient.updateAttestor(request); + console.log(response); + } + + updateAttestor(); + // [END binaryauthorization_update_attestor_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.update_policy.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.update_policy.js new file mode 100644 index 0000000..65251e3 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/binauthz_management_service_v1_beta1.update_policy.js @@ -0,0 +1,57 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(policy) { + // [START binaryauthorization_update_policy_sample] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * 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`. + */ + // const policy = '' + + // Imports the Binaryauthorization library + const {BinauthzManagementServiceV1Beta1Client} = require('@google-cloud/binary-authorization').v1beta1; + + // Instantiates a client + const binaryauthorizationClient = new BinauthzManagementServiceV1Beta1Client(); + + async function updatePolicy() { + // Construct request + const request = { + policy, + }; + + // Run request + const response = await binaryauthorizationClient.updatePolicy(request); + console.log(response); + } + + updatePolicy(); + // [END binaryauthorization_update_policy_sample] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts new file mode 100644 index 0000000..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..3e58f71 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/binauthz_management_service_v1_beta1_client.ts @@ -0,0 +1,1125 @@ +// 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 useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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); + * + * @example include:samples/generated/v1beta1/binauthz_management_service_v1_beta1.get_policy.js + * region_tag:binaryauthorization_get_policy_sample + * + */ + 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); + * + * @example include:samples/generated/v1beta1/binauthz_management_service_v1_beta1.update_policy.js + * region_tag:binaryauthorization_update_policy_sample + * + */ + 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); + * + * @example include:samples/generated/v1beta1/binauthz_management_service_v1_beta1.create_attestor.js + * region_tag:binaryauthorization_create_attestor_sample + * + */ + 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); + * + * @example include:samples/generated/v1beta1/binauthz_management_service_v1_beta1.get_attestor.js + * region_tag:binaryauthorization_get_attestor_sample + * + */ + 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); + * + * @example include:samples/generated/v1beta1/binauthz_management_service_v1_beta1.update_attestor.js + * region_tag:binaryauthorization_update_attestor_sample + * + */ + 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); + * + * @example include:samples/generated/v1beta1/binauthz_management_service_v1_beta1.delete_attestor.js + * region_tag:binaryauthorization_delete_attestor_sample + * + */ + 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. + * + * @example include:samples/generated/v1beta1/binauthz_management_service_v1_beta1.list_attestors.js + * region_tag:binaryauthorization_list_attestors_sample + * + */ + 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. + * + * @example include:samples/generated/v1beta1/binauthz_management_service_v1_beta1.list_attestors.js + * region_tag:binaryauthorization_list_attestors_sample + * + */ + 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 defaultCallSettings = this._defaults['listAttestors']; + const callSettings = defaultCallSettings.merge(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 + * } + * + * @example include:samples/generated/v1beta1/binauthz_management_service_v1_beta1.list_attestors.js + * region_tag:binaryauthorization_list_attestors_sample + * + */ + 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 defaultCallSettings = this._defaults['listAttestors']; + const callSettings = defaultCallSettings.merge(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..272c898 --- /dev/null +++ b/owl-bot-staging/v1beta1/test/gapic_binauthz_management_service_v1_beta1_v1beta1.ts @@ -0,0 +1,1001 @@ +// 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', +};