From 267db24dbb558bd4e8f740678a4d07dc800bd260 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 26 Aug 2022 23:11:33 +0000 Subject: [PATCH 1/4] feat: accept google-gax instance as a parameter Please see the documentation of the client constructor for details. PiperOrigin-RevId: 470332808 Source-Link: https://github.com/googleapis/googleapis/commit/d4a23675457cd8f0b44080e0594ec72de1291b89 Source-Link: https://github.com/googleapis/googleapis-gen/commit/e97a1ac204ead4fe7341f91e72db7c6ac6016341 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTk3YTFhYzIwNGVhZDRmZTczNDFmOTFlNzJkYjdjNmFjNjAxNjM0MSJ9 --- owl-bot-staging/v2/.eslintignore | 7 + owl-bot-staging/v2/.eslintrc.json | 3 + owl-bot-staging/v2/.gitignore | 14 + owl-bot-staging/v2/.jsdoc.js | 55 + owl-bot-staging/v2/.mocharc.js | 33 + owl-bot-staging/v2/.prettierrc.js | 22 + owl-bot-staging/v2/README.md | 1 + owl-bot-staging/v2/linkinator.config.json | 16 + owl-bot-staging/v2/package.json | 65 + .../google/cloud/run/v2/condition.proto | 199 +++ .../protos/google/cloud/run/v2/k8s.min.proto | 274 +++ .../protos/google/cloud/run/v2/revision.proto | 278 +++ .../cloud/run/v2/revision_template.proto | 79 + .../protos/google/cloud/run/v2/service.proto | 435 +++++ .../google/cloud/run/v2/traffic_target.proto | 77 + .../google/cloud/run/v2/vendor_settings.proto | 102 ++ .../generated/v2/revisions.delete_revision.js | 74 + .../generated/v2/revisions.get_revision.js | 63 + .../generated/v2/revisions.list_revisions.js | 79 + .../generated/v2/services.create_service.js | 79 + .../generated/v2/services.delete_service.js | 73 + .../generated/v2/services.get_iam_policy.js | 67 + .../generated/v2/services.get_service.js | 62 + .../generated/v2/services.list_services.js | 78 + .../generated/v2/services.set_iam_policy.js | 77 + .../v2/services.test_iam_permissions.js | 70 + .../generated/v2/services.update_service.js | 73 + .../snippet_metadata.google.cloud.run.v2.json | 531 ++++++ owl-bot-staging/v2/src/index.ts | 27 + owl-bot-staging/v2/src/v2/gapic_metadata.json | 155 ++ owl-bot-staging/v2/src/v2/index.ts | 20 + owl-bot-staging/v2/src/v2/revisions_client.ts | 1016 +++++++++++ .../v2/src/v2/revisions_client_config.json | 38 + .../v2/src/v2/revisions_proto_list.json | 9 + owl-bot-staging/v2/src/v2/services_client.ts | 1423 ++++++++++++++++ .../v2/src/v2/services_client_config.json | 75 + .../v2/src/v2/services_proto_list.json | 9 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + owl-bot-staging/v2/system-test/install.ts | 49 + owl-bot-staging/v2/test/gapic_revisions_v2.ts | 932 +++++++++++ owl-bot-staging/v2/test/gapic_services_v2.ts | 1485 +++++++++++++++++ owl-bot-staging/v2/tsconfig.json | 19 + owl-bot-staging/v2/webpack.config.js | 64 + 44 files changed, 8373 insertions(+) create mode 100644 owl-bot-staging/v2/.eslintignore create mode 100644 owl-bot-staging/v2/.eslintrc.json create mode 100644 owl-bot-staging/v2/.gitignore create mode 100644 owl-bot-staging/v2/.jsdoc.js create mode 100644 owl-bot-staging/v2/.mocharc.js create mode 100644 owl-bot-staging/v2/.prettierrc.js create mode 100644 owl-bot-staging/v2/README.md create mode 100644 owl-bot-staging/v2/linkinator.config.json create mode 100644 owl-bot-staging/v2/package.json create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto create mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.create_service.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.delete_service.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.get_service.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.list_services.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.update_service.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json create mode 100644 owl-bot-staging/v2/src/index.ts create mode 100644 owl-bot-staging/v2/src/v2/gapic_metadata.json create mode 100644 owl-bot-staging/v2/src/v2/index.ts create mode 100644 owl-bot-staging/v2/src/v2/revisions_client.ts create mode 100644 owl-bot-staging/v2/src/v2/revisions_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/revisions_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/services_client.ts create mode 100644 owl-bot-staging/v2/src/v2/services_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/services_proto_list.json create mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v2/system-test/install.ts create mode 100644 owl-bot-staging/v2/test/gapic_revisions_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_services_v2.ts create mode 100644 owl-bot-staging/v2/tsconfig.json create mode 100644 owl-bot-staging/v2/webpack.config.js diff --git a/owl-bot-staging/v2/.eslintignore b/owl-bot-staging/v2/.eslintignore new file mode 100644 index 0000000..cfc348e --- /dev/null +++ b/owl-bot-staging/v2/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v2/.eslintrc.json b/owl-bot-staging/v2/.eslintrc.json new file mode 100644 index 0000000..7821534 --- /dev/null +++ b/owl-bot-staging/v2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v2/.gitignore b/owl-bot-staging/v2/.gitignore new file mode 100644 index 0000000..5d32b23 --- /dev/null +++ b/owl-bot-staging/v2/.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/v2/.jsdoc.js b/owl-bot-staging/v2/.jsdoc.js new file mode 100644 index 0000000..94fed36 --- /dev/null +++ b/owl-bot-staging/v2/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/run', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v2/.mocharc.js b/owl-bot-staging/v2/.mocharc.js new file mode 100644 index 0000000..481c522 --- /dev/null +++ b/owl-bot-staging/v2/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v2/.prettierrc.js b/owl-bot-staging/v2/.prettierrc.js new file mode 100644 index 0000000..494e147 --- /dev/null +++ b/owl-bot-staging/v2/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v2/README.md b/owl-bot-staging/v2/README.md new file mode 100644 index 0000000..bc79325 --- /dev/null +++ b/owl-bot-staging/v2/README.md @@ -0,0 +1 @@ +Run: Nodejs Client diff --git a/owl-bot-staging/v2/linkinator.config.json b/owl-bot-staging/v2/linkinator.config.json new file mode 100644 index 0000000..befd23c --- /dev/null +++ b/owl-bot-staging/v2/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/v2/package.json b/owl-bot-staging/v2/package.json new file mode 100644 index 0000000..c6ef74d --- /dev/null +++ b/owl-bot-staging/v2/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/run", + "version": "0.1.0", + "description": "Run client for Node.js", + "repository": "googleapis/nodejs-run", + "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 run", + "run", + "revisions", + "services" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.0" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto new file mode 100644 index 0000000..3e98749 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto @@ -0,0 +1,199 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "ConditionProto"; +option java_package = "com.google.cloud.run.v2"; + +// Defines a status condition for a resource. +message Condition { + // Represents the possible Condition states. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // Transient state: Reconciliation has not started yet. + CONDITION_PENDING = 1; + + // Transient state: reconciliation is still in progress. + CONDITION_RECONCILING = 2; + + // Terminal state: Reconciliation did not succeed. + CONDITION_FAILED = 3; + + // Terminal state: Reconciliation completed successfully. + CONDITION_SUCCEEDED = 4; + } + + // Represents the severity of the condition failures. + enum Severity { + // Unspecified severity + SEVERITY_UNSPECIFIED = 0; + + // Error severity. + ERROR = 1; + + // Warning severity. + WARNING = 2; + + // Info severity. + INFO = 3; + } + + // Reasons common to all types of conditions. + enum CommonReason { + // Default value. + COMMON_REASON_UNDEFINED = 0; + + // Reason unknown. Further details will be in message. + UNKNOWN = 1; + + // Revision creation process failed. + REVISION_FAILED = 3; + + // Timed out waiting for completion. + PROGRESS_DEADLINE_EXCEEDED = 4; + + // The container image path is incorrect. + CONTAINER_MISSING = 6; + + // Insufficient permissions on the container image. + CONTAINER_PERMISSION_DENIED = 7; + + // Container image is not authorized by policy. + CONTAINER_IMAGE_UNAUTHORIZED = 8; + + // Container image policy authorization check failed. + CONTAINER_IMAGE_AUTHORIZATION_CHECK_FAILED = 9; + + // Insufficient permissions on encryption key. + ENCRYPTION_KEY_PERMISSION_DENIED = 10; + + // Permission check on encryption key failed. + ENCRYPTION_KEY_CHECK_FAILED = 11; + + // At least one Access check on secrets failed. + SECRETS_ACCESS_CHECK_FAILED = 12; + + // Waiting for operation to complete. + WAITING_FOR_OPERATION = 13; + + // System will retry immediately. + IMMEDIATE_RETRY = 14; + + // System will retry later; current attempt failed. + POSTPONED_RETRY = 15; + + // An internal error occurred. Further information may be in the message. + INTERNAL = 16; + } + + // Reasons specific to Revision resource. + enum RevisionReason { + // Default value. + REVISION_REASON_UNDEFINED = 0; + + // Revision in Pending state. + PENDING = 1; + + // Revision is in Reserve state. + RESERVE = 2; + + // Revision is Retired. + RETIRED = 3; + + // Revision is being retired. + RETIRING = 4; + + // Revision is being recreated. + RECREATING = 5; + + // There was a health check error. + HEALTH_CHECK_CONTAINER_ERROR = 6; + + // Health check failed due to user error from customized path of the + // container. System will retry. + CUSTOMIZED_PATH_RESPONSE_PENDING = 7; + + // A revision with min_instance_count > 0 was created and is reserved, but + // it was not configured to serve traffic, so it's not live. This can also + // happen momentarily during traffic migration. + MIN_INSTANCES_NOT_PROVISIONED = 8; + + // The maximum allowed number of active revisions has been reached. + ACTIVE_REVISION_LIMIT_REACHED = 9; + + // There was no deployment defined. + // This value is no longer used, but Services created in older versions of + // the API might contain this value. + NO_DEPLOYMENT = 10; + + // A revision's container has no port specified since the revision is of a + // manually scaled service with 0 instance count + HEALTH_CHECK_SKIPPED = 11; + } + + // Reasons specific to Execution resource. + enum ExecutionReason { + // Default value. + EXECUTION_REASON_UNDEFINED = 0; + + // Internal system error getting execution status. System will retry. + JOB_STATUS_SERVICE_POLLING_ERROR = 1; + + // A task reached its retry limit and the last attempt failed due to the + // user container exiting with a non-zero exit code. + NON_ZERO_EXIT_CODE = 2; + } + + // type is used to communicate the status of the reconciliation process. + // See also: + // https://github.com/knative/serving/blob/main/docs/spec/errors.md#error-conditions-and-reporting + // Types common to all resources include: + // * "Ready": True when the Resource is ready. + string type = 1; + + // State of the condition. + State state = 2; + + // Human readable message indicating details about the current status. + string message = 3; + + // Last time the condition transitioned from one status to another. + google.protobuf.Timestamp last_transition_time = 4; + + // How to interpret failures of this condition, one of Error, Warning, Info + Severity severity = 5; + + // The reason for this condition. Depending on the condition type, + // it will populate one of these fields. + // Successful conditions may not have a reason. + oneof reasons { + // A common (service-level) reason for this condition. + CommonReason reason = 6; + + // A reason for the revision condition. + RevisionReason revision_reason = 9; + + // A reason for the execution condition. + ExecutionReason execution_reason = 11; + } +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto new file mode 100644 index 0000000..328c816 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto @@ -0,0 +1,274 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "K8sMinProto"; +option java_package = "com.google.cloud.run.v2"; +option (google.api.resource_definition) = { + type: "cloudkms.googleapis.com/CryptoKey" + pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}" +}; +option (google.api.resource_definition) = { + type: "secretmanager.googleapis.com/Secret" + pattern: "projects/{project}/secrets/{secret}" +}; +option (google.api.resource_definition) = { + type: "secretmanager.googleapis.com/SecretVersion" + pattern: "projects/{project}/secrets/{secret}/versions/{version}" +}; +option (google.api.resource_definition) = { + type: "vpcaccess.googleapis.com/Connector" + pattern: "projects/{project}/locations/{location}/connectors/{connector}" +}; + +// A single application container. +// This specifies both the container to run, the command to run in the container +// and the arguments to supply to it. +// Note that additional arguments may be supplied by the system to the container +// at runtime. +message Container { + // Name of the container specified as a DNS_LABEL. + string name = 1; + + // Required. URL of the Container image in Google Container Registry or Google Artifact + // Registry. More info: https://kubernetes.io/docs/concepts/containers/images + string image = 2 [(google.api.field_behavior) = REQUIRED]; + + // Entrypoint array. Not executed within a shell. + // The docker image's ENTRYPOINT is used if this is not provided. + // Variable references $(VAR_NAME) are expanded using the container's + // environment. If a variable cannot be resolved, the reference in the input + // string will be unchanged. The $(VAR_NAME) syntax can be escaped with a + // double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, + // regardless of whether the variable exists or not. + // More info: + // https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + repeated string command = 3; + + // Arguments to the entrypoint. + // The docker image's CMD is used if this is not provided. + // Variable references $(VAR_NAME) are expanded using the container's + // environment. If a variable cannot be resolved, the reference in the input + // string will be unchanged. The $(VAR_NAME) syntax can be escaped with a + // double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, + // regardless of whether the variable exists or not. + // More info: + // https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + repeated string args = 4; + + // List of environment variables to set in the container. + repeated EnvVar env = 5; + + // Compute Resource requirements by this container. + // More info: + // https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources + ResourceRequirements resources = 6; + + // List of ports to expose from the container. Only a single port can be + // specified. The specified ports must be listening on all interfaces + // (0.0.0.0) within the container to be accessible. + // + // If omitted, a port number will be chosen and passed to the container + // through the PORT environment variable for the container to listen on. + repeated ContainerPort ports = 7; + + // Volume to mount into the container's filesystem. + repeated VolumeMount volume_mounts = 8; +} + +// ResourceRequirements describes the compute resource requirements. +message ResourceRequirements { + // Only memory and CPU are supported. Note: The only + // supported values for CPU are '1', '2', and '4'. Setting 4 CPU requires at + // least 2Gi of memory. + // The values of the map is string form of the 'quantity' k8s type: + // https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go + map limits = 1; + + // Determines whether CPU should be throttled or not outside of requests. + bool cpu_idle = 2; +} + +// EnvVar represents an environment variable present in a Container. +message EnvVar { + // Required. Name of the environment variable. Must be a C_IDENTIFIER, and mnay not + // exceed 32768 characters. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + oneof values { + // Variable references $(VAR_NAME) are expanded + // using the previous defined environment variables in the container and + // any route environment variables. If a variable cannot be resolved, + // the reference in the input string will be unchanged. The $(VAR_NAME) + // syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped + // references will never be expanded, regardless of whether the variable + // exists or not. + // Defaults to "", and the maximum length is 32768 bytes. + string value = 2; + + // Source for the environment variable's value. + EnvVarSource value_source = 3; + } +} + +// EnvVarSource represents a source for the value of an EnvVar. +message EnvVarSource { + // Selects a secret and a specific version from Cloud Secret Manager. + SecretKeySelector secret_key_ref = 1; +} + +// SecretEnvVarSource represents a source for the value of an EnvVar. +message SecretKeySelector { + // Required. The name of the secret in Cloud Secret Manager. + // Format: {secret_name} if the secret is in the same project. + // projects/{project}/secrets/{secret_name} if the secret is + // in a different project. + string secret = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "secretmanager.googleapis.com/Secret" + } + ]; + + // The Cloud Secret Manager secret version. + // Can be 'latest' for the latest value or an integer for a specific version. + string version = 2 [(google.api.resource_reference) = { + type: "secretmanager.googleapis.com/SecretVersion" + }]; +} + +// ContainerPort represents a network port in a single container. +message ContainerPort { + // If specified, used to specify which protocol to use. + // Allowed values are "http1" and "h2c". + string name = 1; + + // Port number the container listens on. + // This must be a valid TCP port number, 0 < container_port < 65536. + int32 container_port = 3; +} + +// VolumeMount describes a mounting of a Volume within a container. +message VolumeMount { + // Required. This must match the Name of a Volume. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Path within the container at which the volume should be mounted. Must + // not contain ':'. For Cloud SQL volumes, it can be left empty, or must + // otherwise be `/cloudsql`. All instances defined in the Volume will be + // available as `/cloudsql/[instance]`. For more information on Cloud SQL + // volumes, visit https://cloud.google.com/sql/docs/mysql/connect-run + string mount_path = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Volume represents a named volume in a container. +message Volume { + // Required. Volume's name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + oneof volume_type { + // Secret represents a secret that should populate this volume. + // More info: https://kubernetes.io/docs/concepts/storage/volumes#secret + SecretVolumeSource secret = 2; + + // For Cloud SQL volumes, contains the specific instances that should be + // mounted. Visit https://cloud.google.com/sql/docs/mysql/connect-run for + // more information on how to connect Cloud SQL and Cloud Run. + CloudSqlInstance cloud_sql_instance = 3; + } +} + +// The secret's value will be presented as the content of a file whose +// name is defined in the item path. If no items are defined, the name of +// the file is the secret. +message SecretVolumeSource { + // Required. The name of the secret in Cloud Secret Manager. + // Format: {secret} if the secret is in the same project. + // projects/{project}/secrets/{secret} if the secret is + // in a different project. + string secret = 1 [(google.api.field_behavior) = REQUIRED]; + + // If unspecified, the volume will expose a file whose name is the + // secret, relative to VolumeMount.mount_path. + // If specified, the key will be used as the version to fetch from Cloud + // Secret Manager and the path will be the name of the file exposed in the + // volume. When items are defined, they must specify a path and a version. + repeated VersionToPath items = 2; + + // Integer representation of mode bits to use on created files by default. + // Must be a value between 0000 and 0777 (octal), defaulting to 0644. + // Directories within the path are not affected by this setting. + // + // Notes + // + // * Internally, a umask of 0222 will be applied to any non-zero value. + // * This is an integer representation of the mode bits. So, the octal + // integer value should look exactly as the chmod numeric notation with a + // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or + // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or + // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 + // (base-10). + // * This might be in conflict with other options that affect the + // file mode, like fsGroup, and the result can be other mode bits set. + // + // This might be in conflict with other options that affect the + // file mode, like fsGroup, and as a result, other mode bits could be set. + int32 default_mode = 3; +} + +// VersionToPath maps a specific version of a secret to a relative file to mount +// to, relative to VolumeMount's mount_path. +message VersionToPath { + // Required. The relative path of the secret in the container. + string path = 1 [(google.api.field_behavior) = REQUIRED]; + + // The Cloud Secret Manager secret version. + // Can be 'latest' for the latest value or an integer for a specific version. + string version = 2; + + // Integer octal mode bits to use on this file, must be a value between + // 01 and 0777 (octal). If 0 or not set, the Volume's default mode will be + // used. + // + // Notes + // + // * Internally, a umask of 0222 will be applied to any non-zero value. + // * This is an integer representation of the mode bits. So, the octal + // integer value should look exactly as the chmod numeric notation with a + // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or + // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or + // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 + // (base-10). + // * This might be in conflict with other options that affect the + // file mode, like fsGroup, and the result can be other mode bits set. + int32 mode = 3; +} + +// Represents a specific Cloud SQL instance. +message CloudSqlInstance { + // The Cloud SQL instance connection names, as can be found in + // https://console.cloud.google.com/sql/instances. Visit + // https://cloud.google.com/sql/docs/mysql/connect-run for more information on + // how to connect Cloud SQL and Cloud Run. Format: + // {project}:{location}:{instance} + repeated string instances = 1; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto new file mode 100644 index 0000000..0cb674e --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto @@ -0,0 +1,278 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/api/routing.proto"; +import "google/cloud/run/v2/condition.proto"; +import "google/cloud/run/v2/k8s.min.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "RevisionProto"; +option java_package = "com.google.cloud.run.v2"; + +// Cloud Run Revision Control Plane API. +service Revisions { + option (google.api.default_host) = "run.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Gets information about a Revision. + rpc GetRevision(GetRevisionRequest) returns (Revision) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + } + + // List Revisions from a given Service, or from a given location. + rpc ListRevisions(ListRevisionsRequest) returns (ListRevisionsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/services/*}/revisions" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Delete a Revision. + rpc DeleteRevision(DeleteRevisionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Revision" + metadata_type: "Revision" + }; + } +} + +// Request message for obtaining a Revision by its full name. +message GetRevisionRequest { + // Required. The full name of the Revision. + // Format: + // projects/{project}/locations/{location}/services/{service}/revisions/{revision} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + } + ]; +} + +// Request message for retrieving a list of Revisions. +message ListRevisionsRequest { + // Required. The Service from which the Revisions should be listed. + // To list all Revisions across Services, use "-" instead of Service name. + // Format: + // projects/{project}/locations/{location}/services/{service} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Revision" + } + ]; + + // Maximum number of revisions to return in this call. + int32 page_size = 2; + + // A page token received from a previous call to ListRevisions. + // All other parameters must match. + string page_token = 3; + + // If true, returns deleted (but unexpired) resources along with active ones. + bool show_deleted = 4; +} + +// Response message containing a list of Revisions. +message ListRevisionsResponse { + // The resulting list of Revisions. + repeated Revision revisions = 1; + + // A token indicating there are more items than page_size. Use it in the next + // ListRevisions request to continue. + string next_page_token = 2; +} + +// Request message for deleting a retired Revision. +// Revision lifecycle is usually managed by making changes to the parent +// Service. Only retired revisions can be deleted with this API. +message DeleteRevisionRequest { + // Required. The name of the Revision to delete. + // Format: + // projects/{project}/locations/{location}/services/{service}/revisions/{revision} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + } + ]; + + // Indicates that the request should be validated without actually + // deleting any resources. + bool validate_only = 2; + + // A system-generated fingerprint for this version of the + // resource. This may be used to detect modification conflict during updates. + string etag = 3; +} + +// A Revision is an immutable snapshot of code and configuration. A Revision +// references a container image. Revisions are only created by updates to its +// parent Service. +message Revision { + option (google.api.resource) = { + type: "run.googleapis.com/Revision" + pattern: "projects/{project}/locations/{location}/services/{service}/revisions/{revision}" + style: DECLARATIVE_FRIENDLY + }; + + // Output only. The unique name of this Revision. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server assigned unique identifier for the Revision. The value is a UUID4 + // string and guaranteed to remain unchanged until the resource is deleted. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A number that monotonically increases every time the user + // modifies the desired state. + int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // KRM-style labels for the resource. + // User-provided labels are shared with Google's billing system, so they can + // be used to filter, or break down billing charges by team, component, + // environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels + // Cloud Run will populate some labels with 'run.googleapis.com' or + // 'serving.knative.dev' namespaces. Those labels are read-only, and user + // changes will not be preserved. + map labels = 4; + + // KRM-style annotations for the resource. + map annotations = 5; + + // Output only. The creation time. + google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last-modified time. + google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the deletion time. It is only + // populated as a response to a Delete request. + google.protobuf.Timestamp delete_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the time after which it will be + // permamently deleted. It is only populated as a response to a Delete + // request. + google.protobuf.Timestamp expire_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Set the launch stage to a preview stage on write to allow use of preview + // features in that stage. On read, describes whether the resource uses + // preview features. Launch Stages are defined at [Google Cloud Platform + // Launch Stages](https://cloud.google.com/terms/launch-stages). + google.api.LaunchStage launch_stage = 10; + + // Output only. The name of the parent service. + string service = 11 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "run.googleapis.com/Service" + } + ]; + + // Scaling settings for this revision. + RevisionScaling scaling = 12; + + // VPC Access configuration for this Revision. For more information, visit + // https://cloud.google.com/run/docs/configuring/connecting-vpc. + VpcAccess vpc_access = 13; + + // Sets the maximum number of requests that each serving instance can receive. + int32 max_instance_request_concurrency = 34; + + // Max allowed time for an instance to respond to a request. + google.protobuf.Duration timeout = 15; + + // Email address of the IAM service account associated with the revision of + // the service. The service account represents the identity of the running + // revision, and determines what permissions the revision has. + string service_account = 16; + + // Holds the single container that defines the unit of execution for this + // Revision. + repeated Container containers = 17; + + // A list of Volumes to make available to containers. + repeated Volume volumes = 18; + + // The execution environment being used to host this Revision. + ExecutionEnvironment execution_environment = 20; + + // A reference to a customer managed encryption key (CMEK) to use to encrypt + // this container image. For more information, go to + // https://cloud.google.com/run/docs/securing/using-cmek + string encryption_key = 21 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; + + // Output only. Indicates whether the resource's reconciliation is still in progress. + // See comments in `Service.reconciling` for additional information on + // reconciliation process in Cloud Run. + bool reconciling = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Condition of this Revision, containing its readiness status, and + // detailed error information in case it did not reach a serving state. + repeated Condition conditions = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The generation of this Revision currently serving traffic. See comments in + // `reconciling` for additional information on reconciliation process in Cloud + // Run. + int64 observed_generation = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Google Console URI to obtain logs for the Revision. + string log_uri = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto new file mode 100644 index 0000000..f20fb5e --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/resource.proto"; +import "google/cloud/run/v2/k8s.min.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "RevisionTemplateProto"; +option java_package = "com.google.cloud.run.v2"; + +// RevisionTemplate describes the data a revision should have when created from +// a template. +message RevisionTemplate { + // The unique name for the revision. If this field is omitted, it will be + // automatically generated based on the Service name. + string revision = 1 [(google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + }]; + + // KRM-style labels for the resource. + map labels = 2; + + // KRM-style annotations for the resource. + map annotations = 3; + + // Scaling settings for this Revision. + RevisionScaling scaling = 4; + + // VPC Access configuration to use for this Revision. For more information, + // visit https://cloud.google.com/run/docs/configuring/connecting-vpc. + VpcAccess vpc_access = 6; + + // Max allowed time for an instance to respond to a request. + google.protobuf.Duration timeout = 8; + + // Email address of the IAM service account associated with the revision of + // the service. The service account represents the identity of the running + // revision, and determines what permissions the revision has. If not + // provided, the revision will use the project's default service account. + string service_account = 9; + + // Holds the single container that defines the unit of execution for this + // Revision. + repeated Container containers = 10; + + // A list of Volumes to make available to containers. + repeated Volume volumes = 11; + + // The sandbox environment to host this Revision. + ExecutionEnvironment execution_environment = 13; + + // A reference to a customer managed encryption key (CMEK) to use to encrypt + // this container image. For more information, go to + // https://cloud.google.com/run/docs/securing/using-cmek + string encryption_key = 14 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; + + // Sets the maximum number of requests that each serving instance can receive. + int32 max_instance_request_concurrency = 15; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto new file mode 100644 index 0000000..51a29ed --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto @@ -0,0 +1,435 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/api/routing.proto"; +import "google/cloud/run/v2/condition.proto"; +import "google/cloud/run/v2/revision_template.proto"; +import "google/cloud/run/v2/traffic_target.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "ServiceProto"; +option java_package = "com.google.cloud.run.v2"; + +// Cloud Run Service Control Plane API +service Services { + option (google.api.default_host) = "run.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new Service in a given project and location. + rpc CreateService(CreateServiceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*}/services" + body: "service" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}" + } + }; + option (google.api.method_signature) = "parent,service,service_id"; + option (google.longrunning.operation_info) = { + response_type: "Service" + metadata_type: "Service" + }; + } + + // Gets information about a Service. + rpc GetService(GetServiceRequest) returns (Service) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/services/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + } + + // List Services. + rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/services" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a Service. + rpc UpdateService(UpdateServiceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v2/{service.name=projects/*/locations/*/services/*}" + body: "service" + }; + option (google.api.routing) = { + routing_parameters { + field: "service.name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "service"; + option (google.longrunning.operation_info) = { + response_type: "Service" + metadata_type: "Service" + }; + } + + // Deletes a Service. + // This will cause the Service to stop serving traffic and will delete all + // revisions. + rpc DeleteService(DeleteServiceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/services/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Service" + metadata_type: "Service" + }; + } + + // Get the IAM Access Control policy currently in effect for the given + // Cloud Run Service. This result does not include any inherited policies. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + get: "/v2/{resource=projects/*/locations/*/services/*}:getIamPolicy" + }; + } + + // Sets the IAM Access control policy for the specified Service. Overwrites + // any existing policy. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/services/*}:setIamPolicy" + body: "*" + }; + } + + // Returns permissions that a caller has on the specified Project. + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/services/*}:testIamPermissions" + body: "*" + }; + } +} + +// Request message for creating a Service. +message CreateServiceRequest { + // Required. The location and project in which this service should be created. + // Format: projects/{projectnumber}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Service" + } + ]; + + // Required. The Service instance to create. + Service service = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The unique identifier for the Service. The name of the service becomes + // {parent}/services/{service_id}. + string service_id = 3 [(google.api.field_behavior) = REQUIRED]; + + // Indicates that the request should be validated and default values + // populated, without persisting the request or creating any resources. + bool validate_only = 4; +} + +// Request message for updating a service. +message UpdateServiceRequest { + // Required. The Service to be updated. + Service service = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates that the request should be validated and default values + // populated, without persisting the request or updating any resources. + bool validate_only = 3; + + // If set to true, and if the Service does not exist, it will create a new + // one. Caller must have both create and update permissions for this call if + // this is set to true. + bool allow_missing = 4; +} + +// Request message for retrieving a list of Services. +message ListServicesRequest { + // Required. The location and project to list resources on. + // Location must be a valid GCP region, and may not be the "-" wildcard. + // Format: projects/{projectnumber}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Service" + } + ]; + + // Maximum number of Services to return in this call. + int32 page_size = 2; + + // A page token received from a previous call to ListServices. + // All other parameters must match. + string page_token = 3; + + // If true, returns deleted (but unexpired) resources along with active ones. + bool show_deleted = 4; +} + +// Response message containing a list of Services. +message ListServicesResponse { + // The resulting list of Services. + repeated Service services = 1; + + // A token indicating there are more items than page_size. Use it in the next + // ListServices request to continue. + string next_page_token = 2; +} + +// Request message for obtaining a Service by its full name. +message GetServiceRequest { + // Required. The full name of the Service. + // Format: projects/{projectnumber}/locations/{location}/services/{service} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "run.googleapis.com/Service" + } + ]; +} + +// Request message to delete a Service by its full name. +message DeleteServiceRequest { + // Required. The full name of the Service. + // Format: projects/{projectnumber}/locations/{location}/services/{service} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "run.googleapis.com/Service" + } + ]; + + // Indicates that the request should be validated without actually + // deleting any resources. + bool validate_only = 2; + + // A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 3; +} + +// Service acts as a top-level container that manages a set of +// configurations and revision templates which implement a network service. +// Service exists to provide a singular abstraction which can be access +// controlled, reasoned about, and which encapsulates software lifecycle +// decisions such as rollout policy and team resource ownership. +message Service { + option (google.api.resource) = { + type: "run.googleapis.com/Service" + pattern: "projects/{project}/locations/{location}/services/{service}" + style: DECLARATIVE_FRIENDLY + }; + + // The fully qualified name of this Service. In CreateServiceRequest, this + // field is ignored, and instead composed from CreateServiceRequest.parent and + // CreateServiceRequest.service_id. + // + // Format: + // projects/{project}/locations/{location}/services/{service_id} + string name = 1; + + // User-provided description of the Service. This field currently has a + // 512-character limit. + string description = 2; + + // Output only. Server assigned unique identifier for the trigger. The value is a UUID4 + // string and guaranteed to remain unchanged until the resource is deleted. + string uid = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A number that monotonically increases every time the user + // modifies the desired state. + // Please note that unlike v1, this is an int64 value. As with most Google + // APIs, its JSON representation will be a `string` instead of an `integer`. + int64 generation = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Map of string keys and values that can be used to organize and categorize + // objects. + // User-provided labels are shared with Google's billing system, so they can + // be used to filter, or break down billing charges by team, component, + // environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels + // Cloud Run will populate some labels with 'run.googleapis.com' or + // 'serving.knative.dev' namespaces. Those labels are read-only, and user + // changes will not be preserved. + map labels = 5; + + // Unstructured key value map that may be set by external tools to store and + // arbitrary metadata. They are not queryable and should be preserved + // when modifying objects. Cloud Run will populate some annotations using + // 'run.googleapis.com' or 'serving.knative.dev' namespaces. This field + // follows Kubernetes annotations' namespacing, limits, and rules. More info: + // https://kubernetes.io/docs/user-guide/annotations + map annotations = 6; + + // Output only. The creation time. + google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last-modified time. + google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The deletion time. + google.protobuf.Timestamp delete_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the time after which it will be + // permamently deleted. + google.protobuf.Timestamp expire_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Email address of the authenticated creator. + string creator = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Email address of the last authenticated modifier. + string last_modifier = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Arbitrary identifier for the API client. + string client = 13; + + // Arbitrary version identifier for the API client. + string client_version = 14; + + // Provides the ingress settings for this Service. On output, returns the + // currently observed ingress settings, or INGRESS_TRAFFIC_UNSPECIFIED if no + // revision is active. + IngressTraffic ingress = 15; + + // The launch stage as defined by [Google Cloud Platform + // Launch Stages](https://cloud.google.com/terms/launch-stages). + // Cloud Run supports `ALPHA`, `BETA`, and `GA`. If no value is specified, GA + // is assumed. + google.api.LaunchStage launch_stage = 16; + + // Settings for the Binary Authorization feature. + BinaryAuthorization binary_authorization = 17; + + // Required. The template used to create revisions for this Service. + RevisionTemplate template = 18 [(google.api.field_behavior) = REQUIRED]; + + // Specifies how to distribute traffic over a collection of Revisions + // belonging to the Service. If traffic is empty or not provided, defaults to + // 100% traffic to the latest `Ready` Revision. + repeated TrafficTarget traffic = 19; + + // Output only. The generation of this Service currently serving traffic. See comments in + // `reconciling` for additional information on reconciliation process in Cloud + // Run. + // Please note that unlike v1, this is an int64 value. As with most Google + // APIs, its JSON representation will be a `string` instead of an `integer`. + int64 observed_generation = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Condition of this Service, containing its readiness status, and + // detailed error information in case it did not reach a serving state. See + // comments in `reconciling` for additional information on reconciliation + // process in Cloud Run. + Condition terminal_condition = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Conditions of all other associated sub-resources. They contain + // additional diagnostics information in case the Service does not reach its + // Serving state. See comments in `reconciling` for additional information on + // reconciliation process in Cloud Run. + repeated Condition conditions = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the latest revision that is serving traffic. See comments in + // `reconciling` for additional information on reconciliation process in Cloud + // Run. + string latest_ready_revision = 33 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + } + ]; + + // Output only. Name of the last created revision. See comments in `reconciling` for + // additional information on reconciliation process in Cloud Run. + string latest_created_revision = 34 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + } + ]; + + // Output only. Detailed status information for corresponding traffic targets. See comments + // in `reconciling` for additional information on reconciliation process in + // Cloud Run. + repeated TrafficTargetStatus traffic_statuses = 35 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The main URI in which this Service is serving traffic. + string uri = 36 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Returns true if the Service is currently being acted upon by the system to + // bring it into the desired state. + // + // When a new Service is created, or an existing one is updated, Cloud Run + // will asynchronously perform all necessary steps to bring the Service to the + // desired serving state. This process is called reconciliation. + // While reconciliation is in process, `observed_generation`, + // `latest_ready_revison`, `traffic_statuses`, and `uri` will have transient + // values that might mismatch the intended state: Once reconciliation is over + // (and this field is false), there are two possible outcomes: reconciliation + // succeeded and the serving state matches the Service, or there was an error, + // and reconciliation failed. This state can be found in + // `terminal_condition.state`. + // + // If reconciliation succeeded, the following fields will match: `traffic` and + // `traffic_statuses`, `observed_generation` and `generation`, + // `latest_ready_revision` and `latest_created_revision`. + // + // If reconciliation failed, `traffic_statuses`, `observed_generation`, and + // `latest_ready_revision` will have the state of the last serving revision, + // or empty for newly created Services. Additional information on the failure + // can be found in `terminal_condition` and `conditions`. + bool reconciling = 98 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto new file mode 100644 index 0000000..18a8c7d --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "TrafficTargetProto"; +option java_package = "com.google.cloud.run.v2"; + +// Holds a single traffic routing entry for the Service. Allocations can be done +// to a specific Revision name, or pointing to the latest Ready Revision. +message TrafficTarget { + // The allocation type for this traffic target. + TrafficTargetAllocationType type = 1; + + // Revision to which to send this portion of traffic, if traffic allocation is + // by revision. + string revision = 2 [(google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + }]; + + // Specifies percent of the traffic to this Revision. + // This defaults to zero if unspecified. + int32 percent = 3; + + // Indicates a string to be part of the URI to exclusively reference this + // target. + string tag = 4; +} + +// Represents the observed state of a single `TrafficTarget` entry. +message TrafficTargetStatus { + // The allocation type for this traffic target. + TrafficTargetAllocationType type = 1; + + // Revision to which this traffic is sent. + string revision = 2 [(google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + }]; + + // Specifies percent of the traffic to this Revision. + int32 percent = 3; + + // Indicates the string used in the URI to exclusively reference this target. + string tag = 4; + + // Displays the target URI. + string uri = 5; +} + +// The type of instance allocation. +enum TrafficTargetAllocationType { + // Unspecified instance allocation type. + TRAFFIC_TARGET_ALLOCATION_TYPE_UNSPECIFIED = 0; + + // Allocates instances to the Service's latest ready Revision. + TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST = 1; + + // Allocates instances to a Revision by name. + TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION = 2; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto new file mode 100644 index 0000000..89748d5 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto @@ -0,0 +1,102 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "VendorSettingsProto"; +option java_package = "com.google.cloud.run.v2"; + +// VPC Access settings. For more information on creating a VPC Connector, visit +// https://cloud.google.com/vpc/docs/configure-serverless-vpc-access For +// information on how to configure Cloud Run with an existing VPC Connector, +// visit https://cloud.google.com/run/docs/configuring/connecting-vpc +message VpcAccess { + // Egress options for VPC access. + enum VpcEgress { + // Unspecified + VPC_EGRESS_UNSPECIFIED = 0; + + // All outbound traffic is routed through the VPC connector. + ALL_TRAFFIC = 1; + + // Only private IP ranges are routed through the VPC connector. + PRIVATE_RANGES_ONLY = 2; + } + + // VPC Access connector name. + // Format: projects/{project}/locations/{location}/connectors/{connector} + string connector = 1 [(google.api.resource_reference) = { + type: "vpcaccess.googleapis.com/Connector" + }]; + + // Traffic VPC egress settings. + VpcEgress egress = 2; +} + +// Settings for Binary Authorization feature. +message BinaryAuthorization { + oneof binauthz_method { + // If True, indicates to use the default project's binary authorization + // policy. If False, binary authorization will be disabled. + bool use_default = 1; + } + + // If present, indicates to use Breakglass using this justification. + // If use_default is False, then it must be empty. + // For more information on breakglass, see + // https://cloud.google.com/binary-authorization/docs/using-breakglass + string breakglass_justification = 2; +} + +// Settings for revision-level scaling settings. +message RevisionScaling { + // Minimum number of serving instances that this resource should have. + int32 min_instance_count = 1; + + // Maximum number of serving instances that this resource should have. + int32 max_instance_count = 2; +} + +// Allowed ingress traffic for the Container. +enum IngressTraffic { + // Unspecified + INGRESS_TRAFFIC_UNSPECIFIED = 0; + + // All inbound traffic is allowed. + INGRESS_TRAFFIC_ALL = 1; + + // Only internal traffic is allowed. + INGRESS_TRAFFIC_INTERNAL_ONLY = 2; + + // Both internal and Google Cloud Load Balancer traffic is allowed. + INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER = 3; +} + +// Alternatives for execution environments. +enum ExecutionEnvironment { + // Unspecified + EXECUTION_ENVIRONMENT_UNSPECIFIED = 0; + + // Uses the First Generation environment. + EXECUTION_ENVIRONMENT_GEN1 = 1; + + // Uses Second Generation environment. + EXECUTION_ENVIRONMENT_GEN2 = 2; +} diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js b/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js new file mode 100644 index 0000000..ab6b399 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Revisions_DeleteRevision_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Revision to delete. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + */ + // const name = 'abc123' + /** + * Indicates that the request should be validated without actually + * deleting any resources. + */ + // const validateOnly = true + /** + * A system-generated fingerprint for this version of the + * resource. This may be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {RevisionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new RevisionsClient(); + + async function callDeleteRevision() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.deleteRevision(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteRevision(); + // [END run_v2_generated_Revisions_DeleteRevision_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js b/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js new file mode 100644 index 0000000..0c67144 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Revisions_GetRevision_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Revision. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + */ + // const name = 'abc123' + + // Imports the Run library + const {RevisionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new RevisionsClient(); + + async function callGetRevision() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await runClient.getRevision(request); + console.log(response); + } + + callGetRevision(); + // [END run_v2_generated_Revisions_GetRevision_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js b/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js new file mode 100644 index 0000000..2263cee --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START run_v2_generated_Revisions_ListRevisions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + */ + // const parent = 'abc123' + /** + * Maximum number of revisions to return in this call. + */ + // const pageSize = 1234 + /** + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + */ + // const pageToken = 'abc123' + /** + * If true, returns deleted (but unexpired) resources along with active ones. + */ + // const showDeleted = true + + // Imports the Run library + const {RevisionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new RevisionsClient(); + + async function callListRevisions() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await runClient.listRevisionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRevisions(); + // [END run_v2_generated_Revisions_ListRevisions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.create_service.js b/owl-bot-staging/v2/samples/generated/v2/services.create_service.js new file mode 100644 index 0000000..7524ecb --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.create_service.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, service, serviceId) { + // [START run_v2_generated_Services_CreateService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location and project in which this service should be created. + * Format: projects/{projectnumber}/locations/{location} + */ + // const parent = 'abc123' + /** + * Required. The Service instance to create. + */ + // const service = {} + /** + * Required. The unique identifier for the Service. The name of the service becomes + * {parent}/services/{service_id}. + */ + // const serviceId = 'abc123' + /** + * Indicates that the request should be validated and default values + * populated, without persisting the request or creating any resources. + */ + // const validateOnly = true + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callCreateService() { + // Construct request + const request = { + parent, + service, + serviceId, + }; + + // Run request + const [operation] = await runClient.createService(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateService(); + // [END run_v2_generated_Services_CreateService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js b/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js new file mode 100644 index 0000000..bcf7ec4 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Services_DeleteService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Service. + * Format: projects/{projectnumber}/locations/{location}/services/{service} + */ + // const name = 'abc123' + /** + * Indicates that the request should be validated without actually + * deleting any resources. + */ + // const validateOnly = true + /** + * A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callDeleteService() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.deleteService(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteService(); + // [END run_v2_generated_Services_DeleteService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js b/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js new file mode 100644 index 0000000..52329ca --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource) { + // [START run_v2_generated_Services_GetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await runClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END run_v2_generated_Services_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.get_service.js b/owl-bot-staging/v2/samples/generated/v2/services.get_service.js new file mode 100644 index 0000000..ffd939c --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.get_service.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Services_GetService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Service. + * Format: projects/{projectnumber}/locations/{location}/services/{service} + */ + // const name = 'abc123' + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callGetService() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await runClient.getService(request); + console.log(response); + } + + callGetService(); + // [END run_v2_generated_Services_GetService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.list_services.js b/owl-bot-staging/v2/samples/generated/v2/services.list_services.js new file mode 100644 index 0000000..3daad03 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.list_services.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START run_v2_generated_Services_ListServices_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location and project to list resources on. + * Location must be a valid GCP region, and may not be the "-" wildcard. + * Format: projects/{projectnumber}/locations/{location} + */ + // const parent = 'abc123' + /** + * Maximum number of Services to return in this call. + */ + // const pageSize = 1234 + /** + * A page token received from a previous call to ListServices. + * All other parameters must match. + */ + // const pageToken = 'abc123' + /** + * If true, returns deleted (but unexpired) resources along with active ones. + */ + // const showDeleted = true + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callListServices() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await runClient.listServicesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServices(); + // [END run_v2_generated_Services_ListServices_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js b/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js new file mode 100644 index 0000000..f56b2bd --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource, policy) { + // [START run_v2_generated_Services_SetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await runClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END run_v2_generated_Services_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js b/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js new file mode 100644 index 0000000..f7fbd42 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource, permissions) { + // [START run_v2_generated_Services_TestIamPermissions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await runClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END run_v2_generated_Services_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.update_service.js b/owl-bot-staging/v2/samples/generated/v2/services.update_service.js new file mode 100644 index 0000000..a280ace --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.update_service.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(service) { + // [START run_v2_generated_Services_UpdateService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Service to be updated. + */ + // const service = {} + /** + * Indicates that the request should be validated and default values + * populated, without persisting the request or updating any resources. + */ + // const validateOnly = true + /** + * If set to true, and if the Service does not exist, it will create a new + * one. Caller must have both create and update permissions for this call if + * this is set to true. + */ + // const allowMissing = true + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callUpdateService() { + // Construct request + const request = { + service, + }; + + // Run request + const [operation] = await runClient.updateService(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateService(); + // [END run_v2_generated_Services_UpdateService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json new file mode 100644 index 0000000..82e2baf --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json @@ -0,0 +1,531 @@ +{ + "clientLibrary": { + "name": "nodejs-run", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.run.v2", + "version": "v2" + } + ] + }, + "snippets": [ + { + "regionTag": "run_v2_generated_Revisions_GetRevision_async", + "title": "Revisions getRevision Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a Revision.", + "canonical": true, + "file": "revisions.get_revision.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRevision", + "fullName": "google.cloud.run.v2.Revisions.GetRevision", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.run.v2.Revision", + "client": { + "shortName": "RevisionsClient", + "fullName": "google.cloud.run.v2.RevisionsClient" + }, + "method": { + "shortName": "GetRevision", + "fullName": "google.cloud.run.v2.Revisions.GetRevision", + "service": { + "shortName": "Revisions", + "fullName": "google.cloud.run.v2.Revisions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Revisions_ListRevisions_async", + "title": "Revisions listRevisions Sample", + "origin": "API_DEFINITION", + "description": " List Revisions from a given Service, or from a given location.", + "canonical": true, + "file": "revisions.list_revisions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRevisions", + "fullName": "google.cloud.run.v2.Revisions.ListRevisions", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.run.v2.ListRevisionsResponse", + "client": { + "shortName": "RevisionsClient", + "fullName": "google.cloud.run.v2.RevisionsClient" + }, + "method": { + "shortName": "ListRevisions", + "fullName": "google.cloud.run.v2.Revisions.ListRevisions", + "service": { + "shortName": "Revisions", + "fullName": "google.cloud.run.v2.Revisions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Revisions_DeleteRevision_async", + "title": "Revisions deleteRevision Sample", + "origin": "API_DEFINITION", + "description": " Delete a Revision.", + "canonical": true, + "file": "revisions.delete_revision.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteRevision", + "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "RevisionsClient", + "fullName": "google.cloud.run.v2.RevisionsClient" + }, + "method": { + "shortName": "DeleteRevision", + "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", + "service": { + "shortName": "Revisions", + "fullName": "google.cloud.run.v2.Revisions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_CreateService_async", + "title": "Revisions createService Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Service in a given project and location.", + "canonical": true, + "file": "services.create_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateService", + "fullName": "google.cloud.run.v2.Services.CreateService", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "service", + "type": ".google.cloud.run.v2.Service" + }, + { + "name": "service_id", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "CreateService", + "fullName": "google.cloud.run.v2.Services.CreateService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_GetService_async", + "title": "Revisions getService Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a Service.", + "canonical": true, + "file": "services.get_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetService", + "fullName": "google.cloud.run.v2.Services.GetService", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.run.v2.Service", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "GetService", + "fullName": "google.cloud.run.v2.Services.GetService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_ListServices_async", + "title": "Revisions listServices Sample", + "origin": "API_DEFINITION", + "description": " List Services.", + "canonical": true, + "file": "services.list_services.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServices", + "fullName": "google.cloud.run.v2.Services.ListServices", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.run.v2.ListServicesResponse", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "ListServices", + "fullName": "google.cloud.run.v2.Services.ListServices", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_UpdateService_async", + "title": "Revisions updateService Sample", + "origin": "API_DEFINITION", + "description": " Updates a Service.", + "canonical": true, + "file": "services.update_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateService", + "fullName": "google.cloud.run.v2.Services.UpdateService", + "async": true, + "parameters": [ + { + "name": "service", + "type": ".google.cloud.run.v2.Service" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "UpdateService", + "fullName": "google.cloud.run.v2.Services.UpdateService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_DeleteService_async", + "title": "Revisions deleteService Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Service. This will cause the Service to stop serving traffic and will delete all revisions.", + "canonical": true, + "file": "services.delete_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteService", + "fullName": "google.cloud.run.v2.Services.DeleteService", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "DeleteService", + "fullName": "google.cloud.run.v2.Services.DeleteService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_GetIamPolicy_async", + "title": "Revisions getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Get the IAM Access Control policy currently in effect for the given Cloud Run Service. This result does not include any inherited policies.", + "canonical": true, + "file": "services.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.run.v2.Services.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.run.v2.Services.GetIamPolicy", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_SetIamPolicy_async", + "title": "Revisions setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the IAM Access control policy for the specified Service. Overwrites any existing policy.", + "canonical": true, + "file": "services.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.run.v2.Services.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.run.v2.Services.SetIamPolicy", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_TestIamPermissions_async", + "title": "Revisions testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified Project. There are no permissions required for making this API call.", + "canonical": true, + "file": "services.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.run.v2.Services.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.run.v2.Services.TestIamPermissions", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v2/src/index.ts b/owl-bot-staging/v2/src/index.ts new file mode 100644 index 0000000..f7f6340 --- /dev/null +++ b/owl-bot-staging/v2/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v2 from './v2'; +const RevisionsClient = v2.RevisionsClient; +type RevisionsClient = v2.RevisionsClient; +const ServicesClient = v2.ServicesClient; +type ServicesClient = v2.ServicesClient; +export {v2, RevisionsClient, ServicesClient}; +export default {v2, RevisionsClient, ServicesClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v2/src/v2/gapic_metadata.json b/owl-bot-staging/v2/src/v2/gapic_metadata.json new file mode 100644 index 0000000..5990e13 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/gapic_metadata.json @@ -0,0 +1,155 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.run.v2", + "libraryPackage": "@google-cloud/run", + "services": { + "Revisions": { + "clients": { + "grpc": { + "libraryClient": "RevisionsClient", + "rpcs": { + "GetRevision": { + "methods": [ + "getRevision" + ] + }, + "DeleteRevision": { + "methods": [ + "deleteRevision" + ] + }, + "ListRevisions": { + "methods": [ + "listRevisions", + "listRevisionsStream", + "listRevisionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RevisionsClient", + "rpcs": { + "GetRevision": { + "methods": [ + "getRevision" + ] + }, + "DeleteRevision": { + "methods": [ + "deleteRevision" + ] + }, + "ListRevisions": { + "methods": [ + "listRevisions", + "listRevisionsStream", + "listRevisionsAsync" + ] + } + } + } + } + }, + "Services": { + "clients": { + "grpc": { + "libraryClient": "ServicesClient", + "rpcs": { + "GetService": { + "methods": [ + "getService" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateService": { + "methods": [ + "createService" + ] + }, + "UpdateService": { + "methods": [ + "updateService" + ] + }, + "DeleteService": { + "methods": [ + "deleteService" + ] + }, + "ListServices": { + "methods": [ + "listServices", + "listServicesStream", + "listServicesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServicesClient", + "rpcs": { + "GetService": { + "methods": [ + "getService" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateService": { + "methods": [ + "createService" + ] + }, + "UpdateService": { + "methods": [ + "updateService" + ] + }, + "DeleteService": { + "methods": [ + "deleteService" + ] + }, + "ListServices": { + "methods": [ + "listServices", + "listServicesStream", + "listServicesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/index.ts b/owl-bot-staging/v2/src/v2/index.ts new file mode 100644 index 0000000..5ea97dc --- /dev/null +++ b/owl-bot-staging/v2/src/v2/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {RevisionsClient} from './revisions_client'; +export {ServicesClient} from './services_client'; diff --git a/owl-bot-staging/v2/src/v2/revisions_client.ts b/owl-bot-staging/v2/src/v2/revisions_client.ts new file mode 100644 index 0000000..ecc51b3 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/revisions_client.ts @@ -0,0 +1,1016 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/revisions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './revisions_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Run Revision Control Plane API. + * @class + * @memberof v2 + */ +export class RevisionsClient { + 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}; + operationsClient: gax.OperationsClient; + revisionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RevisionsClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RevisionsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RevisionsClient; + 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // 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 = { + cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + revisionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}' + ), + }; + + // 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 = { + listRevisions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'revisions') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const deleteRevisionResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Revision') as gax.protobuf.Type; + const deleteRevisionMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Revision') as gax.protobuf.Type; + + this.descriptors.longrunning = { + deleteRevision: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteRevisionResponse.decode.bind(deleteRevisionResponse), + deleteRevisionMetadata.decode.bind(deleteRevisionMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.run.v2.Revisions', 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 = this._gaxModule.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.revisionsStub) { + return this.revisionsStub; + } + + // Put together the "service stub" for + // google.cloud.run.v2.Revisions. + this.revisionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Revisions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.run.v2.Revisions, + 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 revisionsStubMethods = + ['getRevision', 'listRevisions', 'deleteRevision']; + for (const methodName of revisionsStubMethods) { + const callPromise = this.revisionsStub.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] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.revisionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'run.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 'run.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets information about a Revision. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Revision. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + * @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 [Revision]{@link google.cloud.run.v2.Revision}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/revisions.get_revision.js + * region_tag:run_v2_generated_Revisions_GetRevision_async + */ + getRevision( + request?: protos.google.cloud.run.v2.IGetRevisionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|undefined, {}|undefined + ]>; + getRevision( + request: protos.google.cloud.run.v2.IGetRevisionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>): void; + getRevision( + request: protos.google.cloud.run.v2.IGetRevisionRequest, + callback: Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>): void; + getRevision( + request?: protos.google.cloud.run.v2.IGetRevisionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.getRevision(request, options, callback); + } + +/** + * Delete a Revision. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Revision to delete. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + * @param {boolean} request.validateOnly + * Indicates that the request should be validated without actually + * deleting any resources. + * @param {string} request.etag + * A system-generated fingerprint for this version of the + * resource. This may be used to detect modification conflict during updates. + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/revisions.delete_revision.js + * region_tag:run_v2_generated_Revisions_DeleteRevision_async + */ + deleteRevision( + request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteRevision( + request: protos.google.cloud.run.v2.IDeleteRevisionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteRevision( + request: protos.google.cloud.run.v2.IDeleteRevisionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteRevision( + request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.deleteRevision(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteRevision()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/revisions.delete_revision.js + * region_tag:run_v2_generated_Revisions_DeleteRevision_async + */ + async checkDeleteRevisionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteRevision, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * List Revisions from a given Service, or from a given location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + * @param {number} request.pageSize + * Maximum number of revisions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 [Revision]{@link google.cloud.run.v2.Revision}. + * 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 `listRevisionsAsync()` + * 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. + */ + listRevisions( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IRevision[], + protos.google.cloud.run.v2.IListRevisionsRequest|null, + protos.google.cloud.run.v2.IListRevisionsResponse + ]>; + listRevisions( + request: protos.google.cloud.run.v2.IListRevisionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>): void; + listRevisions( + request: protos.google.cloud.run.v2.IListRevisionsRequest, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>): void; + listRevisions( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>, + callback?: PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>): + Promise<[ + protos.google.cloud.run.v2.IRevision[], + protos.google.cloud.run.v2.IListRevisionsRequest|null, + protos.google.cloud.run.v2.IListRevisionsResponse + ]>|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.listRevisions(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 Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + * @param {number} request.pageSize + * Maximum number of revisions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 [Revision]{@link google.cloud.run.v2.Revision} 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 `listRevisionsAsync()` + * 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. + */ + listRevisionsStream( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRevisions.createStream( + this.innerApiCalls.listRevisions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRevisions`, 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 Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + * @param {number} request.pageSize + * Maximum number of revisions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 + * [Revision]{@link google.cloud.run.v2.Revision}. 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 include:samples/generated/v2/revisions.list_revisions.js + * region_tag:run_v2_generated_Revisions_ListRevisions_async + */ + listRevisionsAsync( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRevisions.asyncIterate( + this.innerApiCalls['listRevisions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified cryptoKey resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} key_ring + * @param {string} crypto_key + * @returns {string} Resource name string. + */ + cryptoKeyPath(project:string,location:string,keyRing:string,cryptoKey:string) { + return this.pathTemplates.cryptoKeyPathTemplate.render({ + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + }); + } + + /** + * Parse the project from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + } + + /** + * Parse the location from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + } + + /** + * Parse the key_ring from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the key_ring. + */ + matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).key_ring; + } + + /** + * Parse the crypto_key from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the crypto_key. + */ + matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).crypto_key; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).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 revision resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @param {string} revision + * @returns {string} Resource name string. + */ + revisionPath(project:string,location:string,service:string,revision:string) { + return this.pathTemplates.revisionPathTemplate.render({ + project: project, + location: location, + service: service, + revision: revision, + }); + } + + /** + * Parse the project from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).project; + } + + /** + * Parse the location from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).location; + } + + /** + * Parse the service from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the service. + */ + matchServiceFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).service; + } + + /** + * Parse the revision from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the revision. + */ + matchRevisionFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(project:string,location:string,service:string) { + return this.pathTemplates.servicePathTemplate.render({ + project: project, + location: location, + service: service, + }); + } + + /** + * Parse the project from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).project; + } + + /** + * Parse the location from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).location; + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.revisionsStub && !this._terminated) { + return this.revisionsStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/revisions_client_config.json b/owl-bot-staging/v2/src/v2/revisions_client_config.json new file mode 100644 index 0000000..f5a18a2 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/revisions_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.run.v2.Revisions": { + "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": { + "GetRevision": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRevisions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteRevision": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/revisions_proto_list.json b/owl-bot-staging/v2/src/v2/revisions_proto_list.json new file mode 100644 index 0000000..455cae6 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/revisions_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/k8s.min.proto", + "../../protos/google/cloud/run/v2/revision.proto", + "../../protos/google/cloud/run/v2/revision_template.proto", + "../../protos/google/cloud/run/v2/service.proto", + "../../protos/google/cloud/run/v2/traffic_target.proto", + "../../protos/google/cloud/run/v2/vendor_settings.proto" +] diff --git a/owl-bot-staging/v2/src/v2/services_client.ts b/owl-bot-staging/v2/src/v2/services_client.ts new file mode 100644 index 0000000..228aaf7 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/services_client.ts @@ -0,0 +1,1423 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/services_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './services_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Run Service Control Plane API + * @class + * @memberof v2 + */ +export class ServicesClient { + 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}; + operationsClient: gax.OperationsClient; + servicesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServicesClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ServicesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServicesClient; + 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // 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 = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + revisionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}' + ), + }; + + // 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 = { + listServices: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createServiceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const createServiceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const updateServiceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const updateServiceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const deleteServiceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const deleteServiceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createService: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createServiceResponse.decode.bind(createServiceResponse), + createServiceMetadata.decode.bind(createServiceMetadata)), + updateService: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateServiceResponse.decode.bind(updateServiceResponse), + updateServiceMetadata.decode.bind(updateServiceMetadata)), + deleteService: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteServiceResponse.decode.bind(deleteServiceResponse), + deleteServiceMetadata.decode.bind(deleteServiceMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.run.v2.Services', 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 = this._gaxModule.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.servicesStub) { + return this.servicesStub; + } + + // Put together the "service stub" for + // google.cloud.run.v2.Services. + this.servicesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Services') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.run.v2.Services, + 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 servicesStubMethods = + ['createService', 'getService', 'listServices', 'updateService', 'deleteService', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of servicesStubMethods) { + const callPromise = this.servicesStub.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] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.servicesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'run.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 'run.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets information about a Service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Service. + * Format: projects/{projectnumber}/locations/{location}/services/{service} + * @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 [Service]{@link google.cloud.run.v2.Service}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/services.get_service.js + * region_tag:run_v2_generated_Services_GetService_async + */ + getService( + request?: protos.google.cloud.run.v2.IGetServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|undefined, {}|undefined + ]>; + getService( + request: protos.google.cloud.run.v2.IGetServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>): void; + getService( + request: protos.google.cloud.run.v2.IGetServiceRequest, + callback: Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>): void; + getService( + request?: protos.google.cloud.run.v2.IGetServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.getService(request, options, callback); + } +/** + * Get the IAM Access Control policy currently in effect for the given + * Cloud Run Service. This result does not include any inherited policies. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/services.get_iam_policy.js + * region_tag:run_v2_generated_Services_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the IAM Access control policy for the specified Service. Overwrites + * any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/services.set_iam_policy.js + * region_tag:run_v2_generated_Services_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified Project. + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/services.test_iam_permissions.js + * region_tag:run_v2_generated_Services_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Creates a new Service in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project in which this service should be created. + * Format: projects/{projectnumber}/locations/{location} + * @param {google.cloud.run.v2.Service} request.service + * Required. The Service instance to create. + * @param {string} request.serviceId + * Required. The unique identifier for the Service. The name of the service becomes + * {parent}/services/{service_id}. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated and default values + * populated, without persisting the request or creating any resources. + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.create_service.js + * region_tag:run_v2_generated_Services_CreateService_async + */ + createService( + request?: protos.google.cloud.run.v2.ICreateServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createService( + request: protos.google.cloud.run.v2.ICreateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createService( + request: protos.google.cloud.run.v2.ICreateServiceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createService( + request?: protos.google.cloud.run.v2.ICreateServiceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.createService(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createService()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.create_service.js + * region_tag:run_v2_generated_Services_CreateService_async + */ + async checkCreateServiceProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createService, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a Service. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.run.v2.Service} request.service + * Required. The Service to be updated. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated and default values + * populated, without persisting the request or updating any resources. + * @param {boolean} request.allowMissing + * If set to true, and if the Service does not exist, it will create a new + * one. Caller must have both create and update permissions for this call if + * this is set to true. + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.update_service.js + * region_tag:run_v2_generated_Services_UpdateService_async + */ + updateService( + request?: protos.google.cloud.run.v2.IUpdateServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateService( + request: protos.google.cloud.run.v2.IUpdateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateService( + request: protos.google.cloud.run.v2.IUpdateServiceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateService( + request?: protos.google.cloud.run.v2.IUpdateServiceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.service?.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.updateService(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateService()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.update_service.js + * region_tag:run_v2_generated_Services_UpdateService_async + */ + async checkUpdateServiceProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateService, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a Service. + * This will cause the Service to stop serving traffic and will delete all + * revisions. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Service. + * Format: projects/{projectnumber}/locations/{location}/services/{service} + * @param {boolean} request.validateOnly + * Indicates that the request should be validated without actually + * deleting any resources. + * @param {string} request.etag + * A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.delete_service.js + * region_tag:run_v2_generated_Services_DeleteService_async + */ + deleteService( + request?: protos.google.cloud.run.v2.IDeleteServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteService( + request: protos.google.cloud.run.v2.IDeleteServiceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteService( + request: protos.google.cloud.run.v2.IDeleteServiceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteService( + request?: protos.google.cloud.run.v2.IDeleteServiceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.deleteService(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteService()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.delete_service.js + * region_tag:run_v2_generated_Services_DeleteService_async + */ + async checkDeleteServiceProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteService, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * List Services. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project to list resources on. + * Location must be a valid GCP region, and may not be the "-" wildcard. + * Format: projects/{projectnumber}/locations/{location} + * @param {number} request.pageSize + * Maximum number of Services to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListServices. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 [Service]{@link google.cloud.run.v2.Service}. + * 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 `listServicesAsync()` + * 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. + */ + listServices( + request?: protos.google.cloud.run.v2.IListServicesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IService[], + protos.google.cloud.run.v2.IListServicesRequest|null, + protos.google.cloud.run.v2.IListServicesResponse + ]>; + listServices( + request: protos.google.cloud.run.v2.IListServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>): void; + listServices( + request: protos.google.cloud.run.v2.IListServicesRequest, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>): void; + listServices( + request?: protos.google.cloud.run.v2.IListServicesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>, + callback?: PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>): + Promise<[ + protos.google.cloud.run.v2.IService[], + protos.google.cloud.run.v2.IListServicesRequest|null, + protos.google.cloud.run.v2.IListServicesResponse + ]>|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.listServices(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 location and project to list resources on. + * Location must be a valid GCP region, and may not be the "-" wildcard. + * Format: projects/{projectnumber}/locations/{location} + * @param {number} request.pageSize + * Maximum number of Services to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListServices. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 [Service]{@link google.cloud.run.v2.Service} 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 `listServicesAsync()` + * 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. + */ + listServicesStream( + request?: protos.google.cloud.run.v2.IListServicesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listServices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServices.createStream( + this.innerApiCalls.listServices as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServices`, 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 location and project to list resources on. + * Location must be a valid GCP region, and may not be the "-" wildcard. + * Format: projects/{projectnumber}/locations/{location} + * @param {number} request.pageSize + * Maximum number of Services to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListServices. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 + * [Service]{@link google.cloud.run.v2.Service}. 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 include:samples/generated/v2/services.list_services.js + * region_tag:run_v2_generated_Services_ListServices_async + */ + listServicesAsync( + request?: protos.google.cloud.run.v2.IListServicesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listServices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServices.asyncIterate( + this.innerApiCalls['listServices'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).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 revision resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @param {string} revision + * @returns {string} Resource name string. + */ + revisionPath(project:string,location:string,service:string,revision:string) { + return this.pathTemplates.revisionPathTemplate.render({ + project: project, + location: location, + service: service, + revision: revision, + }); + } + + /** + * Parse the project from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).project; + } + + /** + * Parse the location from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).location; + } + + /** + * Parse the service from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the service. + */ + matchServiceFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).service; + } + + /** + * Parse the revision from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the revision. + */ + matchRevisionFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(project:string,location:string,service:string) { + return this.pathTemplates.servicePathTemplate.render({ + project: project, + location: location, + service: service, + }); + } + + /** + * Parse the project from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).project; + } + + /** + * Parse the location from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).location; + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.servicesStub && !this._terminated) { + return this.servicesStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/services_client_config.json b/owl-bot-staging/v2/src/v2/services_client_config.json new file mode 100644 index 0000000..d9a3364 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/services_client_config.json @@ -0,0 +1,75 @@ +{ + "interfaces": { + "google.cloud.run.v2.Services": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateService": { + "timeout_millis": 15000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetService": { + "timeout_millis": 10000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListServices": { + "timeout_millis": 10000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateService": { + "timeout_millis": 15000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteService": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/services_proto_list.json b/owl-bot-staging/v2/src/v2/services_proto_list.json new file mode 100644 index 0000000..455cae6 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/services_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/k8s.min.proto", + "../../protos/google/cloud/run/v2/revision.proto", + "../../protos/google/cloud/run/v2/revision_template.proto", + "../../protos/google/cloud/run/v2/service.proto", + "../../protos/google/cloud/run/v2/traffic_target.proto", + "../../protos/google/cloud/run/v2/vendor_settings.proto" +] diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..01b536f --- /dev/null +++ b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const run = require('@google-cloud/run'); + +function main() { + const revisionsClient = new run.RevisionsClient(); + const servicesClient = new run.ServicesClient(); +} + +main(); diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..769c1b4 --- /dev/null +++ b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {RevisionsClient, ServicesClient} from '@google-cloud/run'; + +// check that the client class type name can be used +function doStuffWithRevisionsClient(client: RevisionsClient) { + client.close(); +} +function doStuffWithServicesClient(client: ServicesClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const revisionsClient = new RevisionsClient(); + doStuffWithRevisionsClient(revisionsClient); + // check that the client instance can be created + const servicesClient = new ServicesClient(); + doStuffWithServicesClient(servicesClient); +} + +main(); diff --git a/owl-bot-staging/v2/system-test/install.ts b/owl-bot-staging/v2/system-test/install.ts new file mode 100644 index 0000000..557a575 --- /dev/null +++ b/owl-bot-staging/v2/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v2/test/gapic_revisions_v2.ts b/owl-bot-staging/v2/test/gapic_revisions_v2.ts new file mode 100644 index 0000000..4b4fb53 --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_revisions_v2.ts @@ -0,0 +1,932 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as revisionsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +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('v2.RevisionsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = revisionsModule.v2.RevisionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = revisionsModule.v2.RevisionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = revisionsModule.v2.RevisionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new revisionsModule.v2.RevisionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new revisionsModule.v2.RevisionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.revisionsStub, undefined); + await client.initialize(); + assert(client.revisionsStub); + }); + + it('has close method for the initialized client', done => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.revisionsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.revisionsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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('getRevision', () => { + it('invokes getRevision without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Revision()); + client.innerApiCalls.getRevision = stubSimpleCall(expectedResponse); + const [response] = await client.getRevision(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getRevision without error using callback', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Revision()); + client.innerApiCalls.getRevision = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRevision( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getRevision with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getRevision = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRevision(request), expectedError); + assert((client.innerApiCalls.getRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getRevision with closed client', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRevision(request), expectedError); + }); + }); + + describe('deleteRevision', () => { + it('invokes deleteRevision without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteRevision = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteRevision(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteRevision without error using callback', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteRevision = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteRevision( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteRevision with call error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteRevision(request), expectedError); + assert((client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteRevision with LRO error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteRevision(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteRevisionProgress without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteRevisionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteRevisionProgress with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteRevisionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listRevisions', () => { + it('invokes listRevisions without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.innerApiCalls.listRevisions = stubSimpleCall(expectedResponse); + const [response] = await client.listRevisions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listRevisions without error using callback', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.innerApiCalls.listRevisions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRevisions( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listRevisions with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listRevisions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRevisions(request), expectedError); + assert((client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listRevisionsStream without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRevisionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Revision[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { + 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.listRevisions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); + assert.strictEqual( + (client.descriptors.page.listRevisions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listRevisionsStream with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedError = new Error('expected'); + client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRevisionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Revision[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRevisions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); + assert.strictEqual( + (client.descriptors.page.listRevisions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listRevisions without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.run.v2.IRevision[] = []; + const iterable = client.listRevisionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listRevisions with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&');const expectedError = new Error('expected'); + client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRevisionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.run.v2.IRevision[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('cryptoKey', () => { + const fakePath = "/rendered/path/cryptoKey"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + key_ring: "keyRingValue", + crypto_key: "cryptoKeyValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cryptoKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.cryptoKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('cryptoKeyPath', () => { + const result = client.cryptoKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCryptoKeyName', () => { + const result = client.matchProjectFromCryptoKeyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCryptoKeyName', () => { + const result = client.matchLocationFromCryptoKeyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchKeyRingFromCryptoKeyName', () => { + const result = client.matchKeyRingFromCryptoKeyName(fakePath); + assert.strictEqual(result, "keyRingValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCryptoKeyFromCryptoKeyName', () => { + const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); + assert.strictEqual(result, "cryptoKeyValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + 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('revision', () => { + const fakePath = "/rendered/path/revision"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + revision: "revisionValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.revisionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.revisionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('revisionPath', () => { + const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRevisionName', () => { + const result = client.matchProjectFromRevisionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRevisionName', () => { + const result = client.matchLocationFromRevisionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromRevisionName', () => { + const result = client.matchServiceFromRevisionName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRevisionFromRevisionName', () => { + const result = client.matchRevisionFromRevisionName(fakePath); + assert.strictEqual(result, "revisionValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("projectValue", "locationValue", "serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_services_v2.ts b/owl-bot-staging/v2/test/gapic_services_v2.ts new file mode 100644 index 0000000..3ec3f34 --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_services_v2.ts @@ -0,0 +1,1485 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as servicesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +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('v2.ServicesClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = servicesModule.v2.ServicesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = servicesModule.v2.ServicesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = servicesModule.v2.ServicesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new servicesModule.v2.ServicesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new servicesModule.v2.ServicesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servicesStub, undefined); + await client.initialize(); + assert(client.servicesStub); + }); + + it('has close method for the initialized client', done => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.servicesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servicesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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('getService', () => { + it('invokes getService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Service()); + client.innerApiCalls.getService = stubSimpleCall(expectedResponse); + const [response] = await client.getService(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Service()); + client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getService( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IService|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getService as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getService with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getService = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getService(request), expectedError); + assert((client.innerApiCalls.getService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getService with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getService(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createService', () => { + it('invokes createService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createService = stubLongRunningCall(expectedResponse); + const [operation] = await client.createService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createService = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createService( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createService as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createService with call error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createService(request), expectedError); + assert((client.innerApiCalls.createService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createService with LRO error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createService(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateServiceProgress without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateServiceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateServiceProgress with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateServiceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateService', () => { + it('invokes updateService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateService = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateService = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateService( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateService as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateService with call error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateService(request), expectedError); + assert((client.innerApiCalls.updateService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateService with LRO error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateService(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.updateService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUpdateServiceProgress without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateServiceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateServiceProgress with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateServiceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteService', () => { + it('invokes deleteService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteService = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteService = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteService( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteService as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteService with call error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteService(request), expectedError); + assert((client.innerApiCalls.deleteService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteService with LRO error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteService(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteServiceProgress without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteServiceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteServiceProgress with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteServiceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); + const [response] = await client.listServices(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServices as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServices without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IService[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServices as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listServices with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServices(request), expectedError); + assert((client.innerApiCalls.listServices as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServicesStream without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Service[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Service) => { + 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.listServices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServices, request)); + assert.strictEqual( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listServicesStream with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedError = new Error('expected'); + client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Service[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Service) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServices, request)); + assert.strictEqual( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServices without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.run.v2.IService[] = []; + const iterable = client.listServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServices with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&');const expectedError = new Error('expected'); + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.run.v2.IService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new servicesModule.v2.ServicesClient({ + 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('revision', () => { + const fakePath = "/rendered/path/revision"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + revision: "revisionValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.revisionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.revisionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('revisionPath', () => { + const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRevisionName', () => { + const result = client.matchProjectFromRevisionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRevisionName', () => { + const result = client.matchLocationFromRevisionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromRevisionName', () => { + const result = client.matchServiceFromRevisionName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRevisionFromRevisionName', () => { + const result = client.matchRevisionFromRevisionName(fakePath); + assert.strictEqual(result, "revisionValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("projectValue", "locationValue", "serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/tsconfig.json b/owl-bot-staging/v2/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v2/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/v2/webpack.config.js b/owl-bot-staging/v2/webpack.config.js new file mode 100644 index 0000000..36eeb4b --- /dev/null +++ b/owl-bot-staging/v2/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: 'Revisions', + filename: './revisions.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From f81aa2419fc9a499f0c6b27863f329196a3f1717 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 26 Aug 2022 23:13:23 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- owl-bot-staging/v2/.eslintignore | 7 - owl-bot-staging/v2/.eslintrc.json | 3 - owl-bot-staging/v2/.gitignore | 14 - owl-bot-staging/v2/.jsdoc.js | 55 - owl-bot-staging/v2/.mocharc.js | 33 - owl-bot-staging/v2/.prettierrc.js | 22 - owl-bot-staging/v2/README.md | 1 - owl-bot-staging/v2/linkinator.config.json | 16 - owl-bot-staging/v2/package.json | 65 - .../google/cloud/run/v2/condition.proto | 199 --- .../protos/google/cloud/run/v2/k8s.min.proto | 274 --- .../protos/google/cloud/run/v2/revision.proto | 278 --- .../cloud/run/v2/revision_template.proto | 79 - .../protos/google/cloud/run/v2/service.proto | 435 ----- .../google/cloud/run/v2/traffic_target.proto | 77 - .../google/cloud/run/v2/vendor_settings.proto | 102 -- .../generated/v2/revisions.delete_revision.js | 74 - .../generated/v2/revisions.get_revision.js | 63 - .../generated/v2/revisions.list_revisions.js | 79 - .../generated/v2/services.create_service.js | 79 - .../generated/v2/services.delete_service.js | 73 - .../generated/v2/services.get_iam_policy.js | 67 - .../generated/v2/services.get_service.js | 62 - .../generated/v2/services.list_services.js | 78 - .../generated/v2/services.set_iam_policy.js | 77 - .../v2/services.test_iam_permissions.js | 70 - .../generated/v2/services.update_service.js | 73 - .../snippet_metadata.google.cloud.run.v2.json | 531 ------ owl-bot-staging/v2/src/index.ts | 27 - owl-bot-staging/v2/src/v2/gapic_metadata.json | 155 -- owl-bot-staging/v2/src/v2/index.ts | 20 - owl-bot-staging/v2/src/v2/revisions_client.ts | 1016 ----------- .../v2/src/v2/revisions_client_config.json | 38 - .../v2/src/v2/revisions_proto_list.json | 9 - owl-bot-staging/v2/src/v2/services_client.ts | 1423 ---------------- .../v2/src/v2/services_client_config.json | 75 - .../v2/src/v2/services_proto_list.json | 9 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - owl-bot-staging/v2/system-test/install.ts | 49 - owl-bot-staging/v2/test/gapic_revisions_v2.ts | 932 ----------- owl-bot-staging/v2/test/gapic_services_v2.ts | 1485 ----------------- owl-bot-staging/v2/tsconfig.json | 19 - owl-bot-staging/v2/webpack.config.js | 64 - src/v2/revisions_client.ts | 46 +- src/v2/services_client.ts | 74 +- 46 files changed, 75 insertions(+), 8418 deletions(-) delete mode 100644 owl-bot-staging/v2/.eslintignore delete mode 100644 owl-bot-staging/v2/.eslintrc.json delete mode 100644 owl-bot-staging/v2/.gitignore delete mode 100644 owl-bot-staging/v2/.jsdoc.js delete mode 100644 owl-bot-staging/v2/.mocharc.js delete mode 100644 owl-bot-staging/v2/.prettierrc.js delete mode 100644 owl-bot-staging/v2/README.md delete mode 100644 owl-bot-staging/v2/linkinator.config.json delete mode 100644 owl-bot-staging/v2/package.json delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto delete mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.create_service.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.delete_service.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.get_service.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.list_services.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.update_service.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json delete mode 100644 owl-bot-staging/v2/src/index.ts delete mode 100644 owl-bot-staging/v2/src/v2/gapic_metadata.json delete mode 100644 owl-bot-staging/v2/src/v2/index.ts delete mode 100644 owl-bot-staging/v2/src/v2/revisions_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/revisions_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/revisions_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/services_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/services_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/services_proto_list.json delete mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v2/system-test/install.ts delete mode 100644 owl-bot-staging/v2/test/gapic_revisions_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_services_v2.ts delete mode 100644 owl-bot-staging/v2/tsconfig.json delete mode 100644 owl-bot-staging/v2/webpack.config.js diff --git a/owl-bot-staging/v2/.eslintignore b/owl-bot-staging/v2/.eslintignore deleted file mode 100644 index cfc348e..0000000 --- a/owl-bot-staging/v2/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v2/.eslintrc.json b/owl-bot-staging/v2/.eslintrc.json deleted file mode 100644 index 7821534..0000000 --- a/owl-bot-staging/v2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v2/.gitignore b/owl-bot-staging/v2/.gitignore deleted file mode 100644 index 5d32b23..0000000 --- a/owl-bot-staging/v2/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v2/.jsdoc.js b/owl-bot-staging/v2/.jsdoc.js deleted file mode 100644 index 94fed36..0000000 --- a/owl-bot-staging/v2/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/run', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v2/.mocharc.js b/owl-bot-staging/v2/.mocharc.js deleted file mode 100644 index 481c522..0000000 --- a/owl-bot-staging/v2/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v2/.prettierrc.js b/owl-bot-staging/v2/.prettierrc.js deleted file mode 100644 index 494e147..0000000 --- a/owl-bot-staging/v2/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v2/README.md b/owl-bot-staging/v2/README.md deleted file mode 100644 index bc79325..0000000 --- a/owl-bot-staging/v2/README.md +++ /dev/null @@ -1 +0,0 @@ -Run: Nodejs Client diff --git a/owl-bot-staging/v2/linkinator.config.json b/owl-bot-staging/v2/linkinator.config.json deleted file mode 100644 index befd23c..0000000 --- a/owl-bot-staging/v2/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/v2/package.json b/owl-bot-staging/v2/package.json deleted file mode 100644 index c6ef74d..0000000 --- a/owl-bot-staging/v2/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/run", - "version": "0.1.0", - "description": "Run client for Node.js", - "repository": "googleapis/nodejs-run", - "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 run", - "run", - "revisions", - "services" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.0" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto deleted file mode 100644 index 3e98749..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "ConditionProto"; -option java_package = "com.google.cloud.run.v2"; - -// Defines a status condition for a resource. -message Condition { - // Represents the possible Condition states. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // Transient state: Reconciliation has not started yet. - CONDITION_PENDING = 1; - - // Transient state: reconciliation is still in progress. - CONDITION_RECONCILING = 2; - - // Terminal state: Reconciliation did not succeed. - CONDITION_FAILED = 3; - - // Terminal state: Reconciliation completed successfully. - CONDITION_SUCCEEDED = 4; - } - - // Represents the severity of the condition failures. - enum Severity { - // Unspecified severity - SEVERITY_UNSPECIFIED = 0; - - // Error severity. - ERROR = 1; - - // Warning severity. - WARNING = 2; - - // Info severity. - INFO = 3; - } - - // Reasons common to all types of conditions. - enum CommonReason { - // Default value. - COMMON_REASON_UNDEFINED = 0; - - // Reason unknown. Further details will be in message. - UNKNOWN = 1; - - // Revision creation process failed. - REVISION_FAILED = 3; - - // Timed out waiting for completion. - PROGRESS_DEADLINE_EXCEEDED = 4; - - // The container image path is incorrect. - CONTAINER_MISSING = 6; - - // Insufficient permissions on the container image. - CONTAINER_PERMISSION_DENIED = 7; - - // Container image is not authorized by policy. - CONTAINER_IMAGE_UNAUTHORIZED = 8; - - // Container image policy authorization check failed. - CONTAINER_IMAGE_AUTHORIZATION_CHECK_FAILED = 9; - - // Insufficient permissions on encryption key. - ENCRYPTION_KEY_PERMISSION_DENIED = 10; - - // Permission check on encryption key failed. - ENCRYPTION_KEY_CHECK_FAILED = 11; - - // At least one Access check on secrets failed. - SECRETS_ACCESS_CHECK_FAILED = 12; - - // Waiting for operation to complete. - WAITING_FOR_OPERATION = 13; - - // System will retry immediately. - IMMEDIATE_RETRY = 14; - - // System will retry later; current attempt failed. - POSTPONED_RETRY = 15; - - // An internal error occurred. Further information may be in the message. - INTERNAL = 16; - } - - // Reasons specific to Revision resource. - enum RevisionReason { - // Default value. - REVISION_REASON_UNDEFINED = 0; - - // Revision in Pending state. - PENDING = 1; - - // Revision is in Reserve state. - RESERVE = 2; - - // Revision is Retired. - RETIRED = 3; - - // Revision is being retired. - RETIRING = 4; - - // Revision is being recreated. - RECREATING = 5; - - // There was a health check error. - HEALTH_CHECK_CONTAINER_ERROR = 6; - - // Health check failed due to user error from customized path of the - // container. System will retry. - CUSTOMIZED_PATH_RESPONSE_PENDING = 7; - - // A revision with min_instance_count > 0 was created and is reserved, but - // it was not configured to serve traffic, so it's not live. This can also - // happen momentarily during traffic migration. - MIN_INSTANCES_NOT_PROVISIONED = 8; - - // The maximum allowed number of active revisions has been reached. - ACTIVE_REVISION_LIMIT_REACHED = 9; - - // There was no deployment defined. - // This value is no longer used, but Services created in older versions of - // the API might contain this value. - NO_DEPLOYMENT = 10; - - // A revision's container has no port specified since the revision is of a - // manually scaled service with 0 instance count - HEALTH_CHECK_SKIPPED = 11; - } - - // Reasons specific to Execution resource. - enum ExecutionReason { - // Default value. - EXECUTION_REASON_UNDEFINED = 0; - - // Internal system error getting execution status. System will retry. - JOB_STATUS_SERVICE_POLLING_ERROR = 1; - - // A task reached its retry limit and the last attempt failed due to the - // user container exiting with a non-zero exit code. - NON_ZERO_EXIT_CODE = 2; - } - - // type is used to communicate the status of the reconciliation process. - // See also: - // https://github.com/knative/serving/blob/main/docs/spec/errors.md#error-conditions-and-reporting - // Types common to all resources include: - // * "Ready": True when the Resource is ready. - string type = 1; - - // State of the condition. - State state = 2; - - // Human readable message indicating details about the current status. - string message = 3; - - // Last time the condition transitioned from one status to another. - google.protobuf.Timestamp last_transition_time = 4; - - // How to interpret failures of this condition, one of Error, Warning, Info - Severity severity = 5; - - // The reason for this condition. Depending on the condition type, - // it will populate one of these fields. - // Successful conditions may not have a reason. - oneof reasons { - // A common (service-level) reason for this condition. - CommonReason reason = 6; - - // A reason for the revision condition. - RevisionReason revision_reason = 9; - - // A reason for the execution condition. - ExecutionReason execution_reason = 11; - } -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto deleted file mode 100644 index 328c816..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto +++ /dev/null @@ -1,274 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "K8sMinProto"; -option java_package = "com.google.cloud.run.v2"; -option (google.api.resource_definition) = { - type: "cloudkms.googleapis.com/CryptoKey" - pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}" -}; -option (google.api.resource_definition) = { - type: "secretmanager.googleapis.com/Secret" - pattern: "projects/{project}/secrets/{secret}" -}; -option (google.api.resource_definition) = { - type: "secretmanager.googleapis.com/SecretVersion" - pattern: "projects/{project}/secrets/{secret}/versions/{version}" -}; -option (google.api.resource_definition) = { - type: "vpcaccess.googleapis.com/Connector" - pattern: "projects/{project}/locations/{location}/connectors/{connector}" -}; - -// A single application container. -// This specifies both the container to run, the command to run in the container -// and the arguments to supply to it. -// Note that additional arguments may be supplied by the system to the container -// at runtime. -message Container { - // Name of the container specified as a DNS_LABEL. - string name = 1; - - // Required. URL of the Container image in Google Container Registry or Google Artifact - // Registry. More info: https://kubernetes.io/docs/concepts/containers/images - string image = 2 [(google.api.field_behavior) = REQUIRED]; - - // Entrypoint array. Not executed within a shell. - // The docker image's ENTRYPOINT is used if this is not provided. - // Variable references $(VAR_NAME) are expanded using the container's - // environment. If a variable cannot be resolved, the reference in the input - // string will be unchanged. The $(VAR_NAME) syntax can be escaped with a - // double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, - // regardless of whether the variable exists or not. - // More info: - // https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - repeated string command = 3; - - // Arguments to the entrypoint. - // The docker image's CMD is used if this is not provided. - // Variable references $(VAR_NAME) are expanded using the container's - // environment. If a variable cannot be resolved, the reference in the input - // string will be unchanged. The $(VAR_NAME) syntax can be escaped with a - // double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, - // regardless of whether the variable exists or not. - // More info: - // https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - repeated string args = 4; - - // List of environment variables to set in the container. - repeated EnvVar env = 5; - - // Compute Resource requirements by this container. - // More info: - // https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources - ResourceRequirements resources = 6; - - // List of ports to expose from the container. Only a single port can be - // specified. The specified ports must be listening on all interfaces - // (0.0.0.0) within the container to be accessible. - // - // If omitted, a port number will be chosen and passed to the container - // through the PORT environment variable for the container to listen on. - repeated ContainerPort ports = 7; - - // Volume to mount into the container's filesystem. - repeated VolumeMount volume_mounts = 8; -} - -// ResourceRequirements describes the compute resource requirements. -message ResourceRequirements { - // Only memory and CPU are supported. Note: The only - // supported values for CPU are '1', '2', and '4'. Setting 4 CPU requires at - // least 2Gi of memory. - // The values of the map is string form of the 'quantity' k8s type: - // https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go - map limits = 1; - - // Determines whether CPU should be throttled or not outside of requests. - bool cpu_idle = 2; -} - -// EnvVar represents an environment variable present in a Container. -message EnvVar { - // Required. Name of the environment variable. Must be a C_IDENTIFIER, and mnay not - // exceed 32768 characters. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - oneof values { - // Variable references $(VAR_NAME) are expanded - // using the previous defined environment variables in the container and - // any route environment variables. If a variable cannot be resolved, - // the reference in the input string will be unchanged. The $(VAR_NAME) - // syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped - // references will never be expanded, regardless of whether the variable - // exists or not. - // Defaults to "", and the maximum length is 32768 bytes. - string value = 2; - - // Source for the environment variable's value. - EnvVarSource value_source = 3; - } -} - -// EnvVarSource represents a source for the value of an EnvVar. -message EnvVarSource { - // Selects a secret and a specific version from Cloud Secret Manager. - SecretKeySelector secret_key_ref = 1; -} - -// SecretEnvVarSource represents a source for the value of an EnvVar. -message SecretKeySelector { - // Required. The name of the secret in Cloud Secret Manager. - // Format: {secret_name} if the secret is in the same project. - // projects/{project}/secrets/{secret_name} if the secret is - // in a different project. - string secret = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "secretmanager.googleapis.com/Secret" - } - ]; - - // The Cloud Secret Manager secret version. - // Can be 'latest' for the latest value or an integer for a specific version. - string version = 2 [(google.api.resource_reference) = { - type: "secretmanager.googleapis.com/SecretVersion" - }]; -} - -// ContainerPort represents a network port in a single container. -message ContainerPort { - // If specified, used to specify which protocol to use. - // Allowed values are "http1" and "h2c". - string name = 1; - - // Port number the container listens on. - // This must be a valid TCP port number, 0 < container_port < 65536. - int32 container_port = 3; -} - -// VolumeMount describes a mounting of a Volume within a container. -message VolumeMount { - // Required. This must match the Name of a Volume. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Path within the container at which the volume should be mounted. Must - // not contain ':'. For Cloud SQL volumes, it can be left empty, or must - // otherwise be `/cloudsql`. All instances defined in the Volume will be - // available as `/cloudsql/[instance]`. For more information on Cloud SQL - // volumes, visit https://cloud.google.com/sql/docs/mysql/connect-run - string mount_path = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Volume represents a named volume in a container. -message Volume { - // Required. Volume's name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - oneof volume_type { - // Secret represents a secret that should populate this volume. - // More info: https://kubernetes.io/docs/concepts/storage/volumes#secret - SecretVolumeSource secret = 2; - - // For Cloud SQL volumes, contains the specific instances that should be - // mounted. Visit https://cloud.google.com/sql/docs/mysql/connect-run for - // more information on how to connect Cloud SQL and Cloud Run. - CloudSqlInstance cloud_sql_instance = 3; - } -} - -// The secret's value will be presented as the content of a file whose -// name is defined in the item path. If no items are defined, the name of -// the file is the secret. -message SecretVolumeSource { - // Required. The name of the secret in Cloud Secret Manager. - // Format: {secret} if the secret is in the same project. - // projects/{project}/secrets/{secret} if the secret is - // in a different project. - string secret = 1 [(google.api.field_behavior) = REQUIRED]; - - // If unspecified, the volume will expose a file whose name is the - // secret, relative to VolumeMount.mount_path. - // If specified, the key will be used as the version to fetch from Cloud - // Secret Manager and the path will be the name of the file exposed in the - // volume. When items are defined, they must specify a path and a version. - repeated VersionToPath items = 2; - - // Integer representation of mode bits to use on created files by default. - // Must be a value between 0000 and 0777 (octal), defaulting to 0644. - // Directories within the path are not affected by this setting. - // - // Notes - // - // * Internally, a umask of 0222 will be applied to any non-zero value. - // * This is an integer representation of the mode bits. So, the octal - // integer value should look exactly as the chmod numeric notation with a - // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or - // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or - // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 - // (base-10). - // * This might be in conflict with other options that affect the - // file mode, like fsGroup, and the result can be other mode bits set. - // - // This might be in conflict with other options that affect the - // file mode, like fsGroup, and as a result, other mode bits could be set. - int32 default_mode = 3; -} - -// VersionToPath maps a specific version of a secret to a relative file to mount -// to, relative to VolumeMount's mount_path. -message VersionToPath { - // Required. The relative path of the secret in the container. - string path = 1 [(google.api.field_behavior) = REQUIRED]; - - // The Cloud Secret Manager secret version. - // Can be 'latest' for the latest value or an integer for a specific version. - string version = 2; - - // Integer octal mode bits to use on this file, must be a value between - // 01 and 0777 (octal). If 0 or not set, the Volume's default mode will be - // used. - // - // Notes - // - // * Internally, a umask of 0222 will be applied to any non-zero value. - // * This is an integer representation of the mode bits. So, the octal - // integer value should look exactly as the chmod numeric notation with a - // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or - // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or - // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 - // (base-10). - // * This might be in conflict with other options that affect the - // file mode, like fsGroup, and the result can be other mode bits set. - int32 mode = 3; -} - -// Represents a specific Cloud SQL instance. -message CloudSqlInstance { - // The Cloud SQL instance connection names, as can be found in - // https://console.cloud.google.com/sql/instances. Visit - // https://cloud.google.com/sql/docs/mysql/connect-run for more information on - // how to connect Cloud SQL and Cloud Run. Format: - // {project}:{location}:{instance} - repeated string instances = 1; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto deleted file mode 100644 index 0cb674e..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/launch_stage.proto"; -import "google/api/resource.proto"; -import "google/api/routing.proto"; -import "google/cloud/run/v2/condition.proto"; -import "google/cloud/run/v2/k8s.min.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "RevisionProto"; -option java_package = "com.google.cloud.run.v2"; - -// Cloud Run Revision Control Plane API. -service Revisions { - option (google.api.default_host) = "run.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Gets information about a Revision. - rpc GetRevision(GetRevisionRequest) returns (Revision) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - } - - // List Revisions from a given Service, or from a given location. - rpc ListRevisions(ListRevisionsRequest) returns (ListRevisionsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*/services/*}/revisions" - }; - option (google.api.routing) = { - routing_parameters { - field: "parent" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Delete a Revision. - rpc DeleteRevision(DeleteRevisionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Revision" - metadata_type: "Revision" - }; - } -} - -// Request message for obtaining a Revision by its full name. -message GetRevisionRequest { - // Required. The full name of the Revision. - // Format: - // projects/{project}/locations/{location}/services/{service}/revisions/{revision} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - } - ]; -} - -// Request message for retrieving a list of Revisions. -message ListRevisionsRequest { - // Required. The Service from which the Revisions should be listed. - // To list all Revisions across Services, use "-" instead of Service name. - // Format: - // projects/{project}/locations/{location}/services/{service} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "run.googleapis.com/Revision" - } - ]; - - // Maximum number of revisions to return in this call. - int32 page_size = 2; - - // A page token received from a previous call to ListRevisions. - // All other parameters must match. - string page_token = 3; - - // If true, returns deleted (but unexpired) resources along with active ones. - bool show_deleted = 4; -} - -// Response message containing a list of Revisions. -message ListRevisionsResponse { - // The resulting list of Revisions. - repeated Revision revisions = 1; - - // A token indicating there are more items than page_size. Use it in the next - // ListRevisions request to continue. - string next_page_token = 2; -} - -// Request message for deleting a retired Revision. -// Revision lifecycle is usually managed by making changes to the parent -// Service. Only retired revisions can be deleted with this API. -message DeleteRevisionRequest { - // Required. The name of the Revision to delete. - // Format: - // projects/{project}/locations/{location}/services/{service}/revisions/{revision} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - } - ]; - - // Indicates that the request should be validated without actually - // deleting any resources. - bool validate_only = 2; - - // A system-generated fingerprint for this version of the - // resource. This may be used to detect modification conflict during updates. - string etag = 3; -} - -// A Revision is an immutable snapshot of code and configuration. A Revision -// references a container image. Revisions are only created by updates to its -// parent Service. -message Revision { - option (google.api.resource) = { - type: "run.googleapis.com/Revision" - pattern: "projects/{project}/locations/{location}/services/{service}/revisions/{revision}" - style: DECLARATIVE_FRIENDLY - }; - - // Output only. The unique name of this Revision. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server assigned unique identifier for the Revision. The value is a UUID4 - // string and guaranteed to remain unchanged until the resource is deleted. - string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A number that monotonically increases every time the user - // modifies the desired state. - int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // KRM-style labels for the resource. - // User-provided labels are shared with Google's billing system, so they can - // be used to filter, or break down billing charges by team, component, - // environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels - // Cloud Run will populate some labels with 'run.googleapis.com' or - // 'serving.knative.dev' namespaces. Those labels are read-only, and user - // changes will not be preserved. - map labels = 4; - - // KRM-style annotations for the resource. - map annotations = 5; - - // Output only. The creation time. - google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last-modified time. - google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the deletion time. It is only - // populated as a response to a Delete request. - google.protobuf.Timestamp delete_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the time after which it will be - // permamently deleted. It is only populated as a response to a Delete - // request. - google.protobuf.Timestamp expire_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Set the launch stage to a preview stage on write to allow use of preview - // features in that stage. On read, describes whether the resource uses - // preview features. Launch Stages are defined at [Google Cloud Platform - // Launch Stages](https://cloud.google.com/terms/launch-stages). - google.api.LaunchStage launch_stage = 10; - - // Output only. The name of the parent service. - string service = 11 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "run.googleapis.com/Service" - } - ]; - - // Scaling settings for this revision. - RevisionScaling scaling = 12; - - // VPC Access configuration for this Revision. For more information, visit - // https://cloud.google.com/run/docs/configuring/connecting-vpc. - VpcAccess vpc_access = 13; - - // Sets the maximum number of requests that each serving instance can receive. - int32 max_instance_request_concurrency = 34; - - // Max allowed time for an instance to respond to a request. - google.protobuf.Duration timeout = 15; - - // Email address of the IAM service account associated with the revision of - // the service. The service account represents the identity of the running - // revision, and determines what permissions the revision has. - string service_account = 16; - - // Holds the single container that defines the unit of execution for this - // Revision. - repeated Container containers = 17; - - // A list of Volumes to make available to containers. - repeated Volume volumes = 18; - - // The execution environment being used to host this Revision. - ExecutionEnvironment execution_environment = 20; - - // A reference to a customer managed encryption key (CMEK) to use to encrypt - // this container image. For more information, go to - // https://cloud.google.com/run/docs/securing/using-cmek - string encryption_key = 21 [(google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - }]; - - // Output only. Indicates whether the resource's reconciliation is still in progress. - // See comments in `Service.reconciling` for additional information on - // reconciliation process in Cloud Run. - bool reconciling = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Condition of this Revision, containing its readiness status, and - // detailed error information in case it did not reach a serving state. - repeated Condition conditions = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The generation of this Revision currently serving traffic. See comments in - // `reconciling` for additional information on reconciliation process in Cloud - // Run. - int64 observed_generation = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Google Console URI to obtain logs for the Revision. - string log_uri = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto deleted file mode 100644 index f20fb5e..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/resource.proto"; -import "google/cloud/run/v2/k8s.min.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/protobuf/duration.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "RevisionTemplateProto"; -option java_package = "com.google.cloud.run.v2"; - -// RevisionTemplate describes the data a revision should have when created from -// a template. -message RevisionTemplate { - // The unique name for the revision. If this field is omitted, it will be - // automatically generated based on the Service name. - string revision = 1 [(google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - }]; - - // KRM-style labels for the resource. - map labels = 2; - - // KRM-style annotations for the resource. - map annotations = 3; - - // Scaling settings for this Revision. - RevisionScaling scaling = 4; - - // VPC Access configuration to use for this Revision. For more information, - // visit https://cloud.google.com/run/docs/configuring/connecting-vpc. - VpcAccess vpc_access = 6; - - // Max allowed time for an instance to respond to a request. - google.protobuf.Duration timeout = 8; - - // Email address of the IAM service account associated with the revision of - // the service. The service account represents the identity of the running - // revision, and determines what permissions the revision has. If not - // provided, the revision will use the project's default service account. - string service_account = 9; - - // Holds the single container that defines the unit of execution for this - // Revision. - repeated Container containers = 10; - - // A list of Volumes to make available to containers. - repeated Volume volumes = 11; - - // The sandbox environment to host this Revision. - ExecutionEnvironment execution_environment = 13; - - // A reference to a customer managed encryption key (CMEK) to use to encrypt - // this container image. For more information, go to - // https://cloud.google.com/run/docs/securing/using-cmek - string encryption_key = 14 [(google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - }]; - - // Sets the maximum number of requests that each serving instance can receive. - int32 max_instance_request_concurrency = 15; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto deleted file mode 100644 index 51a29ed..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto +++ /dev/null @@ -1,435 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/launch_stage.proto"; -import "google/api/resource.proto"; -import "google/api/routing.proto"; -import "google/cloud/run/v2/condition.proto"; -import "google/cloud/run/v2/revision_template.proto"; -import "google/cloud/run/v2/traffic_target.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "ServiceProto"; -option java_package = "com.google.cloud.run.v2"; - -// Cloud Run Service Control Plane API -service Services { - option (google.api.default_host) = "run.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a new Service in a given project and location. - rpc CreateService(CreateServiceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*}/services" - body: "service" - }; - option (google.api.routing) = { - routing_parameters { - field: "parent" - path_template: "projects/*/locations/{location=*}" - } - }; - option (google.api.method_signature) = "parent,service,service_id"; - option (google.longrunning.operation_info) = { - response_type: "Service" - metadata_type: "Service" - }; - } - - // Gets information about a Service. - rpc GetService(GetServiceRequest) returns (Service) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/services/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - } - - // List Services. - rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*}/services" - }; - option (google.api.routing) = { - routing_parameters { - field: "parent" - path_template: "projects/*/locations/{location=*}" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a Service. - rpc UpdateService(UpdateServiceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v2/{service.name=projects/*/locations/*/services/*}" - body: "service" - }; - option (google.api.routing) = { - routing_parameters { - field: "service.name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "service"; - option (google.longrunning.operation_info) = { - response_type: "Service" - metadata_type: "Service" - }; - } - - // Deletes a Service. - // This will cause the Service to stop serving traffic and will delete all - // revisions. - rpc DeleteService(DeleteServiceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/services/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Service" - metadata_type: "Service" - }; - } - - // Get the IAM Access Control policy currently in effect for the given - // Cloud Run Service. This result does not include any inherited policies. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - get: "/v2/{resource=projects/*/locations/*/services/*}:getIamPolicy" - }; - } - - // Sets the IAM Access control policy for the specified Service. Overwrites - // any existing policy. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v2/{resource=projects/*/locations/*/services/*}:setIamPolicy" - body: "*" - }; - } - - // Returns permissions that a caller has on the specified Project. - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v2/{resource=projects/*/locations/*/services/*}:testIamPermissions" - body: "*" - }; - } -} - -// Request message for creating a Service. -message CreateServiceRequest { - // Required. The location and project in which this service should be created. - // Format: projects/{projectnumber}/locations/{location} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "run.googleapis.com/Service" - } - ]; - - // Required. The Service instance to create. - Service service = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The unique identifier for the Service. The name of the service becomes - // {parent}/services/{service_id}. - string service_id = 3 [(google.api.field_behavior) = REQUIRED]; - - // Indicates that the request should be validated and default values - // populated, without persisting the request or creating any resources. - bool validate_only = 4; -} - -// Request message for updating a service. -message UpdateServiceRequest { - // Required. The Service to be updated. - Service service = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates that the request should be validated and default values - // populated, without persisting the request or updating any resources. - bool validate_only = 3; - - // If set to true, and if the Service does not exist, it will create a new - // one. Caller must have both create and update permissions for this call if - // this is set to true. - bool allow_missing = 4; -} - -// Request message for retrieving a list of Services. -message ListServicesRequest { - // Required. The location and project to list resources on. - // Location must be a valid GCP region, and may not be the "-" wildcard. - // Format: projects/{projectnumber}/locations/{location} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "run.googleapis.com/Service" - } - ]; - - // Maximum number of Services to return in this call. - int32 page_size = 2; - - // A page token received from a previous call to ListServices. - // All other parameters must match. - string page_token = 3; - - // If true, returns deleted (but unexpired) resources along with active ones. - bool show_deleted = 4; -} - -// Response message containing a list of Services. -message ListServicesResponse { - // The resulting list of Services. - repeated Service services = 1; - - // A token indicating there are more items than page_size. Use it in the next - // ListServices request to continue. - string next_page_token = 2; -} - -// Request message for obtaining a Service by its full name. -message GetServiceRequest { - // Required. The full name of the Service. - // Format: projects/{projectnumber}/locations/{location}/services/{service} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "run.googleapis.com/Service" - } - ]; -} - -// Request message to delete a Service by its full name. -message DeleteServiceRequest { - // Required. The full name of the Service. - // Format: projects/{projectnumber}/locations/{location}/services/{service} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "run.googleapis.com/Service" - } - ]; - - // Indicates that the request should be validated without actually - // deleting any resources. - bool validate_only = 2; - - // A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 3; -} - -// Service acts as a top-level container that manages a set of -// configurations and revision templates which implement a network service. -// Service exists to provide a singular abstraction which can be access -// controlled, reasoned about, and which encapsulates software lifecycle -// decisions such as rollout policy and team resource ownership. -message Service { - option (google.api.resource) = { - type: "run.googleapis.com/Service" - pattern: "projects/{project}/locations/{location}/services/{service}" - style: DECLARATIVE_FRIENDLY - }; - - // The fully qualified name of this Service. In CreateServiceRequest, this - // field is ignored, and instead composed from CreateServiceRequest.parent and - // CreateServiceRequest.service_id. - // - // Format: - // projects/{project}/locations/{location}/services/{service_id} - string name = 1; - - // User-provided description of the Service. This field currently has a - // 512-character limit. - string description = 2; - - // Output only. Server assigned unique identifier for the trigger. The value is a UUID4 - // string and guaranteed to remain unchanged until the resource is deleted. - string uid = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A number that monotonically increases every time the user - // modifies the desired state. - // Please note that unlike v1, this is an int64 value. As with most Google - // APIs, its JSON representation will be a `string` instead of an `integer`. - int64 generation = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Map of string keys and values that can be used to organize and categorize - // objects. - // User-provided labels are shared with Google's billing system, so they can - // be used to filter, or break down billing charges by team, component, - // environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels - // Cloud Run will populate some labels with 'run.googleapis.com' or - // 'serving.knative.dev' namespaces. Those labels are read-only, and user - // changes will not be preserved. - map labels = 5; - - // Unstructured key value map that may be set by external tools to store and - // arbitrary metadata. They are not queryable and should be preserved - // when modifying objects. Cloud Run will populate some annotations using - // 'run.googleapis.com' or 'serving.knative.dev' namespaces. This field - // follows Kubernetes annotations' namespacing, limits, and rules. More info: - // https://kubernetes.io/docs/user-guide/annotations - map annotations = 6; - - // Output only. The creation time. - google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last-modified time. - google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The deletion time. - google.protobuf.Timestamp delete_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the time after which it will be - // permamently deleted. - google.protobuf.Timestamp expire_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Email address of the authenticated creator. - string creator = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Email address of the last authenticated modifier. - string last_modifier = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Arbitrary identifier for the API client. - string client = 13; - - // Arbitrary version identifier for the API client. - string client_version = 14; - - // Provides the ingress settings for this Service. On output, returns the - // currently observed ingress settings, or INGRESS_TRAFFIC_UNSPECIFIED if no - // revision is active. - IngressTraffic ingress = 15; - - // The launch stage as defined by [Google Cloud Platform - // Launch Stages](https://cloud.google.com/terms/launch-stages). - // Cloud Run supports `ALPHA`, `BETA`, and `GA`. If no value is specified, GA - // is assumed. - google.api.LaunchStage launch_stage = 16; - - // Settings for the Binary Authorization feature. - BinaryAuthorization binary_authorization = 17; - - // Required. The template used to create revisions for this Service. - RevisionTemplate template = 18 [(google.api.field_behavior) = REQUIRED]; - - // Specifies how to distribute traffic over a collection of Revisions - // belonging to the Service. If traffic is empty or not provided, defaults to - // 100% traffic to the latest `Ready` Revision. - repeated TrafficTarget traffic = 19; - - // Output only. The generation of this Service currently serving traffic. See comments in - // `reconciling` for additional information on reconciliation process in Cloud - // Run. - // Please note that unlike v1, this is an int64 value. As with most Google - // APIs, its JSON representation will be a `string` instead of an `integer`. - int64 observed_generation = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Condition of this Service, containing its readiness status, and - // detailed error information in case it did not reach a serving state. See - // comments in `reconciling` for additional information on reconciliation - // process in Cloud Run. - Condition terminal_condition = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Conditions of all other associated sub-resources. They contain - // additional diagnostics information in case the Service does not reach its - // Serving state. See comments in `reconciling` for additional information on - // reconciliation process in Cloud Run. - repeated Condition conditions = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the latest revision that is serving traffic. See comments in - // `reconciling` for additional information on reconciliation process in Cloud - // Run. - string latest_ready_revision = 33 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - } - ]; - - // Output only. Name of the last created revision. See comments in `reconciling` for - // additional information on reconciliation process in Cloud Run. - string latest_created_revision = 34 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - } - ]; - - // Output only. Detailed status information for corresponding traffic targets. See comments - // in `reconciling` for additional information on reconciliation process in - // Cloud Run. - repeated TrafficTargetStatus traffic_statuses = 35 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The main URI in which this Service is serving traffic. - string uri = 36 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Returns true if the Service is currently being acted upon by the system to - // bring it into the desired state. - // - // When a new Service is created, or an existing one is updated, Cloud Run - // will asynchronously perform all necessary steps to bring the Service to the - // desired serving state. This process is called reconciliation. - // While reconciliation is in process, `observed_generation`, - // `latest_ready_revison`, `traffic_statuses`, and `uri` will have transient - // values that might mismatch the intended state: Once reconciliation is over - // (and this field is false), there are two possible outcomes: reconciliation - // succeeded and the serving state matches the Service, or there was an error, - // and reconciliation failed. This state can be found in - // `terminal_condition.state`. - // - // If reconciliation succeeded, the following fields will match: `traffic` and - // `traffic_statuses`, `observed_generation` and `generation`, - // `latest_ready_revision` and `latest_created_revision`. - // - // If reconciliation failed, `traffic_statuses`, `observed_generation`, and - // `latest_ready_revision` will have the state of the last serving revision, - // or empty for newly created Services. Additional information on the failure - // can be found in `terminal_condition` and `conditions`. - bool reconciling = 98 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto deleted file mode 100644 index 18a8c7d..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "TrafficTargetProto"; -option java_package = "com.google.cloud.run.v2"; - -// Holds a single traffic routing entry for the Service. Allocations can be done -// to a specific Revision name, or pointing to the latest Ready Revision. -message TrafficTarget { - // The allocation type for this traffic target. - TrafficTargetAllocationType type = 1; - - // Revision to which to send this portion of traffic, if traffic allocation is - // by revision. - string revision = 2 [(google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - }]; - - // Specifies percent of the traffic to this Revision. - // This defaults to zero if unspecified. - int32 percent = 3; - - // Indicates a string to be part of the URI to exclusively reference this - // target. - string tag = 4; -} - -// Represents the observed state of a single `TrafficTarget` entry. -message TrafficTargetStatus { - // The allocation type for this traffic target. - TrafficTargetAllocationType type = 1; - - // Revision to which this traffic is sent. - string revision = 2 [(google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - }]; - - // Specifies percent of the traffic to this Revision. - int32 percent = 3; - - // Indicates the string used in the URI to exclusively reference this target. - string tag = 4; - - // Displays the target URI. - string uri = 5; -} - -// The type of instance allocation. -enum TrafficTargetAllocationType { - // Unspecified instance allocation type. - TRAFFIC_TARGET_ALLOCATION_TYPE_UNSPECIFIED = 0; - - // Allocates instances to the Service's latest ready Revision. - TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST = 1; - - // Allocates instances to a Revision by name. - TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION = 2; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto deleted file mode 100644 index 89748d5..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "VendorSettingsProto"; -option java_package = "com.google.cloud.run.v2"; - -// VPC Access settings. For more information on creating a VPC Connector, visit -// https://cloud.google.com/vpc/docs/configure-serverless-vpc-access For -// information on how to configure Cloud Run with an existing VPC Connector, -// visit https://cloud.google.com/run/docs/configuring/connecting-vpc -message VpcAccess { - // Egress options for VPC access. - enum VpcEgress { - // Unspecified - VPC_EGRESS_UNSPECIFIED = 0; - - // All outbound traffic is routed through the VPC connector. - ALL_TRAFFIC = 1; - - // Only private IP ranges are routed through the VPC connector. - PRIVATE_RANGES_ONLY = 2; - } - - // VPC Access connector name. - // Format: projects/{project}/locations/{location}/connectors/{connector} - string connector = 1 [(google.api.resource_reference) = { - type: "vpcaccess.googleapis.com/Connector" - }]; - - // Traffic VPC egress settings. - VpcEgress egress = 2; -} - -// Settings for Binary Authorization feature. -message BinaryAuthorization { - oneof binauthz_method { - // If True, indicates to use the default project's binary authorization - // policy. If False, binary authorization will be disabled. - bool use_default = 1; - } - - // If present, indicates to use Breakglass using this justification. - // If use_default is False, then it must be empty. - // For more information on breakglass, see - // https://cloud.google.com/binary-authorization/docs/using-breakglass - string breakglass_justification = 2; -} - -// Settings for revision-level scaling settings. -message RevisionScaling { - // Minimum number of serving instances that this resource should have. - int32 min_instance_count = 1; - - // Maximum number of serving instances that this resource should have. - int32 max_instance_count = 2; -} - -// Allowed ingress traffic for the Container. -enum IngressTraffic { - // Unspecified - INGRESS_TRAFFIC_UNSPECIFIED = 0; - - // All inbound traffic is allowed. - INGRESS_TRAFFIC_ALL = 1; - - // Only internal traffic is allowed. - INGRESS_TRAFFIC_INTERNAL_ONLY = 2; - - // Both internal and Google Cloud Load Balancer traffic is allowed. - INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER = 3; -} - -// Alternatives for execution environments. -enum ExecutionEnvironment { - // Unspecified - EXECUTION_ENVIRONMENT_UNSPECIFIED = 0; - - // Uses the First Generation environment. - EXECUTION_ENVIRONMENT_GEN1 = 1; - - // Uses Second Generation environment. - EXECUTION_ENVIRONMENT_GEN2 = 2; -} diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js b/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js deleted file mode 100644 index ab6b399..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START run_v2_generated_Revisions_DeleteRevision_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the Revision to delete. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - */ - // const name = 'abc123' - /** - * Indicates that the request should be validated without actually - * deleting any resources. - */ - // const validateOnly = true - /** - * A system-generated fingerprint for this version of the - * resource. This may be used to detect modification conflict during updates. - */ - // const etag = 'abc123' - - // Imports the Run library - const {RevisionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new RevisionsClient(); - - async function callDeleteRevision() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await runClient.deleteRevision(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteRevision(); - // [END run_v2_generated_Revisions_DeleteRevision_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js b/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js deleted file mode 100644 index 0c67144..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START run_v2_generated_Revisions_GetRevision_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Revision. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - */ - // const name = 'abc123' - - // Imports the Run library - const {RevisionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new RevisionsClient(); - - async function callGetRevision() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await runClient.getRevision(request); - console.log(response); - } - - callGetRevision(); - // [END run_v2_generated_Revisions_GetRevision_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js b/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js deleted file mode 100644 index 2263cee..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START run_v2_generated_Revisions_ListRevisions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - */ - // const parent = 'abc123' - /** - * Maximum number of revisions to return in this call. - */ - // const pageSize = 1234 - /** - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - */ - // const pageToken = 'abc123' - /** - * If true, returns deleted (but unexpired) resources along with active ones. - */ - // const showDeleted = true - - // Imports the Run library - const {RevisionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new RevisionsClient(); - - async function callListRevisions() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await runClient.listRevisionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRevisions(); - // [END run_v2_generated_Revisions_ListRevisions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.create_service.js b/owl-bot-staging/v2/samples/generated/v2/services.create_service.js deleted file mode 100644 index 7524ecb..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.create_service.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, service, serviceId) { - // [START run_v2_generated_Services_CreateService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location and project in which this service should be created. - * Format: projects/{projectnumber}/locations/{location} - */ - // const parent = 'abc123' - /** - * Required. The Service instance to create. - */ - // const service = {} - /** - * Required. The unique identifier for the Service. The name of the service becomes - * {parent}/services/{service_id}. - */ - // const serviceId = 'abc123' - /** - * Indicates that the request should be validated and default values - * populated, without persisting the request or creating any resources. - */ - // const validateOnly = true - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callCreateService() { - // Construct request - const request = { - parent, - service, - serviceId, - }; - - // Run request - const [operation] = await runClient.createService(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateService(); - // [END run_v2_generated_Services_CreateService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js b/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js deleted file mode 100644 index bcf7ec4..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START run_v2_generated_Services_DeleteService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Service. - * Format: projects/{projectnumber}/locations/{location}/services/{service} - */ - // const name = 'abc123' - /** - * Indicates that the request should be validated without actually - * deleting any resources. - */ - // const validateOnly = true - /** - * A system-generated fingerprint for this version of the - * resource. May be used to detect modification conflict during updates. - */ - // const etag = 'abc123' - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callDeleteService() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await runClient.deleteService(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteService(); - // [END run_v2_generated_Services_DeleteService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js b/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js deleted file mode 100644 index 52329ca..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource) { - // [START run_v2_generated_Services_GetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await runClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END run_v2_generated_Services_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.get_service.js b/owl-bot-staging/v2/samples/generated/v2/services.get_service.js deleted file mode 100644 index ffd939c..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.get_service.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START run_v2_generated_Services_GetService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Service. - * Format: projects/{projectnumber}/locations/{location}/services/{service} - */ - // const name = 'abc123' - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callGetService() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await runClient.getService(request); - console.log(response); - } - - callGetService(); - // [END run_v2_generated_Services_GetService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.list_services.js b/owl-bot-staging/v2/samples/generated/v2/services.list_services.js deleted file mode 100644 index 3daad03..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.list_services.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START run_v2_generated_Services_ListServices_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location and project to list resources on. - * Location must be a valid GCP region, and may not be the "-" wildcard. - * Format: projects/{projectnumber}/locations/{location} - */ - // const parent = 'abc123' - /** - * Maximum number of Services to return in this call. - */ - // const pageSize = 1234 - /** - * A page token received from a previous call to ListServices. - * All other parameters must match. - */ - // const pageToken = 'abc123' - /** - * If true, returns deleted (but unexpired) resources along with active ones. - */ - // const showDeleted = true - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callListServices() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await runClient.listServicesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServices(); - // [END run_v2_generated_Services_ListServices_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js b/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js deleted file mode 100644 index f56b2bd..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource, policy) { - // [START run_v2_generated_Services_SetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await runClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END run_v2_generated_Services_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js b/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js deleted file mode 100644 index f7fbd42..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource, permissions) { - // [START run_v2_generated_Services_TestIamPermissions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = 'abc123' - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await runClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END run_v2_generated_Services_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.update_service.js b/owl-bot-staging/v2/samples/generated/v2/services.update_service.js deleted file mode 100644 index a280ace..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.update_service.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(service) { - // [START run_v2_generated_Services_UpdateService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Service to be updated. - */ - // const service = {} - /** - * Indicates that the request should be validated and default values - * populated, without persisting the request or updating any resources. - */ - // const validateOnly = true - /** - * If set to true, and if the Service does not exist, it will create a new - * one. Caller must have both create and update permissions for this call if - * this is set to true. - */ - // const allowMissing = true - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callUpdateService() { - // Construct request - const request = { - service, - }; - - // Run request - const [operation] = await runClient.updateService(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateService(); - // [END run_v2_generated_Services_UpdateService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json deleted file mode 100644 index 82e2baf..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json +++ /dev/null @@ -1,531 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-run", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.run.v2", - "version": "v2" - } - ] - }, - "snippets": [ - { - "regionTag": "run_v2_generated_Revisions_GetRevision_async", - "title": "Revisions getRevision Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a Revision.", - "canonical": true, - "file": "revisions.get_revision.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetRevision", - "fullName": "google.cloud.run.v2.Revisions.GetRevision", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.run.v2.Revision", - "client": { - "shortName": "RevisionsClient", - "fullName": "google.cloud.run.v2.RevisionsClient" - }, - "method": { - "shortName": "GetRevision", - "fullName": "google.cloud.run.v2.Revisions.GetRevision", - "service": { - "shortName": "Revisions", - "fullName": "google.cloud.run.v2.Revisions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Revisions_ListRevisions_async", - "title": "Revisions listRevisions Sample", - "origin": "API_DEFINITION", - "description": " List Revisions from a given Service, or from a given location.", - "canonical": true, - "file": "revisions.list_revisions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListRevisions", - "fullName": "google.cloud.run.v2.Revisions.ListRevisions", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.run.v2.ListRevisionsResponse", - "client": { - "shortName": "RevisionsClient", - "fullName": "google.cloud.run.v2.RevisionsClient" - }, - "method": { - "shortName": "ListRevisions", - "fullName": "google.cloud.run.v2.Revisions.ListRevisions", - "service": { - "shortName": "Revisions", - "fullName": "google.cloud.run.v2.Revisions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Revisions_DeleteRevision_async", - "title": "Revisions deleteRevision Sample", - "origin": "API_DEFINITION", - "description": " Delete a Revision.", - "canonical": true, - "file": "revisions.delete_revision.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteRevision", - "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "RevisionsClient", - "fullName": "google.cloud.run.v2.RevisionsClient" - }, - "method": { - "shortName": "DeleteRevision", - "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", - "service": { - "shortName": "Revisions", - "fullName": "google.cloud.run.v2.Revisions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_CreateService_async", - "title": "Revisions createService Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Service in a given project and location.", - "canonical": true, - "file": "services.create_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateService", - "fullName": "google.cloud.run.v2.Services.CreateService", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "service", - "type": ".google.cloud.run.v2.Service" - }, - { - "name": "service_id", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "CreateService", - "fullName": "google.cloud.run.v2.Services.CreateService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_GetService_async", - "title": "Revisions getService Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a Service.", - "canonical": true, - "file": "services.get_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetService", - "fullName": "google.cloud.run.v2.Services.GetService", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.run.v2.Service", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "GetService", - "fullName": "google.cloud.run.v2.Services.GetService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_ListServices_async", - "title": "Revisions listServices Sample", - "origin": "API_DEFINITION", - "description": " List Services.", - "canonical": true, - "file": "services.list_services.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServices", - "fullName": "google.cloud.run.v2.Services.ListServices", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.run.v2.ListServicesResponse", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "ListServices", - "fullName": "google.cloud.run.v2.Services.ListServices", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_UpdateService_async", - "title": "Revisions updateService Sample", - "origin": "API_DEFINITION", - "description": " Updates a Service.", - "canonical": true, - "file": "services.update_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateService", - "fullName": "google.cloud.run.v2.Services.UpdateService", - "async": true, - "parameters": [ - { - "name": "service", - "type": ".google.cloud.run.v2.Service" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "UpdateService", - "fullName": "google.cloud.run.v2.Services.UpdateService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_DeleteService_async", - "title": "Revisions deleteService Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Service. This will cause the Service to stop serving traffic and will delete all revisions.", - "canonical": true, - "file": "services.delete_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteService", - "fullName": "google.cloud.run.v2.Services.DeleteService", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "DeleteService", - "fullName": "google.cloud.run.v2.Services.DeleteService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_GetIamPolicy_async", - "title": "Revisions getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Get the IAM Access Control policy currently in effect for the given Cloud Run Service. This result does not include any inherited policies.", - "canonical": true, - "file": "services.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.run.v2.Services.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.run.v2.Services.GetIamPolicy", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_SetIamPolicy_async", - "title": "Revisions setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the IAM Access control policy for the specified Service. Overwrites any existing policy.", - "canonical": true, - "file": "services.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.run.v2.Services.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.run.v2.Services.SetIamPolicy", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_TestIamPermissions_async", - "title": "Revisions testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified Project. There are no permissions required for making this API call.", - "canonical": true, - "file": "services.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.run.v2.Services.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.run.v2.Services.TestIamPermissions", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v2/src/index.ts b/owl-bot-staging/v2/src/index.ts deleted file mode 100644 index f7f6340..0000000 --- a/owl-bot-staging/v2/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v2 from './v2'; -const RevisionsClient = v2.RevisionsClient; -type RevisionsClient = v2.RevisionsClient; -const ServicesClient = v2.ServicesClient; -type ServicesClient = v2.ServicesClient; -export {v2, RevisionsClient, ServicesClient}; -export default {v2, RevisionsClient, ServicesClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v2/src/v2/gapic_metadata.json b/owl-bot-staging/v2/src/v2/gapic_metadata.json deleted file mode 100644 index 5990e13..0000000 --- a/owl-bot-staging/v2/src/v2/gapic_metadata.json +++ /dev/null @@ -1,155 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.run.v2", - "libraryPackage": "@google-cloud/run", - "services": { - "Revisions": { - "clients": { - "grpc": { - "libraryClient": "RevisionsClient", - "rpcs": { - "GetRevision": { - "methods": [ - "getRevision" - ] - }, - "DeleteRevision": { - "methods": [ - "deleteRevision" - ] - }, - "ListRevisions": { - "methods": [ - "listRevisions", - "listRevisionsStream", - "listRevisionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RevisionsClient", - "rpcs": { - "GetRevision": { - "methods": [ - "getRevision" - ] - }, - "DeleteRevision": { - "methods": [ - "deleteRevision" - ] - }, - "ListRevisions": { - "methods": [ - "listRevisions", - "listRevisionsStream", - "listRevisionsAsync" - ] - } - } - } - } - }, - "Services": { - "clients": { - "grpc": { - "libraryClient": "ServicesClient", - "rpcs": { - "GetService": { - "methods": [ - "getService" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateService": { - "methods": [ - "createService" - ] - }, - "UpdateService": { - "methods": [ - "updateService" - ] - }, - "DeleteService": { - "methods": [ - "deleteService" - ] - }, - "ListServices": { - "methods": [ - "listServices", - "listServicesStream", - "listServicesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ServicesClient", - "rpcs": { - "GetService": { - "methods": [ - "getService" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateService": { - "methods": [ - "createService" - ] - }, - "UpdateService": { - "methods": [ - "updateService" - ] - }, - "DeleteService": { - "methods": [ - "deleteService" - ] - }, - "ListServices": { - "methods": [ - "listServices", - "listServicesStream", - "listServicesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/index.ts b/owl-bot-staging/v2/src/v2/index.ts deleted file mode 100644 index 5ea97dc..0000000 --- a/owl-bot-staging/v2/src/v2/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {RevisionsClient} from './revisions_client'; -export {ServicesClient} from './services_client'; diff --git a/owl-bot-staging/v2/src/v2/revisions_client.ts b/owl-bot-staging/v2/src/v2/revisions_client.ts deleted file mode 100644 index ecc51b3..0000000 --- a/owl-bot-staging/v2/src/v2/revisions_client.ts +++ /dev/null @@ -1,1016 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/revisions_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './revisions_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Run Revision Control Plane API. - * @class - * @memberof v2 - */ -export class RevisionsClient { - 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}; - operationsClient: gax.OperationsClient; - revisionsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RevisionsClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new RevisionsClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RevisionsClient; - 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; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // 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 = { - cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - revisionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' - ), - }; - - // 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 = { - listRevisions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'revisions') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const deleteRevisionResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Revision') as gax.protobuf.Type; - const deleteRevisionMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Revision') as gax.protobuf.Type; - - this.descriptors.longrunning = { - deleteRevision: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteRevisionResponse.decode.bind(deleteRevisionResponse), - deleteRevisionMetadata.decode.bind(deleteRevisionMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.run.v2.Revisions', 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 = this._gaxModule.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.revisionsStub) { - return this.revisionsStub; - } - - // Put together the "service stub" for - // google.cloud.run.v2.Revisions. - this.revisionsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Revisions') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.run.v2.Revisions, - 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 revisionsStubMethods = - ['getRevision', 'listRevisions', 'deleteRevision']; - for (const methodName of revisionsStubMethods) { - const callPromise = this.revisionsStub.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] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.revisionsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'run.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 'run.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets information about a Revision. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Revision. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - * @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 [Revision]{@link google.cloud.run.v2.Revision}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/revisions.get_revision.js - * region_tag:run_v2_generated_Revisions_GetRevision_async - */ - getRevision( - request?: protos.google.cloud.run.v2.IGetRevisionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|undefined, {}|undefined - ]>; - getRevision( - request: protos.google.cloud.run.v2.IGetRevisionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>): void; - getRevision( - request: protos.google.cloud.run.v2.IGetRevisionRequest, - callback: Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>): void; - getRevision( - request?: protos.google.cloud.run.v2.IGetRevisionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.getRevision(request, options, callback); - } - -/** - * Delete a Revision. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Revision to delete. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - * @param {boolean} request.validateOnly - * Indicates that the request should be validated without actually - * deleting any resources. - * @param {string} request.etag - * A system-generated fingerprint for this version of the - * resource. This may be used to detect modification conflict during updates. - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/revisions.delete_revision.js - * region_tag:run_v2_generated_Revisions_DeleteRevision_async - */ - deleteRevision( - request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteRevision( - request: protos.google.cloud.run.v2.IDeleteRevisionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteRevision( - request: protos.google.cloud.run.v2.IDeleteRevisionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteRevision( - request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.deleteRevision(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteRevision()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/revisions.delete_revision.js - * region_tag:run_v2_generated_Revisions_DeleteRevision_async - */ - async checkDeleteRevisionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteRevision, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * List Revisions from a given Service, or from a given location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - * @param {number} request.pageSize - * Maximum number of revisions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 [Revision]{@link google.cloud.run.v2.Revision}. - * 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 `listRevisionsAsync()` - * 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. - */ - listRevisions( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IRevision[], - protos.google.cloud.run.v2.IListRevisionsRequest|null, - protos.google.cloud.run.v2.IListRevisionsResponse - ]>; - listRevisions( - request: protos.google.cloud.run.v2.IListRevisionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>): void; - listRevisions( - request: protos.google.cloud.run.v2.IListRevisionsRequest, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>): void; - listRevisions( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>, - callback?: PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>): - Promise<[ - protos.google.cloud.run.v2.IRevision[], - protos.google.cloud.run.v2.IListRevisionsRequest|null, - protos.google.cloud.run.v2.IListRevisionsResponse - ]>|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.listRevisions(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 Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - * @param {number} request.pageSize - * Maximum number of revisions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 [Revision]{@link google.cloud.run.v2.Revision} 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 `listRevisionsAsync()` - * 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. - */ - listRevisionsStream( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listRevisions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRevisions.createStream( - this.innerApiCalls.listRevisions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRevisions`, 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 Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - * @param {number} request.pageSize - * Maximum number of revisions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 - * [Revision]{@link google.cloud.run.v2.Revision}. 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 include:samples/generated/v2/revisions.list_revisions.js - * region_tag:run_v2_generated_Revisions_ListRevisions_async - */ - listRevisionsAsync( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listRevisions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRevisions.asyncIterate( - this.innerApiCalls['listRevisions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified cryptoKey resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} key_ring - * @param {string} crypto_key - * @returns {string} Resource name string. - */ - cryptoKeyPath(project:string,location:string,keyRing:string,cryptoKey:string) { - return this.pathTemplates.cryptoKeyPathTemplate.render({ - project: project, - location: location, - key_ring: keyRing, - crypto_key: cryptoKey, - }); - } - - /** - * Parse the project from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; - } - - /** - * Parse the location from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; - } - - /** - * Parse the key_ring from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the key_ring. - */ - matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).key_ring; - } - - /** - * Parse the crypto_key from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the crypto_key. - */ - matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).crypto_key; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).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 revision resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @param {string} revision - * @returns {string} Resource name string. - */ - revisionPath(project:string,location:string,service:string,revision:string) { - return this.pathTemplates.revisionPathTemplate.render({ - project: project, - location: location, - service: service, - revision: revision, - }); - } - - /** - * Parse the project from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).project; - } - - /** - * Parse the location from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).location; - } - - /** - * Parse the service from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the service. - */ - matchServiceFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).service; - } - - /** - * Parse the revision from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the revision. - */ - matchRevisionFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(project:string,location:string,service:string) { - return this.pathTemplates.servicePathTemplate.render({ - project: project, - location: location, - service: service, - }); - } - - /** - * Parse the project from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).project; - } - - /** - * Parse the location from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).location; - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.revisionsStub && !this._terminated) { - return this.revisionsStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/revisions_client_config.json b/owl-bot-staging/v2/src/v2/revisions_client_config.json deleted file mode 100644 index f5a18a2..0000000 --- a/owl-bot-staging/v2/src/v2/revisions_client_config.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "interfaces": { - "google.cloud.run.v2.Revisions": { - "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": { - "GetRevision": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRevisions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteRevision": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/revisions_proto_list.json b/owl-bot-staging/v2/src/v2/revisions_proto_list.json deleted file mode 100644 index 455cae6..0000000 --- a/owl-bot-staging/v2/src/v2/revisions_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/run/v2/condition.proto", - "../../protos/google/cloud/run/v2/k8s.min.proto", - "../../protos/google/cloud/run/v2/revision.proto", - "../../protos/google/cloud/run/v2/revision_template.proto", - "../../protos/google/cloud/run/v2/service.proto", - "../../protos/google/cloud/run/v2/traffic_target.proto", - "../../protos/google/cloud/run/v2/vendor_settings.proto" -] diff --git a/owl-bot-staging/v2/src/v2/services_client.ts b/owl-bot-staging/v2/src/v2/services_client.ts deleted file mode 100644 index 228aaf7..0000000 --- a/owl-bot-staging/v2/src/v2/services_client.ts +++ /dev/null @@ -1,1423 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/services_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './services_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Run Service Control Plane API - * @class - * @memberof v2 - */ -export class ServicesClient { - 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}; - operationsClient: gax.OperationsClient; - servicesStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ServicesClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ServicesClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ServicesClient; - 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; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // 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 = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - revisionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' - ), - }; - - // 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 = { - listServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createServiceResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const createServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const updateServiceResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const updateServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const deleteServiceResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const deleteServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createService: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createServiceResponse.decode.bind(createServiceResponse), - createServiceMetadata.decode.bind(createServiceMetadata)), - updateService: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateServiceResponse.decode.bind(updateServiceResponse), - updateServiceMetadata.decode.bind(updateServiceMetadata)), - deleteService: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteServiceResponse.decode.bind(deleteServiceResponse), - deleteServiceMetadata.decode.bind(deleteServiceMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.run.v2.Services', 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 = this._gaxModule.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.servicesStub) { - return this.servicesStub; - } - - // Put together the "service stub" for - // google.cloud.run.v2.Services. - this.servicesStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Services') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.run.v2.Services, - 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 servicesStubMethods = - ['createService', 'getService', 'listServices', 'updateService', 'deleteService', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of servicesStubMethods) { - const callPromise = this.servicesStub.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] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.servicesStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'run.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 'run.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets information about a Service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Service. - * Format: projects/{projectnumber}/locations/{location}/services/{service} - * @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 [Service]{@link google.cloud.run.v2.Service}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/services.get_service.js - * region_tag:run_v2_generated_Services_GetService_async - */ - getService( - request?: protos.google.cloud.run.v2.IGetServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|undefined, {}|undefined - ]>; - getService( - request: protos.google.cloud.run.v2.IGetServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; - getService( - request: protos.google.cloud.run.v2.IGetServiceRequest, - callback: Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; - getService( - request?: protos.google.cloud.run.v2.IGetServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.getService(request, options, callback); - } -/** - * Get the IAM Access Control policy currently in effect for the given - * Cloud Run Service. This result does not include any inherited policies. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/services.get_iam_policy.js - * region_tag:run_v2_generated_Services_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the IAM Access control policy for the specified Service. Overwrites - * any existing policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/services.set_iam_policy.js - * region_tag:run_v2_generated_Services_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified Project. - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/services.test_iam_permissions.js - * region_tag:run_v2_generated_Services_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Creates a new Service in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project in which this service should be created. - * Format: projects/{projectnumber}/locations/{location} - * @param {google.cloud.run.v2.Service} request.service - * Required. The Service instance to create. - * @param {string} request.serviceId - * Required. The unique identifier for the Service. The name of the service becomes - * {parent}/services/{service_id}. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated and default values - * populated, without persisting the request or creating any resources. - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.create_service.js - * region_tag:run_v2_generated_Services_CreateService_async - */ - createService( - request?: protos.google.cloud.run.v2.ICreateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createService( - request: protos.google.cloud.run.v2.ICreateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createService( - request: protos.google.cloud.run.v2.ICreateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createService( - request?: protos.google.cloud.run.v2.ICreateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.createService(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createService()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.create_service.js - * region_tag:run_v2_generated_Services_CreateService_async - */ - async checkCreateServiceProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a Service. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.run.v2.Service} request.service - * Required. The Service to be updated. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated and default values - * populated, without persisting the request or updating any resources. - * @param {boolean} request.allowMissing - * If set to true, and if the Service does not exist, it will create a new - * one. Caller must have both create and update permissions for this call if - * this is set to true. - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.update_service.js - * region_tag:run_v2_generated_Services_UpdateService_async - */ - updateService( - request?: protos.google.cloud.run.v2.IUpdateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateService( - request: protos.google.cloud.run.v2.IUpdateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateService( - request: protos.google.cloud.run.v2.IUpdateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateService( - request?: protos.google.cloud.run.v2.IUpdateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.service?.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.updateService(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateService()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.update_service.js - * region_tag:run_v2_generated_Services_UpdateService_async - */ - async checkUpdateServiceProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a Service. - * This will cause the Service to stop serving traffic and will delete all - * revisions. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Service. - * Format: projects/{projectnumber}/locations/{location}/services/{service} - * @param {boolean} request.validateOnly - * Indicates that the request should be validated without actually - * deleting any resources. - * @param {string} request.etag - * A system-generated fingerprint for this version of the - * resource. May be used to detect modification conflict during updates. - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.delete_service.js - * region_tag:run_v2_generated_Services_DeleteService_async - */ - deleteService( - request?: protos.google.cloud.run.v2.IDeleteServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteService( - request: protos.google.cloud.run.v2.IDeleteServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteService( - request: protos.google.cloud.run.v2.IDeleteServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteService( - request?: protos.google.cloud.run.v2.IDeleteServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.deleteService(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteService()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.delete_service.js - * region_tag:run_v2_generated_Services_DeleteService_async - */ - async checkDeleteServiceProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * List Services. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project to list resources on. - * Location must be a valid GCP region, and may not be the "-" wildcard. - * Format: projects/{projectnumber}/locations/{location} - * @param {number} request.pageSize - * Maximum number of Services to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListServices. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 [Service]{@link google.cloud.run.v2.Service}. - * 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 `listServicesAsync()` - * 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. - */ - listServices( - request?: protos.google.cloud.run.v2.IListServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IService[], - protos.google.cloud.run.v2.IListServicesRequest|null, - protos.google.cloud.run.v2.IListServicesResponse - ]>; - listServices( - request: protos.google.cloud.run.v2.IListServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>): void; - listServices( - request: protos.google.cloud.run.v2.IListServicesRequest, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>): void; - listServices( - request?: protos.google.cloud.run.v2.IListServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>, - callback?: PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>): - Promise<[ - protos.google.cloud.run.v2.IService[], - protos.google.cloud.run.v2.IListServicesRequest|null, - protos.google.cloud.run.v2.IListServicesResponse - ]>|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.listServices(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 location and project to list resources on. - * Location must be a valid GCP region, and may not be the "-" wildcard. - * Format: projects/{projectnumber}/locations/{location} - * @param {number} request.pageSize - * Maximum number of Services to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListServices. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 [Service]{@link google.cloud.run.v2.Service} 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 `listServicesAsync()` - * 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. - */ - listServicesStream( - request?: protos.google.cloud.run.v2.IListServicesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listServices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServices.createStream( - this.innerApiCalls.listServices as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServices`, 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 location and project to list resources on. - * Location must be a valid GCP region, and may not be the "-" wildcard. - * Format: projects/{projectnumber}/locations/{location} - * @param {number} request.pageSize - * Maximum number of Services to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListServices. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 - * [Service]{@link google.cloud.run.v2.Service}. 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 include:samples/generated/v2/services.list_services.js - * region_tag:run_v2_generated_Services_ListServices_async - */ - listServicesAsync( - request?: protos.google.cloud.run.v2.IListServicesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listServices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServices.asyncIterate( - this.innerApiCalls['listServices'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).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 revision resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @param {string} revision - * @returns {string} Resource name string. - */ - revisionPath(project:string,location:string,service:string,revision:string) { - return this.pathTemplates.revisionPathTemplate.render({ - project: project, - location: location, - service: service, - revision: revision, - }); - } - - /** - * Parse the project from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).project; - } - - /** - * Parse the location from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).location; - } - - /** - * Parse the service from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the service. - */ - matchServiceFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).service; - } - - /** - * Parse the revision from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the revision. - */ - matchRevisionFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(project:string,location:string,service:string) { - return this.pathTemplates.servicePathTemplate.render({ - project: project, - location: location, - service: service, - }); - } - - /** - * Parse the project from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).project; - } - - /** - * Parse the location from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).location; - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.servicesStub && !this._terminated) { - return this.servicesStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/services_client_config.json b/owl-bot-staging/v2/src/v2/services_client_config.json deleted file mode 100644 index d9a3364..0000000 --- a/owl-bot-staging/v2/src/v2/services_client_config.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "interfaces": { - "google.cloud.run.v2.Services": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateService": { - "timeout_millis": 15000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetService": { - "timeout_millis": 10000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListServices": { - "timeout_millis": 10000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateService": { - "timeout_millis": 15000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteService": { - "timeout_millis": 10000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/services_proto_list.json b/owl-bot-staging/v2/src/v2/services_proto_list.json deleted file mode 100644 index 455cae6..0000000 --- a/owl-bot-staging/v2/src/v2/services_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/run/v2/condition.proto", - "../../protos/google/cloud/run/v2/k8s.min.proto", - "../../protos/google/cloud/run/v2/revision.proto", - "../../protos/google/cloud/run/v2/revision_template.proto", - "../../protos/google/cloud/run/v2/service.proto", - "../../protos/google/cloud/run/v2/traffic_target.proto", - "../../protos/google/cloud/run/v2/vendor_settings.proto" -] diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 01b536f..0000000 --- a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const run = require('@google-cloud/run'); - -function main() { - const revisionsClient = new run.RevisionsClient(); - const servicesClient = new run.ServicesClient(); -} - -main(); diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 769c1b4..0000000 --- a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {RevisionsClient, ServicesClient} from '@google-cloud/run'; - -// check that the client class type name can be used -function doStuffWithRevisionsClient(client: RevisionsClient) { - client.close(); -} -function doStuffWithServicesClient(client: ServicesClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const revisionsClient = new RevisionsClient(); - doStuffWithRevisionsClient(revisionsClient); - // check that the client instance can be created - const servicesClient = new ServicesClient(); - doStuffWithServicesClient(servicesClient); -} - -main(); diff --git a/owl-bot-staging/v2/system-test/install.ts b/owl-bot-staging/v2/system-test/install.ts deleted file mode 100644 index 557a575..0000000 --- a/owl-bot-staging/v2/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v2/test/gapic_revisions_v2.ts b/owl-bot-staging/v2/test/gapic_revisions_v2.ts deleted file mode 100644 index 4b4fb53..0000000 --- a/owl-bot-staging/v2/test/gapic_revisions_v2.ts +++ /dev/null @@ -1,932 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as revisionsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -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('v2.RevisionsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = revisionsModule.v2.RevisionsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = revisionsModule.v2.RevisionsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = revisionsModule.v2.RevisionsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new revisionsModule.v2.RevisionsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new revisionsModule.v2.RevisionsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.revisionsStub, undefined); - await client.initialize(); - assert(client.revisionsStub); - }); - - it('has close method for the initialized client', done => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.revisionsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.revisionsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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('getRevision', () => { - it('invokes getRevision without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Revision()); - client.innerApiCalls.getRevision = stubSimpleCall(expectedResponse); - const [response] = await client.getRevision(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getRevision without error using callback', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Revision()); - client.innerApiCalls.getRevision = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRevision( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getRevision with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getRevision = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRevision(request), expectedError); - assert((client.innerApiCalls.getRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getRevision with closed client', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getRevision(request), expectedError); - }); - }); - - describe('deleteRevision', () => { - it('invokes deleteRevision without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteRevision = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteRevision(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteRevision without error using callback', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteRevision = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteRevision( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteRevision with call error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteRevision(request), expectedError); - assert((client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteRevision with LRO error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteRevision(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteRevisionProgress without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteRevisionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteRevisionProgress with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteRevisionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listRevisions', () => { - it('invokes listRevisions without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.innerApiCalls.listRevisions = stubSimpleCall(expectedResponse); - const [response] = await client.listRevisions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listRevisions without error using callback', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.innerApiCalls.listRevisions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRevisions( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listRevisions with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listRevisions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRevisions(request), expectedError); - assert((client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listRevisionsStream without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRevisionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Revision[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { - 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.listRevisions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); - assert.strictEqual( - (client.descriptors.page.listRevisions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listRevisionsStream with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedError = new Error('expected'); - client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRevisionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Revision[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRevisions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); - assert.strictEqual( - (client.descriptors.page.listRevisions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listRevisions without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.run.v2.IRevision[] = []; - const iterable = client.listRevisionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listRevisions with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&');const expectedError = new Error('expected'); - client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRevisionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.run.v2.IRevision[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('cryptoKey', () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.cryptoKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.cryptoKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('cryptoKeyPath', () => { - const result = client.cryptoKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCryptoKeyName', () => { - const result = client.matchProjectFromCryptoKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCryptoKeyName', () => { - const result = client.matchLocationFromCryptoKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromCryptoKeyName', () => { - const result = client.matchKeyRingFromCryptoKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromCryptoKeyName', () => { - const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - 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('revision', () => { - const fakePath = "/rendered/path/revision"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - revision: "revisionValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.revisionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.revisionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('revisionPath', () => { - const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRevisionName', () => { - const result = client.matchProjectFromRevisionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRevisionName', () => { - const result = client.matchLocationFromRevisionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromRevisionName', () => { - const result = client.matchServiceFromRevisionName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRevisionFromRevisionName', () => { - const result = client.matchRevisionFromRevisionName(fakePath); - assert.strictEqual(result, "revisionValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_services_v2.ts b/owl-bot-staging/v2/test/gapic_services_v2.ts deleted file mode 100644 index 3ec3f34..0000000 --- a/owl-bot-staging/v2/test/gapic_services_v2.ts +++ /dev/null @@ -1,1485 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as servicesModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -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('v2.ServicesClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = servicesModule.v2.ServicesClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = servicesModule.v2.ServicesClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = servicesModule.v2.ServicesClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new servicesModule.v2.ServicesClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new servicesModule.v2.ServicesClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servicesStub, undefined); - await client.initialize(); - assert(client.servicesStub); - }); - - it('has close method for the initialized client', done => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.servicesStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servicesStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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('getService', () => { - it('invokes getService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Service()); - client.innerApiCalls.getService = stubSimpleCall(expectedResponse); - const [response] = await client.getService(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Service()); - client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getService( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getService as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getService with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getService = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getService(request), expectedError); - assert((client.innerApiCalls.getService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getService with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getService(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createService', () => { - it('invokes createService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createService = stubLongRunningCall(expectedResponse); - const [operation] = await client.createService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createService as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createService with call error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createService(request), expectedError); - assert((client.innerApiCalls.createService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createService with LRO error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createService(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateServiceProgress without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateServiceProgress with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateService', () => { - it('invokes updateService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateService = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateService as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateService with call error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateService(request), expectedError); - assert((client.innerApiCalls.updateService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateService with LRO error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateService(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateServiceProgress without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateServiceProgress with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteService', () => { - it('invokes deleteService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteService = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteService as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteService with call error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteService(request), expectedError); - assert((client.innerApiCalls.deleteService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteService with LRO error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteService(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteServiceProgress without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteServiceProgress with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listServices', () => { - it('invokes listServices without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); - const [response] = await client.listServices(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServices as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServices without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServices( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IService[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServices as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listServices with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServices(request), expectedError); - assert((client.innerApiCalls.listServices as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServicesStream without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Service[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Service) => { - 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.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert.strictEqual( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listServicesStream with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedError = new Error('expected'); - client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Service[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert.strictEqual( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServices without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.run.v2.IService[] = []; - const iterable = client.listServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServices with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&');const expectedError = new Error('expected'); - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.run.v2.IService[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new servicesModule.v2.ServicesClient({ - 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('revision', () => { - const fakePath = "/rendered/path/revision"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - revision: "revisionValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.revisionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.revisionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('revisionPath', () => { - const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRevisionName', () => { - const result = client.matchProjectFromRevisionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRevisionName', () => { - const result = client.matchLocationFromRevisionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromRevisionName', () => { - const result = client.matchServiceFromRevisionName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRevisionFromRevisionName', () => { - const result = client.matchRevisionFromRevisionName(fakePath); - assert.strictEqual(result, "revisionValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/tsconfig.json b/owl-bot-staging/v2/tsconfig.json deleted file mode 100644 index c78f1c8..0000000 --- a/owl-bot-staging/v2/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v2/webpack.config.js b/owl-bot-staging/v2/webpack.config.js deleted file mode 100644 index 36eeb4b..0000000 --- a/owl-bot-staging/v2/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Revisions', - filename: './revisions.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/src/v2/revisions_client.ts b/src/v2/revisions_client.ts index f966d0a..5da0b46 100644 --- a/src/v2/revisions_client.ts +++ b/src/v2/revisions_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -28,7 +28,6 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); @@ -38,7 +37,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './revisions_client_config.json'; -import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -99,8 +97,18 @@ export class RevisionsClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RevisionsClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof RevisionsClient; const servicePath = @@ -120,8 +128,13 @@ export class RevisionsClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -250,7 +263,7 @@ export class RevisionsClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -467,7 +480,7 @@ export class RevisionsClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.getRevision(request, options, callback); } @@ -590,7 +603,7 @@ export class RevisionsClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.deleteRevision(request, options, callback); } @@ -614,11 +627,12 @@ export class RevisionsClient { protos.google.cloud.run.v2.Revision > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.deleteRevision, this._gaxModule.createDefaultBackoffSettings() @@ -731,7 +745,7 @@ export class RevisionsClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.listRevisions(request, options, callback); } @@ -786,7 +800,7 @@ export class RevisionsClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); const defaultCallSettings = this._defaults['listRevisions']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -850,7 +864,7 @@ export class RevisionsClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); const defaultCallSettings = this._defaults['listRevisions']; const callSettings = defaultCallSettings.merge(options); this.initialize(); diff --git a/src/v2/services_client.ts b/src/v2/services_client.ts index 7522e55..7613358 100644 --- a/src/v2/services_client.ts +++ b/src/v2/services_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -28,7 +28,6 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); @@ -38,7 +37,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './services_client_config.json'; -import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -99,8 +97,18 @@ export class ServicesClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ServicesClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ServicesClient; const servicePath = @@ -120,8 +128,13 @@ export class ServicesClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -269,7 +282,7 @@ export class ServicesClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -490,7 +503,7 @@ export class ServicesClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.getService(request, options, callback); } @@ -576,7 +589,7 @@ export class ServicesClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ resource: request.resource || '', }); this.initialize(); @@ -672,7 +685,7 @@ export class ServicesClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ resource: request.resource || '', }); this.initialize(); @@ -763,7 +776,7 @@ export class ServicesClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ resource: request.resource || '', }); this.initialize(); @@ -889,7 +902,7 @@ export class ServicesClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.createService(request, options, callback); } @@ -913,11 +926,12 @@ export class ServicesClient { protos.google.cloud.run.v2.Service > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.createService, this._gaxModule.createDefaultBackoffSettings() @@ -1044,7 +1058,7 @@ export class ServicesClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.updateService(request, options, callback); } @@ -1068,11 +1082,12 @@ export class ServicesClient { protos.google.cloud.run.v2.Service > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.updateService, this._gaxModule.createDefaultBackoffSettings() @@ -1201,7 +1216,7 @@ export class ServicesClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.deleteService(request, options, callback); } @@ -1225,11 +1240,12 @@ export class ServicesClient { protos.google.cloud.run.v2.Service > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.deleteService, this._gaxModule.createDefaultBackoffSettings() @@ -1341,7 +1357,7 @@ export class ServicesClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.listServices(request, options, callback); } @@ -1395,7 +1411,7 @@ export class ServicesClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); const defaultCallSettings = this._defaults['listServices']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -1458,7 +1474,7 @@ export class ServicesClient { } } options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams(routingParameter); + this._gaxModule.routingHeader.fromParams(routingParameter); const defaultCallSettings = this._defaults['listServices']; const callSettings = defaultCallSettings.merge(options); this.initialize(); From 488b0491eeac810150657e9525c121d64f888db5 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 30 Aug 2022 09:03:33 +0000 Subject: [PATCH 3/4] fix: use _gaxModule when accessing gax for bundling PiperOrigin-RevId: 470911839 Source-Link: https://github.com/googleapis/googleapis/commit/352756699ebc5b2144c252867c265ea44448712e Source-Link: https://github.com/googleapis/googleapis-gen/commit/f16a1d224f00a630ea43d6a9a1a31f566f45cdea Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjE2YTFkMjI0ZjAwYTYzMGVhNDNkNmE5YTFhMzFmNTY2ZjQ1Y2RlYSJ9 --- owl-bot-staging/v2/.eslintignore | 7 + owl-bot-staging/v2/.eslintrc.json | 3 + owl-bot-staging/v2/.gitignore | 14 + owl-bot-staging/v2/.jsdoc.js | 55 + owl-bot-staging/v2/.mocharc.js | 33 + owl-bot-staging/v2/.prettierrc.js | 22 + owl-bot-staging/v2/README.md | 1 + owl-bot-staging/v2/linkinator.config.json | 16 + owl-bot-staging/v2/package.json | 65 + .../google/cloud/run/v2/condition.proto | 199 +++ .../protos/google/cloud/run/v2/k8s.min.proto | 274 +++ .../protos/google/cloud/run/v2/revision.proto | 278 +++ .../cloud/run/v2/revision_template.proto | 79 + .../protos/google/cloud/run/v2/service.proto | 435 +++++ .../google/cloud/run/v2/traffic_target.proto | 77 + .../google/cloud/run/v2/vendor_settings.proto | 102 ++ .../generated/v2/revisions.delete_revision.js | 74 + .../generated/v2/revisions.get_revision.js | 63 + .../generated/v2/revisions.list_revisions.js | 79 + .../generated/v2/services.create_service.js | 79 + .../generated/v2/services.delete_service.js | 73 + .../generated/v2/services.get_iam_policy.js | 67 + .../generated/v2/services.get_service.js | 62 + .../generated/v2/services.list_services.js | 78 + .../generated/v2/services.set_iam_policy.js | 77 + .../v2/services.test_iam_permissions.js | 70 + .../generated/v2/services.update_service.js | 73 + .../snippet_metadata.google.cloud.run.v2.json | 531 ++++++ owl-bot-staging/v2/src/index.ts | 27 + owl-bot-staging/v2/src/v2/gapic_metadata.json | 155 ++ owl-bot-staging/v2/src/v2/index.ts | 20 + owl-bot-staging/v2/src/v2/revisions_client.ts | 1016 +++++++++++ .../v2/src/v2/revisions_client_config.json | 38 + .../v2/src/v2/revisions_proto_list.json | 9 + owl-bot-staging/v2/src/v2/services_client.ts | 1423 ++++++++++++++++ .../v2/src/v2/services_client_config.json | 75 + .../v2/src/v2/services_proto_list.json | 9 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + owl-bot-staging/v2/system-test/install.ts | 49 + owl-bot-staging/v2/test/gapic_revisions_v2.ts | 932 +++++++++++ owl-bot-staging/v2/test/gapic_services_v2.ts | 1485 +++++++++++++++++ owl-bot-staging/v2/tsconfig.json | 19 + owl-bot-staging/v2/webpack.config.js | 64 + 44 files changed, 8373 insertions(+) create mode 100644 owl-bot-staging/v2/.eslintignore create mode 100644 owl-bot-staging/v2/.eslintrc.json create mode 100644 owl-bot-staging/v2/.gitignore create mode 100644 owl-bot-staging/v2/.jsdoc.js create mode 100644 owl-bot-staging/v2/.mocharc.js create mode 100644 owl-bot-staging/v2/.prettierrc.js create mode 100644 owl-bot-staging/v2/README.md create mode 100644 owl-bot-staging/v2/linkinator.config.json create mode 100644 owl-bot-staging/v2/package.json create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto create mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto create mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.create_service.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.delete_service.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.get_service.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.list_services.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/services.update_service.js create mode 100644 owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json create mode 100644 owl-bot-staging/v2/src/index.ts create mode 100644 owl-bot-staging/v2/src/v2/gapic_metadata.json create mode 100644 owl-bot-staging/v2/src/v2/index.ts create mode 100644 owl-bot-staging/v2/src/v2/revisions_client.ts create mode 100644 owl-bot-staging/v2/src/v2/revisions_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/revisions_proto_list.json create mode 100644 owl-bot-staging/v2/src/v2/services_client.ts create mode 100644 owl-bot-staging/v2/src/v2/services_client_config.json create mode 100644 owl-bot-staging/v2/src/v2/services_proto_list.json create mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v2/system-test/install.ts create mode 100644 owl-bot-staging/v2/test/gapic_revisions_v2.ts create mode 100644 owl-bot-staging/v2/test/gapic_services_v2.ts create mode 100644 owl-bot-staging/v2/tsconfig.json create mode 100644 owl-bot-staging/v2/webpack.config.js diff --git a/owl-bot-staging/v2/.eslintignore b/owl-bot-staging/v2/.eslintignore new file mode 100644 index 0000000..cfc348e --- /dev/null +++ b/owl-bot-staging/v2/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v2/.eslintrc.json b/owl-bot-staging/v2/.eslintrc.json new file mode 100644 index 0000000..7821534 --- /dev/null +++ b/owl-bot-staging/v2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v2/.gitignore b/owl-bot-staging/v2/.gitignore new file mode 100644 index 0000000..5d32b23 --- /dev/null +++ b/owl-bot-staging/v2/.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/v2/.jsdoc.js b/owl-bot-staging/v2/.jsdoc.js new file mode 100644 index 0000000..94fed36 --- /dev/null +++ b/owl-bot-staging/v2/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/run', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v2/.mocharc.js b/owl-bot-staging/v2/.mocharc.js new file mode 100644 index 0000000..481c522 --- /dev/null +++ b/owl-bot-staging/v2/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v2/.prettierrc.js b/owl-bot-staging/v2/.prettierrc.js new file mode 100644 index 0000000..494e147 --- /dev/null +++ b/owl-bot-staging/v2/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v2/README.md b/owl-bot-staging/v2/README.md new file mode 100644 index 0000000..bc79325 --- /dev/null +++ b/owl-bot-staging/v2/README.md @@ -0,0 +1 @@ +Run: Nodejs Client diff --git a/owl-bot-staging/v2/linkinator.config.json b/owl-bot-staging/v2/linkinator.config.json new file mode 100644 index 0000000..befd23c --- /dev/null +++ b/owl-bot-staging/v2/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/v2/package.json b/owl-bot-staging/v2/package.json new file mode 100644 index 0000000..9b879b5 --- /dev/null +++ b/owl-bot-staging/v2/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/run", + "version": "0.1.0", + "description": "Run client for Node.js", + "repository": "googleapis/nodejs-run", + "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 run", + "run", + "revisions", + "services" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto new file mode 100644 index 0000000..3e98749 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto @@ -0,0 +1,199 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "ConditionProto"; +option java_package = "com.google.cloud.run.v2"; + +// Defines a status condition for a resource. +message Condition { + // Represents the possible Condition states. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // Transient state: Reconciliation has not started yet. + CONDITION_PENDING = 1; + + // Transient state: reconciliation is still in progress. + CONDITION_RECONCILING = 2; + + // Terminal state: Reconciliation did not succeed. + CONDITION_FAILED = 3; + + // Terminal state: Reconciliation completed successfully. + CONDITION_SUCCEEDED = 4; + } + + // Represents the severity of the condition failures. + enum Severity { + // Unspecified severity + SEVERITY_UNSPECIFIED = 0; + + // Error severity. + ERROR = 1; + + // Warning severity. + WARNING = 2; + + // Info severity. + INFO = 3; + } + + // Reasons common to all types of conditions. + enum CommonReason { + // Default value. + COMMON_REASON_UNDEFINED = 0; + + // Reason unknown. Further details will be in message. + UNKNOWN = 1; + + // Revision creation process failed. + REVISION_FAILED = 3; + + // Timed out waiting for completion. + PROGRESS_DEADLINE_EXCEEDED = 4; + + // The container image path is incorrect. + CONTAINER_MISSING = 6; + + // Insufficient permissions on the container image. + CONTAINER_PERMISSION_DENIED = 7; + + // Container image is not authorized by policy. + CONTAINER_IMAGE_UNAUTHORIZED = 8; + + // Container image policy authorization check failed. + CONTAINER_IMAGE_AUTHORIZATION_CHECK_FAILED = 9; + + // Insufficient permissions on encryption key. + ENCRYPTION_KEY_PERMISSION_DENIED = 10; + + // Permission check on encryption key failed. + ENCRYPTION_KEY_CHECK_FAILED = 11; + + // At least one Access check on secrets failed. + SECRETS_ACCESS_CHECK_FAILED = 12; + + // Waiting for operation to complete. + WAITING_FOR_OPERATION = 13; + + // System will retry immediately. + IMMEDIATE_RETRY = 14; + + // System will retry later; current attempt failed. + POSTPONED_RETRY = 15; + + // An internal error occurred. Further information may be in the message. + INTERNAL = 16; + } + + // Reasons specific to Revision resource. + enum RevisionReason { + // Default value. + REVISION_REASON_UNDEFINED = 0; + + // Revision in Pending state. + PENDING = 1; + + // Revision is in Reserve state. + RESERVE = 2; + + // Revision is Retired. + RETIRED = 3; + + // Revision is being retired. + RETIRING = 4; + + // Revision is being recreated. + RECREATING = 5; + + // There was a health check error. + HEALTH_CHECK_CONTAINER_ERROR = 6; + + // Health check failed due to user error from customized path of the + // container. System will retry. + CUSTOMIZED_PATH_RESPONSE_PENDING = 7; + + // A revision with min_instance_count > 0 was created and is reserved, but + // it was not configured to serve traffic, so it's not live. This can also + // happen momentarily during traffic migration. + MIN_INSTANCES_NOT_PROVISIONED = 8; + + // The maximum allowed number of active revisions has been reached. + ACTIVE_REVISION_LIMIT_REACHED = 9; + + // There was no deployment defined. + // This value is no longer used, but Services created in older versions of + // the API might contain this value. + NO_DEPLOYMENT = 10; + + // A revision's container has no port specified since the revision is of a + // manually scaled service with 0 instance count + HEALTH_CHECK_SKIPPED = 11; + } + + // Reasons specific to Execution resource. + enum ExecutionReason { + // Default value. + EXECUTION_REASON_UNDEFINED = 0; + + // Internal system error getting execution status. System will retry. + JOB_STATUS_SERVICE_POLLING_ERROR = 1; + + // A task reached its retry limit and the last attempt failed due to the + // user container exiting with a non-zero exit code. + NON_ZERO_EXIT_CODE = 2; + } + + // type is used to communicate the status of the reconciliation process. + // See also: + // https://github.com/knative/serving/blob/main/docs/spec/errors.md#error-conditions-and-reporting + // Types common to all resources include: + // * "Ready": True when the Resource is ready. + string type = 1; + + // State of the condition. + State state = 2; + + // Human readable message indicating details about the current status. + string message = 3; + + // Last time the condition transitioned from one status to another. + google.protobuf.Timestamp last_transition_time = 4; + + // How to interpret failures of this condition, one of Error, Warning, Info + Severity severity = 5; + + // The reason for this condition. Depending on the condition type, + // it will populate one of these fields. + // Successful conditions may not have a reason. + oneof reasons { + // A common (service-level) reason for this condition. + CommonReason reason = 6; + + // A reason for the revision condition. + RevisionReason revision_reason = 9; + + // A reason for the execution condition. + ExecutionReason execution_reason = 11; + } +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto new file mode 100644 index 0000000..328c816 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto @@ -0,0 +1,274 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "K8sMinProto"; +option java_package = "com.google.cloud.run.v2"; +option (google.api.resource_definition) = { + type: "cloudkms.googleapis.com/CryptoKey" + pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}" +}; +option (google.api.resource_definition) = { + type: "secretmanager.googleapis.com/Secret" + pattern: "projects/{project}/secrets/{secret}" +}; +option (google.api.resource_definition) = { + type: "secretmanager.googleapis.com/SecretVersion" + pattern: "projects/{project}/secrets/{secret}/versions/{version}" +}; +option (google.api.resource_definition) = { + type: "vpcaccess.googleapis.com/Connector" + pattern: "projects/{project}/locations/{location}/connectors/{connector}" +}; + +// A single application container. +// This specifies both the container to run, the command to run in the container +// and the arguments to supply to it. +// Note that additional arguments may be supplied by the system to the container +// at runtime. +message Container { + // Name of the container specified as a DNS_LABEL. + string name = 1; + + // Required. URL of the Container image in Google Container Registry or Google Artifact + // Registry. More info: https://kubernetes.io/docs/concepts/containers/images + string image = 2 [(google.api.field_behavior) = REQUIRED]; + + // Entrypoint array. Not executed within a shell. + // The docker image's ENTRYPOINT is used if this is not provided. + // Variable references $(VAR_NAME) are expanded using the container's + // environment. If a variable cannot be resolved, the reference in the input + // string will be unchanged. The $(VAR_NAME) syntax can be escaped with a + // double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, + // regardless of whether the variable exists or not. + // More info: + // https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + repeated string command = 3; + + // Arguments to the entrypoint. + // The docker image's CMD is used if this is not provided. + // Variable references $(VAR_NAME) are expanded using the container's + // environment. If a variable cannot be resolved, the reference in the input + // string will be unchanged. The $(VAR_NAME) syntax can be escaped with a + // double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, + // regardless of whether the variable exists or not. + // More info: + // https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + repeated string args = 4; + + // List of environment variables to set in the container. + repeated EnvVar env = 5; + + // Compute Resource requirements by this container. + // More info: + // https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources + ResourceRequirements resources = 6; + + // List of ports to expose from the container. Only a single port can be + // specified. The specified ports must be listening on all interfaces + // (0.0.0.0) within the container to be accessible. + // + // If omitted, a port number will be chosen and passed to the container + // through the PORT environment variable for the container to listen on. + repeated ContainerPort ports = 7; + + // Volume to mount into the container's filesystem. + repeated VolumeMount volume_mounts = 8; +} + +// ResourceRequirements describes the compute resource requirements. +message ResourceRequirements { + // Only memory and CPU are supported. Note: The only + // supported values for CPU are '1', '2', and '4'. Setting 4 CPU requires at + // least 2Gi of memory. + // The values of the map is string form of the 'quantity' k8s type: + // https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go + map limits = 1; + + // Determines whether CPU should be throttled or not outside of requests. + bool cpu_idle = 2; +} + +// EnvVar represents an environment variable present in a Container. +message EnvVar { + // Required. Name of the environment variable. Must be a C_IDENTIFIER, and mnay not + // exceed 32768 characters. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + oneof values { + // Variable references $(VAR_NAME) are expanded + // using the previous defined environment variables in the container and + // any route environment variables. If a variable cannot be resolved, + // the reference in the input string will be unchanged. The $(VAR_NAME) + // syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped + // references will never be expanded, regardless of whether the variable + // exists or not. + // Defaults to "", and the maximum length is 32768 bytes. + string value = 2; + + // Source for the environment variable's value. + EnvVarSource value_source = 3; + } +} + +// EnvVarSource represents a source for the value of an EnvVar. +message EnvVarSource { + // Selects a secret and a specific version from Cloud Secret Manager. + SecretKeySelector secret_key_ref = 1; +} + +// SecretEnvVarSource represents a source for the value of an EnvVar. +message SecretKeySelector { + // Required. The name of the secret in Cloud Secret Manager. + // Format: {secret_name} if the secret is in the same project. + // projects/{project}/secrets/{secret_name} if the secret is + // in a different project. + string secret = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "secretmanager.googleapis.com/Secret" + } + ]; + + // The Cloud Secret Manager secret version. + // Can be 'latest' for the latest value or an integer for a specific version. + string version = 2 [(google.api.resource_reference) = { + type: "secretmanager.googleapis.com/SecretVersion" + }]; +} + +// ContainerPort represents a network port in a single container. +message ContainerPort { + // If specified, used to specify which protocol to use. + // Allowed values are "http1" and "h2c". + string name = 1; + + // Port number the container listens on. + // This must be a valid TCP port number, 0 < container_port < 65536. + int32 container_port = 3; +} + +// VolumeMount describes a mounting of a Volume within a container. +message VolumeMount { + // Required. This must match the Name of a Volume. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Path within the container at which the volume should be mounted. Must + // not contain ':'. For Cloud SQL volumes, it can be left empty, or must + // otherwise be `/cloudsql`. All instances defined in the Volume will be + // available as `/cloudsql/[instance]`. For more information on Cloud SQL + // volumes, visit https://cloud.google.com/sql/docs/mysql/connect-run + string mount_path = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Volume represents a named volume in a container. +message Volume { + // Required. Volume's name. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + oneof volume_type { + // Secret represents a secret that should populate this volume. + // More info: https://kubernetes.io/docs/concepts/storage/volumes#secret + SecretVolumeSource secret = 2; + + // For Cloud SQL volumes, contains the specific instances that should be + // mounted. Visit https://cloud.google.com/sql/docs/mysql/connect-run for + // more information on how to connect Cloud SQL and Cloud Run. + CloudSqlInstance cloud_sql_instance = 3; + } +} + +// The secret's value will be presented as the content of a file whose +// name is defined in the item path. If no items are defined, the name of +// the file is the secret. +message SecretVolumeSource { + // Required. The name of the secret in Cloud Secret Manager. + // Format: {secret} if the secret is in the same project. + // projects/{project}/secrets/{secret} if the secret is + // in a different project. + string secret = 1 [(google.api.field_behavior) = REQUIRED]; + + // If unspecified, the volume will expose a file whose name is the + // secret, relative to VolumeMount.mount_path. + // If specified, the key will be used as the version to fetch from Cloud + // Secret Manager and the path will be the name of the file exposed in the + // volume. When items are defined, they must specify a path and a version. + repeated VersionToPath items = 2; + + // Integer representation of mode bits to use on created files by default. + // Must be a value between 0000 and 0777 (octal), defaulting to 0644. + // Directories within the path are not affected by this setting. + // + // Notes + // + // * Internally, a umask of 0222 will be applied to any non-zero value. + // * This is an integer representation of the mode bits. So, the octal + // integer value should look exactly as the chmod numeric notation with a + // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or + // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or + // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 + // (base-10). + // * This might be in conflict with other options that affect the + // file mode, like fsGroup, and the result can be other mode bits set. + // + // This might be in conflict with other options that affect the + // file mode, like fsGroup, and as a result, other mode bits could be set. + int32 default_mode = 3; +} + +// VersionToPath maps a specific version of a secret to a relative file to mount +// to, relative to VolumeMount's mount_path. +message VersionToPath { + // Required. The relative path of the secret in the container. + string path = 1 [(google.api.field_behavior) = REQUIRED]; + + // The Cloud Secret Manager secret version. + // Can be 'latest' for the latest value or an integer for a specific version. + string version = 2; + + // Integer octal mode bits to use on this file, must be a value between + // 01 and 0777 (octal). If 0 or not set, the Volume's default mode will be + // used. + // + // Notes + // + // * Internally, a umask of 0222 will be applied to any non-zero value. + // * This is an integer representation of the mode bits. So, the octal + // integer value should look exactly as the chmod numeric notation with a + // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or + // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or + // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 + // (base-10). + // * This might be in conflict with other options that affect the + // file mode, like fsGroup, and the result can be other mode bits set. + int32 mode = 3; +} + +// Represents a specific Cloud SQL instance. +message CloudSqlInstance { + // The Cloud SQL instance connection names, as can be found in + // https://console.cloud.google.com/sql/instances. Visit + // https://cloud.google.com/sql/docs/mysql/connect-run for more information on + // how to connect Cloud SQL and Cloud Run. Format: + // {project}:{location}:{instance} + repeated string instances = 1; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto new file mode 100644 index 0000000..0cb674e --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto @@ -0,0 +1,278 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/api/routing.proto"; +import "google/cloud/run/v2/condition.proto"; +import "google/cloud/run/v2/k8s.min.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "RevisionProto"; +option java_package = "com.google.cloud.run.v2"; + +// Cloud Run Revision Control Plane API. +service Revisions { + option (google.api.default_host) = "run.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Gets information about a Revision. + rpc GetRevision(GetRevisionRequest) returns (Revision) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + } + + // List Revisions from a given Service, or from a given location. + rpc ListRevisions(ListRevisionsRequest) returns (ListRevisionsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/services/*}/revisions" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Delete a Revision. + rpc DeleteRevision(DeleteRevisionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Revision" + metadata_type: "Revision" + }; + } +} + +// Request message for obtaining a Revision by its full name. +message GetRevisionRequest { + // Required. The full name of the Revision. + // Format: + // projects/{project}/locations/{location}/services/{service}/revisions/{revision} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + } + ]; +} + +// Request message for retrieving a list of Revisions. +message ListRevisionsRequest { + // Required. The Service from which the Revisions should be listed. + // To list all Revisions across Services, use "-" instead of Service name. + // Format: + // projects/{project}/locations/{location}/services/{service} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Revision" + } + ]; + + // Maximum number of revisions to return in this call. + int32 page_size = 2; + + // A page token received from a previous call to ListRevisions. + // All other parameters must match. + string page_token = 3; + + // If true, returns deleted (but unexpired) resources along with active ones. + bool show_deleted = 4; +} + +// Response message containing a list of Revisions. +message ListRevisionsResponse { + // The resulting list of Revisions. + repeated Revision revisions = 1; + + // A token indicating there are more items than page_size. Use it in the next + // ListRevisions request to continue. + string next_page_token = 2; +} + +// Request message for deleting a retired Revision. +// Revision lifecycle is usually managed by making changes to the parent +// Service. Only retired revisions can be deleted with this API. +message DeleteRevisionRequest { + // Required. The name of the Revision to delete. + // Format: + // projects/{project}/locations/{location}/services/{service}/revisions/{revision} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + } + ]; + + // Indicates that the request should be validated without actually + // deleting any resources. + bool validate_only = 2; + + // A system-generated fingerprint for this version of the + // resource. This may be used to detect modification conflict during updates. + string etag = 3; +} + +// A Revision is an immutable snapshot of code and configuration. A Revision +// references a container image. Revisions are only created by updates to its +// parent Service. +message Revision { + option (google.api.resource) = { + type: "run.googleapis.com/Revision" + pattern: "projects/{project}/locations/{location}/services/{service}/revisions/{revision}" + style: DECLARATIVE_FRIENDLY + }; + + // Output only. The unique name of this Revision. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server assigned unique identifier for the Revision. The value is a UUID4 + // string and guaranteed to remain unchanged until the resource is deleted. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A number that monotonically increases every time the user + // modifies the desired state. + int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // KRM-style labels for the resource. + // User-provided labels are shared with Google's billing system, so they can + // be used to filter, or break down billing charges by team, component, + // environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels + // Cloud Run will populate some labels with 'run.googleapis.com' or + // 'serving.knative.dev' namespaces. Those labels are read-only, and user + // changes will not be preserved. + map labels = 4; + + // KRM-style annotations for the resource. + map annotations = 5; + + // Output only. The creation time. + google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last-modified time. + google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the deletion time. It is only + // populated as a response to a Delete request. + google.protobuf.Timestamp delete_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the time after which it will be + // permamently deleted. It is only populated as a response to a Delete + // request. + google.protobuf.Timestamp expire_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Set the launch stage to a preview stage on write to allow use of preview + // features in that stage. On read, describes whether the resource uses + // preview features. Launch Stages are defined at [Google Cloud Platform + // Launch Stages](https://cloud.google.com/terms/launch-stages). + google.api.LaunchStage launch_stage = 10; + + // Output only. The name of the parent service. + string service = 11 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "run.googleapis.com/Service" + } + ]; + + // Scaling settings for this revision. + RevisionScaling scaling = 12; + + // VPC Access configuration for this Revision. For more information, visit + // https://cloud.google.com/run/docs/configuring/connecting-vpc. + VpcAccess vpc_access = 13; + + // Sets the maximum number of requests that each serving instance can receive. + int32 max_instance_request_concurrency = 34; + + // Max allowed time for an instance to respond to a request. + google.protobuf.Duration timeout = 15; + + // Email address of the IAM service account associated with the revision of + // the service. The service account represents the identity of the running + // revision, and determines what permissions the revision has. + string service_account = 16; + + // Holds the single container that defines the unit of execution for this + // Revision. + repeated Container containers = 17; + + // A list of Volumes to make available to containers. + repeated Volume volumes = 18; + + // The execution environment being used to host this Revision. + ExecutionEnvironment execution_environment = 20; + + // A reference to a customer managed encryption key (CMEK) to use to encrypt + // this container image. For more information, go to + // https://cloud.google.com/run/docs/securing/using-cmek + string encryption_key = 21 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; + + // Output only. Indicates whether the resource's reconciliation is still in progress. + // See comments in `Service.reconciling` for additional information on + // reconciliation process in Cloud Run. + bool reconciling = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Condition of this Revision, containing its readiness status, and + // detailed error information in case it did not reach a serving state. + repeated Condition conditions = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The generation of this Revision currently serving traffic. See comments in + // `reconciling` for additional information on reconciliation process in Cloud + // Run. + int64 observed_generation = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Google Console URI to obtain logs for the Revision. + string log_uri = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto new file mode 100644 index 0000000..f20fb5e --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/resource.proto"; +import "google/cloud/run/v2/k8s.min.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "RevisionTemplateProto"; +option java_package = "com.google.cloud.run.v2"; + +// RevisionTemplate describes the data a revision should have when created from +// a template. +message RevisionTemplate { + // The unique name for the revision. If this field is omitted, it will be + // automatically generated based on the Service name. + string revision = 1 [(google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + }]; + + // KRM-style labels for the resource. + map labels = 2; + + // KRM-style annotations for the resource. + map annotations = 3; + + // Scaling settings for this Revision. + RevisionScaling scaling = 4; + + // VPC Access configuration to use for this Revision. For more information, + // visit https://cloud.google.com/run/docs/configuring/connecting-vpc. + VpcAccess vpc_access = 6; + + // Max allowed time for an instance to respond to a request. + google.protobuf.Duration timeout = 8; + + // Email address of the IAM service account associated with the revision of + // the service. The service account represents the identity of the running + // revision, and determines what permissions the revision has. If not + // provided, the revision will use the project's default service account. + string service_account = 9; + + // Holds the single container that defines the unit of execution for this + // Revision. + repeated Container containers = 10; + + // A list of Volumes to make available to containers. + repeated Volume volumes = 11; + + // The sandbox environment to host this Revision. + ExecutionEnvironment execution_environment = 13; + + // A reference to a customer managed encryption key (CMEK) to use to encrypt + // this container image. For more information, go to + // https://cloud.google.com/run/docs/securing/using-cmek + string encryption_key = 14 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; + + // Sets the maximum number of requests that each serving instance can receive. + int32 max_instance_request_concurrency = 15; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto new file mode 100644 index 0000000..51a29ed --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto @@ -0,0 +1,435 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; +import "google/api/routing.proto"; +import "google/cloud/run/v2/condition.proto"; +import "google/cloud/run/v2/revision_template.proto"; +import "google/cloud/run/v2/traffic_target.proto"; +import "google/cloud/run/v2/vendor_settings.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "ServiceProto"; +option java_package = "com.google.cloud.run.v2"; + +// Cloud Run Service Control Plane API +service Services { + option (google.api.default_host) = "run.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new Service in a given project and location. + rpc CreateService(CreateServiceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*}/services" + body: "service" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}" + } + }; + option (google.api.method_signature) = "parent,service,service_id"; + option (google.longrunning.operation_info) = { + response_type: "Service" + metadata_type: "Service" + }; + } + + // Gets information about a Service. + rpc GetService(GetServiceRequest) returns (Service) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/services/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + } + + // List Services. + rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/services" + }; + option (google.api.routing) = { + routing_parameters { + field: "parent" + path_template: "projects/*/locations/{location=*}" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a Service. + rpc UpdateService(UpdateServiceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v2/{service.name=projects/*/locations/*/services/*}" + body: "service" + }; + option (google.api.routing) = { + routing_parameters { + field: "service.name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "service"; + option (google.longrunning.operation_info) = { + response_type: "Service" + metadata_type: "Service" + }; + } + + // Deletes a Service. + // This will cause the Service to stop serving traffic and will delete all + // revisions. + rpc DeleteService(DeleteServiceRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/services/*}" + }; + option (google.api.routing) = { + routing_parameters { + field: "name" + path_template: "projects/*/locations/{location=*}/**" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Service" + metadata_type: "Service" + }; + } + + // Get the IAM Access Control policy currently in effect for the given + // Cloud Run Service. This result does not include any inherited policies. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + get: "/v2/{resource=projects/*/locations/*/services/*}:getIamPolicy" + }; + } + + // Sets the IAM Access control policy for the specified Service. Overwrites + // any existing policy. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/services/*}:setIamPolicy" + body: "*" + }; + } + + // Returns permissions that a caller has on the specified Project. + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/services/*}:testIamPermissions" + body: "*" + }; + } +} + +// Request message for creating a Service. +message CreateServiceRequest { + // Required. The location and project in which this service should be created. + // Format: projects/{projectnumber}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Service" + } + ]; + + // Required. The Service instance to create. + Service service = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The unique identifier for the Service. The name of the service becomes + // {parent}/services/{service_id}. + string service_id = 3 [(google.api.field_behavior) = REQUIRED]; + + // Indicates that the request should be validated and default values + // populated, without persisting the request or creating any resources. + bool validate_only = 4; +} + +// Request message for updating a service. +message UpdateServiceRequest { + // Required. The Service to be updated. + Service service = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates that the request should be validated and default values + // populated, without persisting the request or updating any resources. + bool validate_only = 3; + + // If set to true, and if the Service does not exist, it will create a new + // one. Caller must have both create and update permissions for this call if + // this is set to true. + bool allow_missing = 4; +} + +// Request message for retrieving a list of Services. +message ListServicesRequest { + // Required. The location and project to list resources on. + // Location must be a valid GCP region, and may not be the "-" wildcard. + // Format: projects/{projectnumber}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "run.googleapis.com/Service" + } + ]; + + // Maximum number of Services to return in this call. + int32 page_size = 2; + + // A page token received from a previous call to ListServices. + // All other parameters must match. + string page_token = 3; + + // If true, returns deleted (but unexpired) resources along with active ones. + bool show_deleted = 4; +} + +// Response message containing a list of Services. +message ListServicesResponse { + // The resulting list of Services. + repeated Service services = 1; + + // A token indicating there are more items than page_size. Use it in the next + // ListServices request to continue. + string next_page_token = 2; +} + +// Request message for obtaining a Service by its full name. +message GetServiceRequest { + // Required. The full name of the Service. + // Format: projects/{projectnumber}/locations/{location}/services/{service} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "run.googleapis.com/Service" + } + ]; +} + +// Request message to delete a Service by its full name. +message DeleteServiceRequest { + // Required. The full name of the Service. + // Format: projects/{projectnumber}/locations/{location}/services/{service} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "run.googleapis.com/Service" + } + ]; + + // Indicates that the request should be validated without actually + // deleting any resources. + bool validate_only = 2; + + // A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 3; +} + +// Service acts as a top-level container that manages a set of +// configurations and revision templates which implement a network service. +// Service exists to provide a singular abstraction which can be access +// controlled, reasoned about, and which encapsulates software lifecycle +// decisions such as rollout policy and team resource ownership. +message Service { + option (google.api.resource) = { + type: "run.googleapis.com/Service" + pattern: "projects/{project}/locations/{location}/services/{service}" + style: DECLARATIVE_FRIENDLY + }; + + // The fully qualified name of this Service. In CreateServiceRequest, this + // field is ignored, and instead composed from CreateServiceRequest.parent and + // CreateServiceRequest.service_id. + // + // Format: + // projects/{project}/locations/{location}/services/{service_id} + string name = 1; + + // User-provided description of the Service. This field currently has a + // 512-character limit. + string description = 2; + + // Output only. Server assigned unique identifier for the trigger. The value is a UUID4 + // string and guaranteed to remain unchanged until the resource is deleted. + string uid = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A number that monotonically increases every time the user + // modifies the desired state. + // Please note that unlike v1, this is an int64 value. As with most Google + // APIs, its JSON representation will be a `string` instead of an `integer`. + int64 generation = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Map of string keys and values that can be used to organize and categorize + // objects. + // User-provided labels are shared with Google's billing system, so they can + // be used to filter, or break down billing charges by team, component, + // environment, state, etc. For more information, visit + // https://cloud.google.com/resource-manager/docs/creating-managing-labels or + // https://cloud.google.com/run/docs/configuring/labels + // Cloud Run will populate some labels with 'run.googleapis.com' or + // 'serving.knative.dev' namespaces. Those labels are read-only, and user + // changes will not be preserved. + map labels = 5; + + // Unstructured key value map that may be set by external tools to store and + // arbitrary metadata. They are not queryable and should be preserved + // when modifying objects. Cloud Run will populate some annotations using + // 'run.googleapis.com' or 'serving.knative.dev' namespaces. This field + // follows Kubernetes annotations' namespacing, limits, and rules. More info: + // https://kubernetes.io/docs/user-guide/annotations + map annotations = 6; + + // Output only. The creation time. + google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last-modified time. + google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The deletion time. + google.protobuf.Timestamp delete_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a deleted resource, the time after which it will be + // permamently deleted. + google.protobuf.Timestamp expire_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Email address of the authenticated creator. + string creator = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Email address of the last authenticated modifier. + string last_modifier = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Arbitrary identifier for the API client. + string client = 13; + + // Arbitrary version identifier for the API client. + string client_version = 14; + + // Provides the ingress settings for this Service. On output, returns the + // currently observed ingress settings, or INGRESS_TRAFFIC_UNSPECIFIED if no + // revision is active. + IngressTraffic ingress = 15; + + // The launch stage as defined by [Google Cloud Platform + // Launch Stages](https://cloud.google.com/terms/launch-stages). + // Cloud Run supports `ALPHA`, `BETA`, and `GA`. If no value is specified, GA + // is assumed. + google.api.LaunchStage launch_stage = 16; + + // Settings for the Binary Authorization feature. + BinaryAuthorization binary_authorization = 17; + + // Required. The template used to create revisions for this Service. + RevisionTemplate template = 18 [(google.api.field_behavior) = REQUIRED]; + + // Specifies how to distribute traffic over a collection of Revisions + // belonging to the Service. If traffic is empty or not provided, defaults to + // 100% traffic to the latest `Ready` Revision. + repeated TrafficTarget traffic = 19; + + // Output only. The generation of this Service currently serving traffic. See comments in + // `reconciling` for additional information on reconciliation process in Cloud + // Run. + // Please note that unlike v1, this is an int64 value. As with most Google + // APIs, its JSON representation will be a `string` instead of an `integer`. + int64 observed_generation = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Condition of this Service, containing its readiness status, and + // detailed error information in case it did not reach a serving state. See + // comments in `reconciling` for additional information on reconciliation + // process in Cloud Run. + Condition terminal_condition = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Conditions of all other associated sub-resources. They contain + // additional diagnostics information in case the Service does not reach its + // Serving state. See comments in `reconciling` for additional information on + // reconciliation process in Cloud Run. + repeated Condition conditions = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the latest revision that is serving traffic. See comments in + // `reconciling` for additional information on reconciliation process in Cloud + // Run. + string latest_ready_revision = 33 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + } + ]; + + // Output only. Name of the last created revision. See comments in `reconciling` for + // additional information on reconciliation process in Cloud Run. + string latest_created_revision = 34 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + } + ]; + + // Output only. Detailed status information for corresponding traffic targets. See comments + // in `reconciling` for additional information on reconciliation process in + // Cloud Run. + repeated TrafficTargetStatus traffic_statuses = 35 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The main URI in which this Service is serving traffic. + string uri = 36 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Returns true if the Service is currently being acted upon by the system to + // bring it into the desired state. + // + // When a new Service is created, or an existing one is updated, Cloud Run + // will asynchronously perform all necessary steps to bring the Service to the + // desired serving state. This process is called reconciliation. + // While reconciliation is in process, `observed_generation`, + // `latest_ready_revison`, `traffic_statuses`, and `uri` will have transient + // values that might mismatch the intended state: Once reconciliation is over + // (and this field is false), there are two possible outcomes: reconciliation + // succeeded and the serving state matches the Service, or there was an error, + // and reconciliation failed. This state can be found in + // `terminal_condition.state`. + // + // If reconciliation succeeded, the following fields will match: `traffic` and + // `traffic_statuses`, `observed_generation` and `generation`, + // `latest_ready_revision` and `latest_created_revision`. + // + // If reconciliation failed, `traffic_statuses`, `observed_generation`, and + // `latest_ready_revision` will have the state of the last serving revision, + // or empty for newly created Services. Additional information on the failure + // can be found in `terminal_condition` and `conditions`. + bool reconciling = 98 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A system-generated fingerprint for this version of the + // resource. May be used to detect modification conflict during updates. + string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto new file mode 100644 index 0000000..18a8c7d --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "TrafficTargetProto"; +option java_package = "com.google.cloud.run.v2"; + +// Holds a single traffic routing entry for the Service. Allocations can be done +// to a specific Revision name, or pointing to the latest Ready Revision. +message TrafficTarget { + // The allocation type for this traffic target. + TrafficTargetAllocationType type = 1; + + // Revision to which to send this portion of traffic, if traffic allocation is + // by revision. + string revision = 2 [(google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + }]; + + // Specifies percent of the traffic to this Revision. + // This defaults to zero if unspecified. + int32 percent = 3; + + // Indicates a string to be part of the URI to exclusively reference this + // target. + string tag = 4; +} + +// Represents the observed state of a single `TrafficTarget` entry. +message TrafficTargetStatus { + // The allocation type for this traffic target. + TrafficTargetAllocationType type = 1; + + // Revision to which this traffic is sent. + string revision = 2 [(google.api.resource_reference) = { + type: "run.googleapis.com/Revision" + }]; + + // Specifies percent of the traffic to this Revision. + int32 percent = 3; + + // Indicates the string used in the URI to exclusively reference this target. + string tag = 4; + + // Displays the target URI. + string uri = 5; +} + +// The type of instance allocation. +enum TrafficTargetAllocationType { + // Unspecified instance allocation type. + TRAFFIC_TARGET_ALLOCATION_TYPE_UNSPECIFIED = 0; + + // Allocates instances to the Service's latest ready Revision. + TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST = 1; + + // Allocates instances to a Revision by name. + TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION = 2; +} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto new file mode 100644 index 0000000..89748d5 --- /dev/null +++ b/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto @@ -0,0 +1,102 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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.run.v2; + +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; +option java_multiple_files = true; +option java_outer_classname = "VendorSettingsProto"; +option java_package = "com.google.cloud.run.v2"; + +// VPC Access settings. For more information on creating a VPC Connector, visit +// https://cloud.google.com/vpc/docs/configure-serverless-vpc-access For +// information on how to configure Cloud Run with an existing VPC Connector, +// visit https://cloud.google.com/run/docs/configuring/connecting-vpc +message VpcAccess { + // Egress options for VPC access. + enum VpcEgress { + // Unspecified + VPC_EGRESS_UNSPECIFIED = 0; + + // All outbound traffic is routed through the VPC connector. + ALL_TRAFFIC = 1; + + // Only private IP ranges are routed through the VPC connector. + PRIVATE_RANGES_ONLY = 2; + } + + // VPC Access connector name. + // Format: projects/{project}/locations/{location}/connectors/{connector} + string connector = 1 [(google.api.resource_reference) = { + type: "vpcaccess.googleapis.com/Connector" + }]; + + // Traffic VPC egress settings. + VpcEgress egress = 2; +} + +// Settings for Binary Authorization feature. +message BinaryAuthorization { + oneof binauthz_method { + // If True, indicates to use the default project's binary authorization + // policy. If False, binary authorization will be disabled. + bool use_default = 1; + } + + // If present, indicates to use Breakglass using this justification. + // If use_default is False, then it must be empty. + // For more information on breakglass, see + // https://cloud.google.com/binary-authorization/docs/using-breakglass + string breakglass_justification = 2; +} + +// Settings for revision-level scaling settings. +message RevisionScaling { + // Minimum number of serving instances that this resource should have. + int32 min_instance_count = 1; + + // Maximum number of serving instances that this resource should have. + int32 max_instance_count = 2; +} + +// Allowed ingress traffic for the Container. +enum IngressTraffic { + // Unspecified + INGRESS_TRAFFIC_UNSPECIFIED = 0; + + // All inbound traffic is allowed. + INGRESS_TRAFFIC_ALL = 1; + + // Only internal traffic is allowed. + INGRESS_TRAFFIC_INTERNAL_ONLY = 2; + + // Both internal and Google Cloud Load Balancer traffic is allowed. + INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER = 3; +} + +// Alternatives for execution environments. +enum ExecutionEnvironment { + // Unspecified + EXECUTION_ENVIRONMENT_UNSPECIFIED = 0; + + // Uses the First Generation environment. + EXECUTION_ENVIRONMENT_GEN1 = 1; + + // Uses Second Generation environment. + EXECUTION_ENVIRONMENT_GEN2 = 2; +} diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js b/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js new file mode 100644 index 0000000..ab6b399 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Revisions_DeleteRevision_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Revision to delete. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + */ + // const name = 'abc123' + /** + * Indicates that the request should be validated without actually + * deleting any resources. + */ + // const validateOnly = true + /** + * A system-generated fingerprint for this version of the + * resource. This may be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {RevisionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new RevisionsClient(); + + async function callDeleteRevision() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.deleteRevision(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteRevision(); + // [END run_v2_generated_Revisions_DeleteRevision_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js b/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js new file mode 100644 index 0000000..0c67144 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Revisions_GetRevision_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Revision. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + */ + // const name = 'abc123' + + // Imports the Run library + const {RevisionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new RevisionsClient(); + + async function callGetRevision() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await runClient.getRevision(request); + console.log(response); + } + + callGetRevision(); + // [END run_v2_generated_Revisions_GetRevision_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js b/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js new file mode 100644 index 0000000..2263cee --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START run_v2_generated_Revisions_ListRevisions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + */ + // const parent = 'abc123' + /** + * Maximum number of revisions to return in this call. + */ + // const pageSize = 1234 + /** + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + */ + // const pageToken = 'abc123' + /** + * If true, returns deleted (but unexpired) resources along with active ones. + */ + // const showDeleted = true + + // Imports the Run library + const {RevisionsClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new RevisionsClient(); + + async function callListRevisions() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await runClient.listRevisionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRevisions(); + // [END run_v2_generated_Revisions_ListRevisions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.create_service.js b/owl-bot-staging/v2/samples/generated/v2/services.create_service.js new file mode 100644 index 0000000..7524ecb --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.create_service.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, service, serviceId) { + // [START run_v2_generated_Services_CreateService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location and project in which this service should be created. + * Format: projects/{projectnumber}/locations/{location} + */ + // const parent = 'abc123' + /** + * Required. The Service instance to create. + */ + // const service = {} + /** + * Required. The unique identifier for the Service. The name of the service becomes + * {parent}/services/{service_id}. + */ + // const serviceId = 'abc123' + /** + * Indicates that the request should be validated and default values + * populated, without persisting the request or creating any resources. + */ + // const validateOnly = true + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callCreateService() { + // Construct request + const request = { + parent, + service, + serviceId, + }; + + // Run request + const [operation] = await runClient.createService(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateService(); + // [END run_v2_generated_Services_CreateService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js b/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js new file mode 100644 index 0000000..bcf7ec4 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Services_DeleteService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Service. + * Format: projects/{projectnumber}/locations/{location}/services/{service} + */ + // const name = 'abc123' + /** + * Indicates that the request should be validated without actually + * deleting any resources. + */ + // const validateOnly = true + /** + * A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + */ + // const etag = 'abc123' + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callDeleteService() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await runClient.deleteService(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteService(); + // [END run_v2_generated_Services_DeleteService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js b/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js new file mode 100644 index 0000000..52329ca --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource) { + // [START run_v2_generated_Services_GetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await runClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END run_v2_generated_Services_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.get_service.js b/owl-bot-staging/v2/samples/generated/v2/services.get_service.js new file mode 100644 index 0000000..ffd939c --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.get_service.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START run_v2_generated_Services_GetService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full name of the Service. + * Format: projects/{projectnumber}/locations/{location}/services/{service} + */ + // const name = 'abc123' + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callGetService() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await runClient.getService(request); + console.log(response); + } + + callGetService(); + // [END run_v2_generated_Services_GetService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.list_services.js b/owl-bot-staging/v2/samples/generated/v2/services.list_services.js new file mode 100644 index 0000000..3daad03 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.list_services.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START run_v2_generated_Services_ListServices_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location and project to list resources on. + * Location must be a valid GCP region, and may not be the "-" wildcard. + * Format: projects/{projectnumber}/locations/{location} + */ + // const parent = 'abc123' + /** + * Maximum number of Services to return in this call. + */ + // const pageSize = 1234 + /** + * A page token received from a previous call to ListServices. + * All other parameters must match. + */ + // const pageToken = 'abc123' + /** + * If true, returns deleted (but unexpired) resources along with active ones. + */ + // const showDeleted = true + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callListServices() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await runClient.listServicesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServices(); + // [END run_v2_generated_Services_ListServices_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js b/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js new file mode 100644 index 0000000..f56b2bd --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource, policy) { + // [START run_v2_generated_Services_SetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await runClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END run_v2_generated_Services_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js b/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js new file mode 100644 index 0000000..f7fbd42 --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource, permissions) { + // [START run_v2_generated_Services_TestIamPermissions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await runClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END run_v2_generated_Services_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.update_service.js b/owl-bot-staging/v2/samples/generated/v2/services.update_service.js new file mode 100644 index 0000000..a280ace --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/services.update_service.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(service) { + // [START run_v2_generated_Services_UpdateService_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Service to be updated. + */ + // const service = {} + /** + * Indicates that the request should be validated and default values + * populated, without persisting the request or updating any resources. + */ + // const validateOnly = true + /** + * If set to true, and if the Service does not exist, it will create a new + * one. Caller must have both create and update permissions for this call if + * this is set to true. + */ + // const allowMissing = true + + // Imports the Run library + const {ServicesClient} = require('@google-cloud/run').v2; + + // Instantiates a client + const runClient = new ServicesClient(); + + async function callUpdateService() { + // Construct request + const request = { + service, + }; + + // Run request + const [operation] = await runClient.updateService(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateService(); + // [END run_v2_generated_Services_UpdateService_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json new file mode 100644 index 0000000..82e2baf --- /dev/null +++ b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json @@ -0,0 +1,531 @@ +{ + "clientLibrary": { + "name": "nodejs-run", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.run.v2", + "version": "v2" + } + ] + }, + "snippets": [ + { + "regionTag": "run_v2_generated_Revisions_GetRevision_async", + "title": "Revisions getRevision Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a Revision.", + "canonical": true, + "file": "revisions.get_revision.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRevision", + "fullName": "google.cloud.run.v2.Revisions.GetRevision", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.run.v2.Revision", + "client": { + "shortName": "RevisionsClient", + "fullName": "google.cloud.run.v2.RevisionsClient" + }, + "method": { + "shortName": "GetRevision", + "fullName": "google.cloud.run.v2.Revisions.GetRevision", + "service": { + "shortName": "Revisions", + "fullName": "google.cloud.run.v2.Revisions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Revisions_ListRevisions_async", + "title": "Revisions listRevisions Sample", + "origin": "API_DEFINITION", + "description": " List Revisions from a given Service, or from a given location.", + "canonical": true, + "file": "revisions.list_revisions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRevisions", + "fullName": "google.cloud.run.v2.Revisions.ListRevisions", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.run.v2.ListRevisionsResponse", + "client": { + "shortName": "RevisionsClient", + "fullName": "google.cloud.run.v2.RevisionsClient" + }, + "method": { + "shortName": "ListRevisions", + "fullName": "google.cloud.run.v2.Revisions.ListRevisions", + "service": { + "shortName": "Revisions", + "fullName": "google.cloud.run.v2.Revisions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Revisions_DeleteRevision_async", + "title": "Revisions deleteRevision Sample", + "origin": "API_DEFINITION", + "description": " Delete a Revision.", + "canonical": true, + "file": "revisions.delete_revision.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteRevision", + "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "RevisionsClient", + "fullName": "google.cloud.run.v2.RevisionsClient" + }, + "method": { + "shortName": "DeleteRevision", + "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", + "service": { + "shortName": "Revisions", + "fullName": "google.cloud.run.v2.Revisions" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_CreateService_async", + "title": "Revisions createService Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Service in a given project and location.", + "canonical": true, + "file": "services.create_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateService", + "fullName": "google.cloud.run.v2.Services.CreateService", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "service", + "type": ".google.cloud.run.v2.Service" + }, + { + "name": "service_id", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "CreateService", + "fullName": "google.cloud.run.v2.Services.CreateService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_GetService_async", + "title": "Revisions getService Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a Service.", + "canonical": true, + "file": "services.get_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetService", + "fullName": "google.cloud.run.v2.Services.GetService", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.run.v2.Service", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "GetService", + "fullName": "google.cloud.run.v2.Services.GetService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_ListServices_async", + "title": "Revisions listServices Sample", + "origin": "API_DEFINITION", + "description": " List Services.", + "canonical": true, + "file": "services.list_services.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServices", + "fullName": "google.cloud.run.v2.Services.ListServices", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.run.v2.ListServicesResponse", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "ListServices", + "fullName": "google.cloud.run.v2.Services.ListServices", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_UpdateService_async", + "title": "Revisions updateService Sample", + "origin": "API_DEFINITION", + "description": " Updates a Service.", + "canonical": true, + "file": "services.update_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateService", + "fullName": "google.cloud.run.v2.Services.UpdateService", + "async": true, + "parameters": [ + { + "name": "service", + "type": ".google.cloud.run.v2.Service" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "UpdateService", + "fullName": "google.cloud.run.v2.Services.UpdateService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_DeleteService_async", + "title": "Revisions deleteService Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Service. This will cause the Service to stop serving traffic and will delete all revisions.", + "canonical": true, + "file": "services.delete_service.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteService", + "fullName": "google.cloud.run.v2.Services.DeleteService", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "DeleteService", + "fullName": "google.cloud.run.v2.Services.DeleteService", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_GetIamPolicy_async", + "title": "Revisions getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Get the IAM Access Control policy currently in effect for the given Cloud Run Service. This result does not include any inherited policies.", + "canonical": true, + "file": "services.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.run.v2.Services.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.run.v2.Services.GetIamPolicy", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_SetIamPolicy_async", + "title": "Revisions setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the IAM Access control policy for the specified Service. Overwrites any existing policy.", + "canonical": true, + "file": "services.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.run.v2.Services.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.run.v2.Services.SetIamPolicy", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + }, + { + "regionTag": "run_v2_generated_Services_TestIamPermissions_async", + "title": "Revisions testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified Project. There are no permissions required for making this API call.", + "canonical": true, + "file": "services.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.run.v2.Services.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "ServicesClient", + "fullName": "google.cloud.run.v2.ServicesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.run.v2.Services.TestIamPermissions", + "service": { + "shortName": "Services", + "fullName": "google.cloud.run.v2.Services" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v2/src/index.ts b/owl-bot-staging/v2/src/index.ts new file mode 100644 index 0000000..f7f6340 --- /dev/null +++ b/owl-bot-staging/v2/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v2 from './v2'; +const RevisionsClient = v2.RevisionsClient; +type RevisionsClient = v2.RevisionsClient; +const ServicesClient = v2.ServicesClient; +type ServicesClient = v2.ServicesClient; +export {v2, RevisionsClient, ServicesClient}; +export default {v2, RevisionsClient, ServicesClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v2/src/v2/gapic_metadata.json b/owl-bot-staging/v2/src/v2/gapic_metadata.json new file mode 100644 index 0000000..5990e13 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/gapic_metadata.json @@ -0,0 +1,155 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.run.v2", + "libraryPackage": "@google-cloud/run", + "services": { + "Revisions": { + "clients": { + "grpc": { + "libraryClient": "RevisionsClient", + "rpcs": { + "GetRevision": { + "methods": [ + "getRevision" + ] + }, + "DeleteRevision": { + "methods": [ + "deleteRevision" + ] + }, + "ListRevisions": { + "methods": [ + "listRevisions", + "listRevisionsStream", + "listRevisionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RevisionsClient", + "rpcs": { + "GetRevision": { + "methods": [ + "getRevision" + ] + }, + "DeleteRevision": { + "methods": [ + "deleteRevision" + ] + }, + "ListRevisions": { + "methods": [ + "listRevisions", + "listRevisionsStream", + "listRevisionsAsync" + ] + } + } + } + } + }, + "Services": { + "clients": { + "grpc": { + "libraryClient": "ServicesClient", + "rpcs": { + "GetService": { + "methods": [ + "getService" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateService": { + "methods": [ + "createService" + ] + }, + "UpdateService": { + "methods": [ + "updateService" + ] + }, + "DeleteService": { + "methods": [ + "deleteService" + ] + }, + "ListServices": { + "methods": [ + "listServices", + "listServicesStream", + "listServicesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServicesClient", + "rpcs": { + "GetService": { + "methods": [ + "getService" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateService": { + "methods": [ + "createService" + ] + }, + "UpdateService": { + "methods": [ + "updateService" + ] + }, + "DeleteService": { + "methods": [ + "deleteService" + ] + }, + "ListServices": { + "methods": [ + "listServices", + "listServicesStream", + "listServicesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/index.ts b/owl-bot-staging/v2/src/v2/index.ts new file mode 100644 index 0000000..5ea97dc --- /dev/null +++ b/owl-bot-staging/v2/src/v2/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {RevisionsClient} from './revisions_client'; +export {ServicesClient} from './services_client'; diff --git a/owl-bot-staging/v2/src/v2/revisions_client.ts b/owl-bot-staging/v2/src/v2/revisions_client.ts new file mode 100644 index 0000000..ecc51b3 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/revisions_client.ts @@ -0,0 +1,1016 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/revisions_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './revisions_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Run Revision Control Plane API. + * @class + * @memberof v2 + */ +export class RevisionsClient { + 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}; + operationsClient: gax.OperationsClient; + revisionsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RevisionsClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RevisionsClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RevisionsClient; + 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // 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 = { + cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + revisionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}' + ), + }; + + // 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 = { + listRevisions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'revisions') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const deleteRevisionResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Revision') as gax.protobuf.Type; + const deleteRevisionMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Revision') as gax.protobuf.Type; + + this.descriptors.longrunning = { + deleteRevision: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteRevisionResponse.decode.bind(deleteRevisionResponse), + deleteRevisionMetadata.decode.bind(deleteRevisionMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.run.v2.Revisions', 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 = this._gaxModule.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.revisionsStub) { + return this.revisionsStub; + } + + // Put together the "service stub" for + // google.cloud.run.v2.Revisions. + this.revisionsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Revisions') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.run.v2.Revisions, + 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 revisionsStubMethods = + ['getRevision', 'listRevisions', 'deleteRevision']; + for (const methodName of revisionsStubMethods) { + const callPromise = this.revisionsStub.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] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.revisionsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'run.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 'run.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets information about a Revision. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Revision. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + * @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 [Revision]{@link google.cloud.run.v2.Revision}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/revisions.get_revision.js + * region_tag:run_v2_generated_Revisions_GetRevision_async + */ + getRevision( + request?: protos.google.cloud.run.v2.IGetRevisionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|undefined, {}|undefined + ]>; + getRevision( + request: protos.google.cloud.run.v2.IGetRevisionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>): void; + getRevision( + request: protos.google.cloud.run.v2.IGetRevisionRequest, + callback: Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>): void; + getRevision( + request?: protos.google.cloud.run.v2.IGetRevisionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.run.v2.IRevision, + protos.google.cloud.run.v2.IGetRevisionRequest|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.getRevision(request, options, callback); + } + +/** + * Delete a Revision. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Revision to delete. + * Format: + * projects/{project}/locations/{location}/services/{service}/revisions/{revision} + * @param {boolean} request.validateOnly + * Indicates that the request should be validated without actually + * deleting any resources. + * @param {string} request.etag + * A system-generated fingerprint for this version of the + * resource. This may be used to detect modification conflict during updates. + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/revisions.delete_revision.js + * region_tag:run_v2_generated_Revisions_DeleteRevision_async + */ + deleteRevision( + request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteRevision( + request: protos.google.cloud.run.v2.IDeleteRevisionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteRevision( + request: protos.google.cloud.run.v2.IDeleteRevisionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteRevision( + request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.deleteRevision(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteRevision()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/revisions.delete_revision.js + * region_tag:run_v2_generated_Revisions_DeleteRevision_async + */ + async checkDeleteRevisionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteRevision, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * List Revisions from a given Service, or from a given location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + * @param {number} request.pageSize + * Maximum number of revisions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 [Revision]{@link google.cloud.run.v2.Revision}. + * 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 `listRevisionsAsync()` + * 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. + */ + listRevisions( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IRevision[], + protos.google.cloud.run.v2.IListRevisionsRequest|null, + protos.google.cloud.run.v2.IListRevisionsResponse + ]>; + listRevisions( + request: protos.google.cloud.run.v2.IListRevisionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>): void; + listRevisions( + request: protos.google.cloud.run.v2.IListRevisionsRequest, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>): void; + listRevisions( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>, + callback?: PaginationCallback< + protos.google.cloud.run.v2.IListRevisionsRequest, + protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, + protos.google.cloud.run.v2.IRevision>): + Promise<[ + protos.google.cloud.run.v2.IRevision[], + protos.google.cloud.run.v2.IListRevisionsRequest|null, + protos.google.cloud.run.v2.IListRevisionsResponse + ]>|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.listRevisions(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 Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + * @param {number} request.pageSize + * Maximum number of revisions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 [Revision]{@link google.cloud.run.v2.Revision} 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 `listRevisionsAsync()` + * 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. + */ + listRevisionsStream( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRevisions.createStream( + this.innerApiCalls.listRevisions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRevisions`, 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 Service from which the Revisions should be listed. + * To list all Revisions across Services, use "-" instead of Service name. + * Format: + * projects/{project}/locations/{location}/services/{service} + * @param {number} request.pageSize + * Maximum number of revisions to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListRevisions. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 + * [Revision]{@link google.cloud.run.v2.Revision}. 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 include:samples/generated/v2/revisions.list_revisions.js + * region_tag:run_v2_generated_Revisions_ListRevisions_async + */ + listRevisionsAsync( + request?: protos.google.cloud.run.v2.IListRevisionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRevisions.asyncIterate( + this.innerApiCalls['listRevisions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified cryptoKey resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} key_ring + * @param {string} crypto_key + * @returns {string} Resource name string. + */ + cryptoKeyPath(project:string,location:string,keyRing:string,cryptoKey:string) { + return this.pathTemplates.cryptoKeyPathTemplate.render({ + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + }); + } + + /** + * Parse the project from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + } + + /** + * Parse the location from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + } + + /** + * Parse the key_ring from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the key_ring. + */ + matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).key_ring; + } + + /** + * Parse the crypto_key from CryptoKey resource. + * + * @param {string} cryptoKeyName + * A fully-qualified path representing CryptoKey resource. + * @returns {string} A string representing the crypto_key. + */ + matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).crypto_key; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).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 revision resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @param {string} revision + * @returns {string} Resource name string. + */ + revisionPath(project:string,location:string,service:string,revision:string) { + return this.pathTemplates.revisionPathTemplate.render({ + project: project, + location: location, + service: service, + revision: revision, + }); + } + + /** + * Parse the project from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).project; + } + + /** + * Parse the location from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).location; + } + + /** + * Parse the service from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the service. + */ + matchServiceFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).service; + } + + /** + * Parse the revision from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the revision. + */ + matchRevisionFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(project:string,location:string,service:string) { + return this.pathTemplates.servicePathTemplate.render({ + project: project, + location: location, + service: service, + }); + } + + /** + * Parse the project from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).project; + } + + /** + * Parse the location from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).location; + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.revisionsStub && !this._terminated) { + return this.revisionsStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/revisions_client_config.json b/owl-bot-staging/v2/src/v2/revisions_client_config.json new file mode 100644 index 0000000..f5a18a2 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/revisions_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.run.v2.Revisions": { + "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": { + "GetRevision": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRevisions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteRevision": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/revisions_proto_list.json b/owl-bot-staging/v2/src/v2/revisions_proto_list.json new file mode 100644 index 0000000..455cae6 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/revisions_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/k8s.min.proto", + "../../protos/google/cloud/run/v2/revision.proto", + "../../protos/google/cloud/run/v2/revision_template.proto", + "../../protos/google/cloud/run/v2/service.proto", + "../../protos/google/cloud/run/v2/traffic_target.proto", + "../../protos/google/cloud/run/v2/vendor_settings.proto" +] diff --git a/owl-bot-staging/v2/src/v2/services_client.ts b/owl-bot-staging/v2/src/v2/services_client.ts new file mode 100644 index 0000000..228aaf7 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/services_client.ts @@ -0,0 +1,1423 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/services_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './services_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Run Service Control Plane API + * @class + * @memberof v2 + */ +export class ServicesClient { + 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}; + operationsClient: gax.OperationsClient; + servicesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServicesClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ServicesClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServicesClient; + 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // 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 = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + revisionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/services/{service}' + ), + }; + + // 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 = { + listServices: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createServiceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const createServiceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const updateServiceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const updateServiceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const deleteServiceResponse = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + const deleteServiceMetadata = protoFilesRoot.lookup( + '.google.cloud.run.v2.Service') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createService: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createServiceResponse.decode.bind(createServiceResponse), + createServiceMetadata.decode.bind(createServiceMetadata)), + updateService: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateServiceResponse.decode.bind(updateServiceResponse), + updateServiceMetadata.decode.bind(updateServiceMetadata)), + deleteService: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteServiceResponse.decode.bind(deleteServiceResponse), + deleteServiceMetadata.decode.bind(deleteServiceMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.run.v2.Services', 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 = this._gaxModule.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.servicesStub) { + return this.servicesStub; + } + + // Put together the "service stub" for + // google.cloud.run.v2.Services. + this.servicesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Services') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.run.v2.Services, + 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 servicesStubMethods = + ['createService', 'getService', 'listServices', 'updateService', 'deleteService', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of servicesStubMethods) { + const callPromise = this.servicesStub.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] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.servicesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'run.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 'run.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets information about a Service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Service. + * Format: projects/{projectnumber}/locations/{location}/services/{service} + * @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 [Service]{@link google.cloud.run.v2.Service}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/services.get_service.js + * region_tag:run_v2_generated_Services_GetService_async + */ + getService( + request?: protos.google.cloud.run.v2.IGetServiceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|undefined, {}|undefined + ]>; + getService( + request: protos.google.cloud.run.v2.IGetServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>): void; + getService( + request: protos.google.cloud.run.v2.IGetServiceRequest, + callback: Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>): void; + getService( + request?: protos.google.cloud.run.v2.IGetServiceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.run.v2.IService, + protos.google.cloud.run.v2.IGetServiceRequest|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.getService(request, options, callback); + } +/** + * Get the IAM Access Control policy currently in effect for the given + * Cloud Run Service. This result does not include any inherited policies. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/services.get_iam_policy.js + * region_tag:run_v2_generated_Services_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the IAM Access control policy for the specified Service. Overwrites + * any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/services.set_iam_policy.js + * region_tag:run_v2_generated_Services_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified Project. + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/services.test_iam_permissions.js + * region_tag:run_v2_generated_Services_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Creates a new Service in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project in which this service should be created. + * Format: projects/{projectnumber}/locations/{location} + * @param {google.cloud.run.v2.Service} request.service + * Required. The Service instance to create. + * @param {string} request.serviceId + * Required. The unique identifier for the Service. The name of the service becomes + * {parent}/services/{service_id}. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated and default values + * populated, without persisting the request or creating any resources. + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.create_service.js + * region_tag:run_v2_generated_Services_CreateService_async + */ + createService( + request?: protos.google.cloud.run.v2.ICreateServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createService( + request: protos.google.cloud.run.v2.ICreateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createService( + request: protos.google.cloud.run.v2.ICreateServiceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createService( + request?: protos.google.cloud.run.v2.ICreateServiceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.createService(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createService()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.create_service.js + * region_tag:run_v2_generated_Services_CreateService_async + */ + async checkCreateServiceProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createService, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a Service. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.run.v2.Service} request.service + * Required. The Service to be updated. + * @param {boolean} request.validateOnly + * Indicates that the request should be validated and default values + * populated, without persisting the request or updating any resources. + * @param {boolean} request.allowMissing + * If set to true, and if the Service does not exist, it will create a new + * one. Caller must have both create and update permissions for this call if + * this is set to true. + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.update_service.js + * region_tag:run_v2_generated_Services_UpdateService_async + */ + updateService( + request?: protos.google.cloud.run.v2.IUpdateServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateService( + request: protos.google.cloud.run.v2.IUpdateServiceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateService( + request: protos.google.cloud.run.v2.IUpdateServiceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateService( + request?: protos.google.cloud.run.v2.IUpdateServiceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.service?.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.updateService(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateService()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.update_service.js + * region_tag:run_v2_generated_Services_UpdateService_async + */ + async checkUpdateServiceProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateService, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a Service. + * This will cause the Service to stop serving traffic and will delete all + * revisions. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of the Service. + * Format: projects/{projectnumber}/locations/{location}/services/{service} + * @param {boolean} request.validateOnly + * Indicates that the request should be validated without actually + * deleting any resources. + * @param {string} request.etag + * A system-generated fingerprint for this version of the + * resource. May be used to detect modification conflict during updates. + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.delete_service.js + * region_tag:run_v2_generated_Services_DeleteService_async + */ + deleteService( + request?: protos.google.cloud.run.v2.IDeleteServiceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteService( + request: protos.google.cloud.run.v2.IDeleteServiceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteService( + request: protos.google.cloud.run.v2.IDeleteServiceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteService( + request?: protos.google.cloud.run.v2.IDeleteServiceRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.name; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.deleteService(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteService()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/services.delete_service.js + * region_tag:run_v2_generated_Services_DeleteService_async + */ + async checkDeleteServiceProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteService, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * List Services. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location and project to list resources on. + * Location must be a valid GCP region, and may not be the "-" wildcard. + * Format: projects/{projectnumber}/locations/{location} + * @param {number} request.pageSize + * Maximum number of Services to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListServices. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 [Service]{@link google.cloud.run.v2.Service}. + * 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 `listServicesAsync()` + * 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. + */ + listServices( + request?: protos.google.cloud.run.v2.IListServicesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.run.v2.IService[], + protos.google.cloud.run.v2.IListServicesRequest|null, + protos.google.cloud.run.v2.IListServicesResponse + ]>; + listServices( + request: protos.google.cloud.run.v2.IListServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>): void; + listServices( + request: protos.google.cloud.run.v2.IListServicesRequest, + callback: PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>): void; + listServices( + request?: protos.google.cloud.run.v2.IListServicesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>, + callback?: PaginationCallback< + protos.google.cloud.run.v2.IListServicesRequest, + protos.google.cloud.run.v2.IListServicesResponse|null|undefined, + protos.google.cloud.run.v2.IService>): + Promise<[ + protos.google.cloud.run.v2.IService[], + protos.google.cloud.run.v2.IListServicesRequest|null, + protos.google.cloud.run.v2.IListServicesResponse + ]>|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 || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + this.initialize(); + return this.innerApiCalls.listServices(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 location and project to list resources on. + * Location must be a valid GCP region, and may not be the "-" wildcard. + * Format: projects/{projectnumber}/locations/{location} + * @param {number} request.pageSize + * Maximum number of Services to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListServices. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 [Service]{@link google.cloud.run.v2.Service} 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 `listServicesAsync()` + * 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. + */ + listServicesStream( + request?: protos.google.cloud.run.v2.IListServicesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listServices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServices.createStream( + this.innerApiCalls.listServices as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServices`, 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 location and project to list resources on. + * Location must be a valid GCP region, and may not be the "-" wildcard. + * Format: projects/{projectnumber}/locations/{location} + * @param {number} request.pageSize + * Maximum number of Services to return in this call. + * @param {string} request.pageToken + * A page token received from a previous call to ListServices. + * All other parameters must match. + * @param {boolean} request.showDeleted + * If true, returns deleted (but unexpired) resources along with active ones. + * @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 + * [Service]{@link google.cloud.run.v2.Service}. 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 include:samples/generated/v2/services.list_services.js + * region_tag:run_v2_generated_Services_ListServices_async + */ + listServicesAsync( + request?: protos.google.cloud.run.v2.IListServicesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + let routingParameter = {}; + { + const fieldValue = request.parent; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); + if (match) { + const parameterValue = match.groups?.['location'] ?? fieldValue; + Object.assign(routingParameter, { location: parameterValue }); + } + } + } + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams( + routingParameter + ); + const defaultCallSettings = this._defaults['listServices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServices.asyncIterate( + this.innerApiCalls['listServices'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).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 revision resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @param {string} revision + * @returns {string} Resource name string. + */ + revisionPath(project:string,location:string,service:string,revision:string) { + return this.pathTemplates.revisionPathTemplate.render({ + project: project, + location: location, + service: service, + revision: revision, + }); + } + + /** + * Parse the project from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).project; + } + + /** + * Parse the location from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).location; + } + + /** + * Parse the service from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the service. + */ + matchServiceFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).service; + } + + /** + * Parse the revision from Revision resource. + * + * @param {string} revisionName + * A fully-qualified path representing Revision resource. + * @returns {string} A string representing the revision. + */ + matchRevisionFromRevisionName(revisionName: string) { + return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(project:string,location:string,service:string) { + return this.pathTemplates.servicePathTemplate.render({ + project: project, + location: location, + service: service, + }); + } + + /** + * Parse the project from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).project; + } + + /** + * Parse the location from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).location; + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.servicesStub && !this._terminated) { + return this.servicesStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v2/src/v2/services_client_config.json b/owl-bot-staging/v2/src/v2/services_client_config.json new file mode 100644 index 0000000..d9a3364 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/services_client_config.json @@ -0,0 +1,75 @@ +{ + "interfaces": { + "google.cloud.run.v2.Services": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateService": { + "timeout_millis": 15000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetService": { + "timeout_millis": 10000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListServices": { + "timeout_millis": 10000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateService": { + "timeout_millis": 15000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteService": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v2/src/v2/services_proto_list.json b/owl-bot-staging/v2/src/v2/services_proto_list.json new file mode 100644 index 0000000..455cae6 --- /dev/null +++ b/owl-bot-staging/v2/src/v2/services_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/run/v2/condition.proto", + "../../protos/google/cloud/run/v2/k8s.min.proto", + "../../protos/google/cloud/run/v2/revision.proto", + "../../protos/google/cloud/run/v2/revision_template.proto", + "../../protos/google/cloud/run/v2/service.proto", + "../../protos/google/cloud/run/v2/traffic_target.proto", + "../../protos/google/cloud/run/v2/vendor_settings.proto" +] diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..01b536f --- /dev/null +++ b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const run = require('@google-cloud/run'); + +function main() { + const revisionsClient = new run.RevisionsClient(); + const servicesClient = new run.ServicesClient(); +} + +main(); diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..769c1b4 --- /dev/null +++ b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {RevisionsClient, ServicesClient} from '@google-cloud/run'; + +// check that the client class type name can be used +function doStuffWithRevisionsClient(client: RevisionsClient) { + client.close(); +} +function doStuffWithServicesClient(client: ServicesClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const revisionsClient = new RevisionsClient(); + doStuffWithRevisionsClient(revisionsClient); + // check that the client instance can be created + const servicesClient = new ServicesClient(); + doStuffWithServicesClient(servicesClient); +} + +main(); diff --git a/owl-bot-staging/v2/system-test/install.ts b/owl-bot-staging/v2/system-test/install.ts new file mode 100644 index 0000000..557a575 --- /dev/null +++ b/owl-bot-staging/v2/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v2/test/gapic_revisions_v2.ts b/owl-bot-staging/v2/test/gapic_revisions_v2.ts new file mode 100644 index 0000000..4b4fb53 --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_revisions_v2.ts @@ -0,0 +1,932 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as revisionsModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +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('v2.RevisionsClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = revisionsModule.v2.RevisionsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = revisionsModule.v2.RevisionsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = revisionsModule.v2.RevisionsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new revisionsModule.v2.RevisionsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new revisionsModule.v2.RevisionsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.revisionsStub, undefined); + await client.initialize(); + assert(client.revisionsStub); + }); + + it('has close method for the initialized client', done => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.revisionsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.revisionsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new revisionsModule.v2.RevisionsClient({ + 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 revisionsModule.v2.RevisionsClient({ + 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('getRevision', () => { + it('invokes getRevision without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Revision()); + client.innerApiCalls.getRevision = stubSimpleCall(expectedResponse); + const [response] = await client.getRevision(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getRevision without error using callback', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Revision()); + client.innerApiCalls.getRevision = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRevision( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getRevision with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getRevision = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRevision(request), expectedError); + assert((client.innerApiCalls.getRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getRevision with closed client', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRevision(request), expectedError); + }); + }); + + describe('deleteRevision', () => { + it('invokes deleteRevision without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteRevision = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteRevision(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteRevision without error using callback', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteRevision = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteRevision( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteRevision with call error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteRevision(request), expectedError); + assert((client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteRevision with LRO error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteRevision(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteRevision as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteRevisionProgress without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteRevisionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteRevisionProgress with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteRevisionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listRevisions', () => { + it('invokes listRevisions without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.innerApiCalls.listRevisions = stubSimpleCall(expectedResponse); + const [response] = await client.listRevisions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listRevisions without error using callback', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.innerApiCalls.listRevisions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRevisions( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listRevisions with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listRevisions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRevisions(request), expectedError); + assert((client.innerApiCalls.listRevisions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listRevisionsStream without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRevisionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Revision[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { + 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.listRevisions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); + assert.strictEqual( + (client.descriptors.page.listRevisions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listRevisionsStream with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedError = new Error('expected'); + client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRevisionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Revision[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRevisions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); + assert.strictEqual( + (client.descriptors.page.listRevisions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listRevisions without error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + generateSampleMessage(new protos.google.cloud.run.v2.Revision()), + ]; + client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.run.v2.IRevision[] = []; + const iterable = client.listRevisionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listRevisions with error', async () => { + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.parent = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&');const expectedError = new Error('expected'); + client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRevisionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.run.v2.IRevision[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listRevisions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('cryptoKey', () => { + const fakePath = "/rendered/path/cryptoKey"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + key_ring: "keyRingValue", + crypto_key: "cryptoKeyValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cryptoKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.cryptoKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('cryptoKeyPath', () => { + const result = client.cryptoKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCryptoKeyName', () => { + const result = client.matchProjectFromCryptoKeyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCryptoKeyName', () => { + const result = client.matchLocationFromCryptoKeyName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchKeyRingFromCryptoKeyName', () => { + const result = client.matchKeyRingFromCryptoKeyName(fakePath); + assert.strictEqual(result, "keyRingValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCryptoKeyFromCryptoKeyName', () => { + const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); + assert.strictEqual(result, "cryptoKeyValue"); + assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + 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('revision', () => { + const fakePath = "/rendered/path/revision"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + revision: "revisionValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.revisionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.revisionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('revisionPath', () => { + const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRevisionName', () => { + const result = client.matchProjectFromRevisionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRevisionName', () => { + const result = client.matchLocationFromRevisionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromRevisionName', () => { + const result = client.matchServiceFromRevisionName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRevisionFromRevisionName', () => { + const result = client.matchRevisionFromRevisionName(fakePath); + assert.strictEqual(result, "revisionValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + }; + const client = new revisionsModule.v2.RevisionsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("projectValue", "locationValue", "serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/test/gapic_services_v2.ts b/owl-bot-staging/v2/test/gapic_services_v2.ts new file mode 100644 index 0000000..3ec3f34 --- /dev/null +++ b/owl-bot-staging/v2/test/gapic_services_v2.ts @@ -0,0 +1,1485 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as servicesModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +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('v2.ServicesClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = servicesModule.v2.ServicesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = servicesModule.v2.ServicesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = servicesModule.v2.ServicesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new servicesModule.v2.ServicesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new servicesModule.v2.ServicesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servicesStub, undefined); + await client.initialize(); + assert(client.servicesStub); + }); + + it('has close method for the initialized client', done => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.servicesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servicesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new servicesModule.v2.ServicesClient({ + 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 servicesModule.v2.ServicesClient({ + 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('getService', () => { + it('invokes getService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Service()); + client.innerApiCalls.getService = stubSimpleCall(expectedResponse); + const [response] = await client.getService(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Service()); + client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getService( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IService|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getService as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getService with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getService = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getService(request), expectedError); + assert((client.innerApiCalls.getService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getService with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getService(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createService', () => { + it('invokes createService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createService = stubLongRunningCall(expectedResponse); + const [operation] = await client.createService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createService = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createService( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createService as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createService with call error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createService(request), expectedError); + assert((client.innerApiCalls.createService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createService with LRO error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createService(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateServiceProgress without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateServiceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateServiceProgress with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateServiceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateService', () => { + it('invokes updateService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateService = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateService = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateService( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateService as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateService with call error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateService(request), expectedError); + assert((client.innerApiCalls.updateService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateService with LRO error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + request.service = {}; + // path template: projects/*/locations/{location=*}/** + request.service.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateService(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.updateService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUpdateServiceProgress without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateServiceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateServiceProgress with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateServiceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteService', () => { + it('invokes deleteService without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteService = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteService(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteService without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteService = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteService( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteService as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteService with call error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteService(request), expectedError); + assert((client.innerApiCalls.deleteService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteService with LRO error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*}/** + request.name = 'projects/value/locations/value/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteService(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteService as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteServiceProgress without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteServiceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteServiceProgress with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteServiceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); + const [response] = await client.listServices(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServices as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServices without error using callback', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + (err?: Error|null, result?: protos.google.cloud.run.v2.IService[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listServices as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listServices with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServices(request), expectedError); + assert((client.innerApiCalls.listServices as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listServicesStream without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Service[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Service) => { + 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.listServices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServices, request)); + assert.strictEqual( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listServicesStream with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedError = new Error('expected'); + client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.run.v2.Service[] = []; + stream.on('data', (response: protos.google.cloud.run.v2.Service) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServices, request)); + assert.strictEqual( + (client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServices without error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + generateSampleMessage(new protos.google.cloud.run.v2.Service()), + ]; + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.run.v2.IService[] = []; + const iterable = client.listServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServices with error', async () => { + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); + const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; + // path template: projects/*/locations/{location=*} + request.parent = 'projects/value/locations/value'; + expectedHeaderRequestParamsObj['location'] = 'value'; + const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&');const expectedError = new Error('expected'); + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.run.v2.IService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new servicesModule.v2.ServicesClient({ + 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('revision', () => { + const fakePath = "/rendered/path/revision"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + revision: "revisionValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.revisionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.revisionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('revisionPath', () => { + const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRevisionName', () => { + const result = client.matchProjectFromRevisionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRevisionName', () => { + const result = client.matchLocationFromRevisionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromRevisionName', () => { + const result = client.matchServiceFromRevisionName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRevisionFromRevisionName', () => { + const result = client.matchRevisionFromRevisionName(fakePath); + assert.strictEqual(result, "revisionValue"); + assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + service: "serviceValue", + }; + const client = new servicesModule.v2.ServicesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("projectValue", "locationValue", "serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromServiceName', () => { + const result = client.matchProjectFromServiceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromServiceName', () => { + const result = client.matchLocationFromServiceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v2/tsconfig.json b/owl-bot-staging/v2/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v2/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/v2/webpack.config.js b/owl-bot-staging/v2/webpack.config.js new file mode 100644 index 0000000..36eeb4b --- /dev/null +++ b/owl-bot-staging/v2/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: 'Revisions', + filename: './revisions.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From ff3272b3ea54450bf042788592250ab11341a801 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 30 Aug 2022 09:05:24 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- owl-bot-staging/v2/.eslintignore | 7 - owl-bot-staging/v2/.eslintrc.json | 3 - owl-bot-staging/v2/.gitignore | 14 - owl-bot-staging/v2/.jsdoc.js | 55 - owl-bot-staging/v2/.mocharc.js | 33 - owl-bot-staging/v2/.prettierrc.js | 22 - owl-bot-staging/v2/README.md | 1 - owl-bot-staging/v2/linkinator.config.json | 16 - owl-bot-staging/v2/package.json | 65 - .../google/cloud/run/v2/condition.proto | 199 --- .../protos/google/cloud/run/v2/k8s.min.proto | 274 --- .../protos/google/cloud/run/v2/revision.proto | 278 --- .../cloud/run/v2/revision_template.proto | 79 - .../protos/google/cloud/run/v2/service.proto | 435 ----- .../google/cloud/run/v2/traffic_target.proto | 77 - .../google/cloud/run/v2/vendor_settings.proto | 102 -- .../generated/v2/revisions.delete_revision.js | 74 - .../generated/v2/revisions.get_revision.js | 63 - .../generated/v2/revisions.list_revisions.js | 79 - .../generated/v2/services.create_service.js | 79 - .../generated/v2/services.delete_service.js | 73 - .../generated/v2/services.get_iam_policy.js | 67 - .../generated/v2/services.get_service.js | 62 - .../generated/v2/services.list_services.js | 78 - .../generated/v2/services.set_iam_policy.js | 77 - .../v2/services.test_iam_permissions.js | 70 - .../generated/v2/services.update_service.js | 73 - .../snippet_metadata.google.cloud.run.v2.json | 531 ------ owl-bot-staging/v2/src/index.ts | 27 - owl-bot-staging/v2/src/v2/gapic_metadata.json | 155 -- owl-bot-staging/v2/src/v2/index.ts | 20 - owl-bot-staging/v2/src/v2/revisions_client.ts | 1016 ----------- .../v2/src/v2/revisions_client_config.json | 38 - .../v2/src/v2/revisions_proto_list.json | 9 - owl-bot-staging/v2/src/v2/services_client.ts | 1423 ---------------- .../v2/src/v2/services_client_config.json | 75 - .../v2/src/v2/services_proto_list.json | 9 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - owl-bot-staging/v2/system-test/install.ts | 49 - owl-bot-staging/v2/test/gapic_revisions_v2.ts | 932 ----------- owl-bot-staging/v2/test/gapic_services_v2.ts | 1485 ----------------- owl-bot-staging/v2/tsconfig.json | 19 - owl-bot-staging/v2/webpack.config.js | 64 - 44 files changed, 8373 deletions(-) delete mode 100644 owl-bot-staging/v2/.eslintignore delete mode 100644 owl-bot-staging/v2/.eslintrc.json delete mode 100644 owl-bot-staging/v2/.gitignore delete mode 100644 owl-bot-staging/v2/.jsdoc.js delete mode 100644 owl-bot-staging/v2/.mocharc.js delete mode 100644 owl-bot-staging/v2/.prettierrc.js delete mode 100644 owl-bot-staging/v2/README.md delete mode 100644 owl-bot-staging/v2/linkinator.config.json delete mode 100644 owl-bot-staging/v2/package.json delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto delete mode 100644 owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto delete mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.create_service.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.delete_service.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.get_service.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.list_services.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/services.update_service.js delete mode 100644 owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json delete mode 100644 owl-bot-staging/v2/src/index.ts delete mode 100644 owl-bot-staging/v2/src/v2/gapic_metadata.json delete mode 100644 owl-bot-staging/v2/src/v2/index.ts delete mode 100644 owl-bot-staging/v2/src/v2/revisions_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/revisions_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/revisions_proto_list.json delete mode 100644 owl-bot-staging/v2/src/v2/services_client.ts delete mode 100644 owl-bot-staging/v2/src/v2/services_client_config.json delete mode 100644 owl-bot-staging/v2/src/v2/services_proto_list.json delete mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v2/system-test/install.ts delete mode 100644 owl-bot-staging/v2/test/gapic_revisions_v2.ts delete mode 100644 owl-bot-staging/v2/test/gapic_services_v2.ts delete mode 100644 owl-bot-staging/v2/tsconfig.json delete mode 100644 owl-bot-staging/v2/webpack.config.js diff --git a/owl-bot-staging/v2/.eslintignore b/owl-bot-staging/v2/.eslintignore deleted file mode 100644 index cfc348e..0000000 --- a/owl-bot-staging/v2/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v2/.eslintrc.json b/owl-bot-staging/v2/.eslintrc.json deleted file mode 100644 index 7821534..0000000 --- a/owl-bot-staging/v2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v2/.gitignore b/owl-bot-staging/v2/.gitignore deleted file mode 100644 index 5d32b23..0000000 --- a/owl-bot-staging/v2/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v2/.jsdoc.js b/owl-bot-staging/v2/.jsdoc.js deleted file mode 100644 index 94fed36..0000000 --- a/owl-bot-staging/v2/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/run', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v2/.mocharc.js b/owl-bot-staging/v2/.mocharc.js deleted file mode 100644 index 481c522..0000000 --- a/owl-bot-staging/v2/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v2/.prettierrc.js b/owl-bot-staging/v2/.prettierrc.js deleted file mode 100644 index 494e147..0000000 --- a/owl-bot-staging/v2/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v2/README.md b/owl-bot-staging/v2/README.md deleted file mode 100644 index bc79325..0000000 --- a/owl-bot-staging/v2/README.md +++ /dev/null @@ -1 +0,0 @@ -Run: Nodejs Client diff --git a/owl-bot-staging/v2/linkinator.config.json b/owl-bot-staging/v2/linkinator.config.json deleted file mode 100644 index befd23c..0000000 --- a/owl-bot-staging/v2/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/v2/package.json b/owl-bot-staging/v2/package.json deleted file mode 100644 index 9b879b5..0000000 --- a/owl-bot-staging/v2/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/run", - "version": "0.1.0", - "description": "Run client for Node.js", - "repository": "googleapis/nodejs-run", - "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 run", - "run", - "revisions", - "services" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto deleted file mode 100644 index 3e98749..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/condition.proto +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "ConditionProto"; -option java_package = "com.google.cloud.run.v2"; - -// Defines a status condition for a resource. -message Condition { - // Represents the possible Condition states. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // Transient state: Reconciliation has not started yet. - CONDITION_PENDING = 1; - - // Transient state: reconciliation is still in progress. - CONDITION_RECONCILING = 2; - - // Terminal state: Reconciliation did not succeed. - CONDITION_FAILED = 3; - - // Terminal state: Reconciliation completed successfully. - CONDITION_SUCCEEDED = 4; - } - - // Represents the severity of the condition failures. - enum Severity { - // Unspecified severity - SEVERITY_UNSPECIFIED = 0; - - // Error severity. - ERROR = 1; - - // Warning severity. - WARNING = 2; - - // Info severity. - INFO = 3; - } - - // Reasons common to all types of conditions. - enum CommonReason { - // Default value. - COMMON_REASON_UNDEFINED = 0; - - // Reason unknown. Further details will be in message. - UNKNOWN = 1; - - // Revision creation process failed. - REVISION_FAILED = 3; - - // Timed out waiting for completion. - PROGRESS_DEADLINE_EXCEEDED = 4; - - // The container image path is incorrect. - CONTAINER_MISSING = 6; - - // Insufficient permissions on the container image. - CONTAINER_PERMISSION_DENIED = 7; - - // Container image is not authorized by policy. - CONTAINER_IMAGE_UNAUTHORIZED = 8; - - // Container image policy authorization check failed. - CONTAINER_IMAGE_AUTHORIZATION_CHECK_FAILED = 9; - - // Insufficient permissions on encryption key. - ENCRYPTION_KEY_PERMISSION_DENIED = 10; - - // Permission check on encryption key failed. - ENCRYPTION_KEY_CHECK_FAILED = 11; - - // At least one Access check on secrets failed. - SECRETS_ACCESS_CHECK_FAILED = 12; - - // Waiting for operation to complete. - WAITING_FOR_OPERATION = 13; - - // System will retry immediately. - IMMEDIATE_RETRY = 14; - - // System will retry later; current attempt failed. - POSTPONED_RETRY = 15; - - // An internal error occurred. Further information may be in the message. - INTERNAL = 16; - } - - // Reasons specific to Revision resource. - enum RevisionReason { - // Default value. - REVISION_REASON_UNDEFINED = 0; - - // Revision in Pending state. - PENDING = 1; - - // Revision is in Reserve state. - RESERVE = 2; - - // Revision is Retired. - RETIRED = 3; - - // Revision is being retired. - RETIRING = 4; - - // Revision is being recreated. - RECREATING = 5; - - // There was a health check error. - HEALTH_CHECK_CONTAINER_ERROR = 6; - - // Health check failed due to user error from customized path of the - // container. System will retry. - CUSTOMIZED_PATH_RESPONSE_PENDING = 7; - - // A revision with min_instance_count > 0 was created and is reserved, but - // it was not configured to serve traffic, so it's not live. This can also - // happen momentarily during traffic migration. - MIN_INSTANCES_NOT_PROVISIONED = 8; - - // The maximum allowed number of active revisions has been reached. - ACTIVE_REVISION_LIMIT_REACHED = 9; - - // There was no deployment defined. - // This value is no longer used, but Services created in older versions of - // the API might contain this value. - NO_DEPLOYMENT = 10; - - // A revision's container has no port specified since the revision is of a - // manually scaled service with 0 instance count - HEALTH_CHECK_SKIPPED = 11; - } - - // Reasons specific to Execution resource. - enum ExecutionReason { - // Default value. - EXECUTION_REASON_UNDEFINED = 0; - - // Internal system error getting execution status. System will retry. - JOB_STATUS_SERVICE_POLLING_ERROR = 1; - - // A task reached its retry limit and the last attempt failed due to the - // user container exiting with a non-zero exit code. - NON_ZERO_EXIT_CODE = 2; - } - - // type is used to communicate the status of the reconciliation process. - // See also: - // https://github.com/knative/serving/blob/main/docs/spec/errors.md#error-conditions-and-reporting - // Types common to all resources include: - // * "Ready": True when the Resource is ready. - string type = 1; - - // State of the condition. - State state = 2; - - // Human readable message indicating details about the current status. - string message = 3; - - // Last time the condition transitioned from one status to another. - google.protobuf.Timestamp last_transition_time = 4; - - // How to interpret failures of this condition, one of Error, Warning, Info - Severity severity = 5; - - // The reason for this condition. Depending on the condition type, - // it will populate one of these fields. - // Successful conditions may not have a reason. - oneof reasons { - // A common (service-level) reason for this condition. - CommonReason reason = 6; - - // A reason for the revision condition. - RevisionReason revision_reason = 9; - - // A reason for the execution condition. - ExecutionReason execution_reason = 11; - } -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto deleted file mode 100644 index 328c816..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/k8s.min.proto +++ /dev/null @@ -1,274 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "K8sMinProto"; -option java_package = "com.google.cloud.run.v2"; -option (google.api.resource_definition) = { - type: "cloudkms.googleapis.com/CryptoKey" - pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}" -}; -option (google.api.resource_definition) = { - type: "secretmanager.googleapis.com/Secret" - pattern: "projects/{project}/secrets/{secret}" -}; -option (google.api.resource_definition) = { - type: "secretmanager.googleapis.com/SecretVersion" - pattern: "projects/{project}/secrets/{secret}/versions/{version}" -}; -option (google.api.resource_definition) = { - type: "vpcaccess.googleapis.com/Connector" - pattern: "projects/{project}/locations/{location}/connectors/{connector}" -}; - -// A single application container. -// This specifies both the container to run, the command to run in the container -// and the arguments to supply to it. -// Note that additional arguments may be supplied by the system to the container -// at runtime. -message Container { - // Name of the container specified as a DNS_LABEL. - string name = 1; - - // Required. URL of the Container image in Google Container Registry or Google Artifact - // Registry. More info: https://kubernetes.io/docs/concepts/containers/images - string image = 2 [(google.api.field_behavior) = REQUIRED]; - - // Entrypoint array. Not executed within a shell. - // The docker image's ENTRYPOINT is used if this is not provided. - // Variable references $(VAR_NAME) are expanded using the container's - // environment. If a variable cannot be resolved, the reference in the input - // string will be unchanged. The $(VAR_NAME) syntax can be escaped with a - // double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, - // regardless of whether the variable exists or not. - // More info: - // https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - repeated string command = 3; - - // Arguments to the entrypoint. - // The docker image's CMD is used if this is not provided. - // Variable references $(VAR_NAME) are expanded using the container's - // environment. If a variable cannot be resolved, the reference in the input - // string will be unchanged. The $(VAR_NAME) syntax can be escaped with a - // double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, - // regardless of whether the variable exists or not. - // More info: - // https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - repeated string args = 4; - - // List of environment variables to set in the container. - repeated EnvVar env = 5; - - // Compute Resource requirements by this container. - // More info: - // https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources - ResourceRequirements resources = 6; - - // List of ports to expose from the container. Only a single port can be - // specified. The specified ports must be listening on all interfaces - // (0.0.0.0) within the container to be accessible. - // - // If omitted, a port number will be chosen and passed to the container - // through the PORT environment variable for the container to listen on. - repeated ContainerPort ports = 7; - - // Volume to mount into the container's filesystem. - repeated VolumeMount volume_mounts = 8; -} - -// ResourceRequirements describes the compute resource requirements. -message ResourceRequirements { - // Only memory and CPU are supported. Note: The only - // supported values for CPU are '1', '2', and '4'. Setting 4 CPU requires at - // least 2Gi of memory. - // The values of the map is string form of the 'quantity' k8s type: - // https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go - map limits = 1; - - // Determines whether CPU should be throttled or not outside of requests. - bool cpu_idle = 2; -} - -// EnvVar represents an environment variable present in a Container. -message EnvVar { - // Required. Name of the environment variable. Must be a C_IDENTIFIER, and mnay not - // exceed 32768 characters. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - oneof values { - // Variable references $(VAR_NAME) are expanded - // using the previous defined environment variables in the container and - // any route environment variables. If a variable cannot be resolved, - // the reference in the input string will be unchanged. The $(VAR_NAME) - // syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped - // references will never be expanded, regardless of whether the variable - // exists or not. - // Defaults to "", and the maximum length is 32768 bytes. - string value = 2; - - // Source for the environment variable's value. - EnvVarSource value_source = 3; - } -} - -// EnvVarSource represents a source for the value of an EnvVar. -message EnvVarSource { - // Selects a secret and a specific version from Cloud Secret Manager. - SecretKeySelector secret_key_ref = 1; -} - -// SecretEnvVarSource represents a source for the value of an EnvVar. -message SecretKeySelector { - // Required. The name of the secret in Cloud Secret Manager. - // Format: {secret_name} if the secret is in the same project. - // projects/{project}/secrets/{secret_name} if the secret is - // in a different project. - string secret = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "secretmanager.googleapis.com/Secret" - } - ]; - - // The Cloud Secret Manager secret version. - // Can be 'latest' for the latest value or an integer for a specific version. - string version = 2 [(google.api.resource_reference) = { - type: "secretmanager.googleapis.com/SecretVersion" - }]; -} - -// ContainerPort represents a network port in a single container. -message ContainerPort { - // If specified, used to specify which protocol to use. - // Allowed values are "http1" and "h2c". - string name = 1; - - // Port number the container listens on. - // This must be a valid TCP port number, 0 < container_port < 65536. - int32 container_port = 3; -} - -// VolumeMount describes a mounting of a Volume within a container. -message VolumeMount { - // Required. This must match the Name of a Volume. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Path within the container at which the volume should be mounted. Must - // not contain ':'. For Cloud SQL volumes, it can be left empty, or must - // otherwise be `/cloudsql`. All instances defined in the Volume will be - // available as `/cloudsql/[instance]`. For more information on Cloud SQL - // volumes, visit https://cloud.google.com/sql/docs/mysql/connect-run - string mount_path = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Volume represents a named volume in a container. -message Volume { - // Required. Volume's name. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - oneof volume_type { - // Secret represents a secret that should populate this volume. - // More info: https://kubernetes.io/docs/concepts/storage/volumes#secret - SecretVolumeSource secret = 2; - - // For Cloud SQL volumes, contains the specific instances that should be - // mounted. Visit https://cloud.google.com/sql/docs/mysql/connect-run for - // more information on how to connect Cloud SQL and Cloud Run. - CloudSqlInstance cloud_sql_instance = 3; - } -} - -// The secret's value will be presented as the content of a file whose -// name is defined in the item path. If no items are defined, the name of -// the file is the secret. -message SecretVolumeSource { - // Required. The name of the secret in Cloud Secret Manager. - // Format: {secret} if the secret is in the same project. - // projects/{project}/secrets/{secret} if the secret is - // in a different project. - string secret = 1 [(google.api.field_behavior) = REQUIRED]; - - // If unspecified, the volume will expose a file whose name is the - // secret, relative to VolumeMount.mount_path. - // If specified, the key will be used as the version to fetch from Cloud - // Secret Manager and the path will be the name of the file exposed in the - // volume. When items are defined, they must specify a path and a version. - repeated VersionToPath items = 2; - - // Integer representation of mode bits to use on created files by default. - // Must be a value between 0000 and 0777 (octal), defaulting to 0644. - // Directories within the path are not affected by this setting. - // - // Notes - // - // * Internally, a umask of 0222 will be applied to any non-zero value. - // * This is an integer representation of the mode bits. So, the octal - // integer value should look exactly as the chmod numeric notation with a - // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or - // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or - // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 - // (base-10). - // * This might be in conflict with other options that affect the - // file mode, like fsGroup, and the result can be other mode bits set. - // - // This might be in conflict with other options that affect the - // file mode, like fsGroup, and as a result, other mode bits could be set. - int32 default_mode = 3; -} - -// VersionToPath maps a specific version of a secret to a relative file to mount -// to, relative to VolumeMount's mount_path. -message VersionToPath { - // Required. The relative path of the secret in the container. - string path = 1 [(google.api.field_behavior) = REQUIRED]; - - // The Cloud Secret Manager secret version. - // Can be 'latest' for the latest value or an integer for a specific version. - string version = 2; - - // Integer octal mode bits to use on this file, must be a value between - // 01 and 0777 (octal). If 0 or not set, the Volume's default mode will be - // used. - // - // Notes - // - // * Internally, a umask of 0222 will be applied to any non-zero value. - // * This is an integer representation of the mode bits. So, the octal - // integer value should look exactly as the chmod numeric notation with a - // leading zero. Some examples: for chmod 777 (a=rwx), set to 0777 (octal) or - // 511 (base-10). For chmod 640 (u=rw,g=r), set to 0640 (octal) or - // 416 (base-10). For chmod 755 (u=rwx,g=rx,o=rx), set to 0755 (octal) or 493 - // (base-10). - // * This might be in conflict with other options that affect the - // file mode, like fsGroup, and the result can be other mode bits set. - int32 mode = 3; -} - -// Represents a specific Cloud SQL instance. -message CloudSqlInstance { - // The Cloud SQL instance connection names, as can be found in - // https://console.cloud.google.com/sql/instances. Visit - // https://cloud.google.com/sql/docs/mysql/connect-run for more information on - // how to connect Cloud SQL and Cloud Run. Format: - // {project}:{location}:{instance} - repeated string instances = 1; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto deleted file mode 100644 index 0cb674e..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision.proto +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/launch_stage.proto"; -import "google/api/resource.proto"; -import "google/api/routing.proto"; -import "google/cloud/run/v2/condition.proto"; -import "google/cloud/run/v2/k8s.min.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "RevisionProto"; -option java_package = "com.google.cloud.run.v2"; - -// Cloud Run Revision Control Plane API. -service Revisions { - option (google.api.default_host) = "run.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Gets information about a Revision. - rpc GetRevision(GetRevisionRequest) returns (Revision) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - } - - // List Revisions from a given Service, or from a given location. - rpc ListRevisions(ListRevisionsRequest) returns (ListRevisionsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*/services/*}/revisions" - }; - option (google.api.routing) = { - routing_parameters { - field: "parent" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Delete a Revision. - rpc DeleteRevision(DeleteRevisionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/services/*/revisions/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Revision" - metadata_type: "Revision" - }; - } -} - -// Request message for obtaining a Revision by its full name. -message GetRevisionRequest { - // Required. The full name of the Revision. - // Format: - // projects/{project}/locations/{location}/services/{service}/revisions/{revision} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - } - ]; -} - -// Request message for retrieving a list of Revisions. -message ListRevisionsRequest { - // Required. The Service from which the Revisions should be listed. - // To list all Revisions across Services, use "-" instead of Service name. - // Format: - // projects/{project}/locations/{location}/services/{service} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "run.googleapis.com/Revision" - } - ]; - - // Maximum number of revisions to return in this call. - int32 page_size = 2; - - // A page token received from a previous call to ListRevisions. - // All other parameters must match. - string page_token = 3; - - // If true, returns deleted (but unexpired) resources along with active ones. - bool show_deleted = 4; -} - -// Response message containing a list of Revisions. -message ListRevisionsResponse { - // The resulting list of Revisions. - repeated Revision revisions = 1; - - // A token indicating there are more items than page_size. Use it in the next - // ListRevisions request to continue. - string next_page_token = 2; -} - -// Request message for deleting a retired Revision. -// Revision lifecycle is usually managed by making changes to the parent -// Service. Only retired revisions can be deleted with this API. -message DeleteRevisionRequest { - // Required. The name of the Revision to delete. - // Format: - // projects/{project}/locations/{location}/services/{service}/revisions/{revision} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - } - ]; - - // Indicates that the request should be validated without actually - // deleting any resources. - bool validate_only = 2; - - // A system-generated fingerprint for this version of the - // resource. This may be used to detect modification conflict during updates. - string etag = 3; -} - -// A Revision is an immutable snapshot of code and configuration. A Revision -// references a container image. Revisions are only created by updates to its -// parent Service. -message Revision { - option (google.api.resource) = { - type: "run.googleapis.com/Revision" - pattern: "projects/{project}/locations/{location}/services/{service}/revisions/{revision}" - style: DECLARATIVE_FRIENDLY - }; - - // Output only. The unique name of this Revision. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server assigned unique identifier for the Revision. The value is a UUID4 - // string and guaranteed to remain unchanged until the resource is deleted. - string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A number that monotonically increases every time the user - // modifies the desired state. - int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // KRM-style labels for the resource. - // User-provided labels are shared with Google's billing system, so they can - // be used to filter, or break down billing charges by team, component, - // environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels - // Cloud Run will populate some labels with 'run.googleapis.com' or - // 'serving.knative.dev' namespaces. Those labels are read-only, and user - // changes will not be preserved. - map labels = 4; - - // KRM-style annotations for the resource. - map annotations = 5; - - // Output only. The creation time. - google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last-modified time. - google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the deletion time. It is only - // populated as a response to a Delete request. - google.protobuf.Timestamp delete_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the time after which it will be - // permamently deleted. It is only populated as a response to a Delete - // request. - google.protobuf.Timestamp expire_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Set the launch stage to a preview stage on write to allow use of preview - // features in that stage. On read, describes whether the resource uses - // preview features. Launch Stages are defined at [Google Cloud Platform - // Launch Stages](https://cloud.google.com/terms/launch-stages). - google.api.LaunchStage launch_stage = 10; - - // Output only. The name of the parent service. - string service = 11 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "run.googleapis.com/Service" - } - ]; - - // Scaling settings for this revision. - RevisionScaling scaling = 12; - - // VPC Access configuration for this Revision. For more information, visit - // https://cloud.google.com/run/docs/configuring/connecting-vpc. - VpcAccess vpc_access = 13; - - // Sets the maximum number of requests that each serving instance can receive. - int32 max_instance_request_concurrency = 34; - - // Max allowed time for an instance to respond to a request. - google.protobuf.Duration timeout = 15; - - // Email address of the IAM service account associated with the revision of - // the service. The service account represents the identity of the running - // revision, and determines what permissions the revision has. - string service_account = 16; - - // Holds the single container that defines the unit of execution for this - // Revision. - repeated Container containers = 17; - - // A list of Volumes to make available to containers. - repeated Volume volumes = 18; - - // The execution environment being used to host this Revision. - ExecutionEnvironment execution_environment = 20; - - // A reference to a customer managed encryption key (CMEK) to use to encrypt - // this container image. For more information, go to - // https://cloud.google.com/run/docs/securing/using-cmek - string encryption_key = 21 [(google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - }]; - - // Output only. Indicates whether the resource's reconciliation is still in progress. - // See comments in `Service.reconciling` for additional information on - // reconciliation process in Cloud Run. - bool reconciling = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Condition of this Revision, containing its readiness status, and - // detailed error information in case it did not reach a serving state. - repeated Condition conditions = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The generation of this Revision currently serving traffic. See comments in - // `reconciling` for additional information on reconciliation process in Cloud - // Run. - int64 observed_generation = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Google Console URI to obtain logs for the Revision. - string log_uri = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto deleted file mode 100644 index f20fb5e..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/revision_template.proto +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/resource.proto"; -import "google/cloud/run/v2/k8s.min.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/protobuf/duration.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "RevisionTemplateProto"; -option java_package = "com.google.cloud.run.v2"; - -// RevisionTemplate describes the data a revision should have when created from -// a template. -message RevisionTemplate { - // The unique name for the revision. If this field is omitted, it will be - // automatically generated based on the Service name. - string revision = 1 [(google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - }]; - - // KRM-style labels for the resource. - map labels = 2; - - // KRM-style annotations for the resource. - map annotations = 3; - - // Scaling settings for this Revision. - RevisionScaling scaling = 4; - - // VPC Access configuration to use for this Revision. For more information, - // visit https://cloud.google.com/run/docs/configuring/connecting-vpc. - VpcAccess vpc_access = 6; - - // Max allowed time for an instance to respond to a request. - google.protobuf.Duration timeout = 8; - - // Email address of the IAM service account associated with the revision of - // the service. The service account represents the identity of the running - // revision, and determines what permissions the revision has. If not - // provided, the revision will use the project's default service account. - string service_account = 9; - - // Holds the single container that defines the unit of execution for this - // Revision. - repeated Container containers = 10; - - // A list of Volumes to make available to containers. - repeated Volume volumes = 11; - - // The sandbox environment to host this Revision. - ExecutionEnvironment execution_environment = 13; - - // A reference to a customer managed encryption key (CMEK) to use to encrypt - // this container image. For more information, go to - // https://cloud.google.com/run/docs/securing/using-cmek - string encryption_key = 14 [(google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - }]; - - // Sets the maximum number of requests that each serving instance can receive. - int32 max_instance_request_concurrency = 15; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto deleted file mode 100644 index 51a29ed..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/service.proto +++ /dev/null @@ -1,435 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/launch_stage.proto"; -import "google/api/resource.proto"; -import "google/api/routing.proto"; -import "google/cloud/run/v2/condition.proto"; -import "google/cloud/run/v2/revision_template.proto"; -import "google/cloud/run/v2/traffic_target.proto"; -import "google/cloud/run/v2/vendor_settings.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "ServiceProto"; -option java_package = "com.google.cloud.run.v2"; - -// Cloud Run Service Control Plane API -service Services { - option (google.api.default_host) = "run.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a new Service in a given project and location. - rpc CreateService(CreateServiceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*}/services" - body: "service" - }; - option (google.api.routing) = { - routing_parameters { - field: "parent" - path_template: "projects/*/locations/{location=*}" - } - }; - option (google.api.method_signature) = "parent,service,service_id"; - option (google.longrunning.operation_info) = { - response_type: "Service" - metadata_type: "Service" - }; - } - - // Gets information about a Service. - rpc GetService(GetServiceRequest) returns (Service) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/services/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - } - - // List Services. - rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*}/services" - }; - option (google.api.routing) = { - routing_parameters { - field: "parent" - path_template: "projects/*/locations/{location=*}" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a Service. - rpc UpdateService(UpdateServiceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v2/{service.name=projects/*/locations/*/services/*}" - body: "service" - }; - option (google.api.routing) = { - routing_parameters { - field: "service.name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "service"; - option (google.longrunning.operation_info) = { - response_type: "Service" - metadata_type: "Service" - }; - } - - // Deletes a Service. - // This will cause the Service to stop serving traffic and will delete all - // revisions. - rpc DeleteService(DeleteServiceRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/services/*}" - }; - option (google.api.routing) = { - routing_parameters { - field: "name" - path_template: "projects/*/locations/{location=*}/**" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Service" - metadata_type: "Service" - }; - } - - // Get the IAM Access Control policy currently in effect for the given - // Cloud Run Service. This result does not include any inherited policies. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - get: "/v2/{resource=projects/*/locations/*/services/*}:getIamPolicy" - }; - } - - // Sets the IAM Access control policy for the specified Service. Overwrites - // any existing policy. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v2/{resource=projects/*/locations/*/services/*}:setIamPolicy" - body: "*" - }; - } - - // Returns permissions that a caller has on the specified Project. - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v2/{resource=projects/*/locations/*/services/*}:testIamPermissions" - body: "*" - }; - } -} - -// Request message for creating a Service. -message CreateServiceRequest { - // Required. The location and project in which this service should be created. - // Format: projects/{projectnumber}/locations/{location} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "run.googleapis.com/Service" - } - ]; - - // Required. The Service instance to create. - Service service = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The unique identifier for the Service. The name of the service becomes - // {parent}/services/{service_id}. - string service_id = 3 [(google.api.field_behavior) = REQUIRED]; - - // Indicates that the request should be validated and default values - // populated, without persisting the request or creating any resources. - bool validate_only = 4; -} - -// Request message for updating a service. -message UpdateServiceRequest { - // Required. The Service to be updated. - Service service = 1 [(google.api.field_behavior) = REQUIRED]; - - // Indicates that the request should be validated and default values - // populated, without persisting the request or updating any resources. - bool validate_only = 3; - - // If set to true, and if the Service does not exist, it will create a new - // one. Caller must have both create and update permissions for this call if - // this is set to true. - bool allow_missing = 4; -} - -// Request message for retrieving a list of Services. -message ListServicesRequest { - // Required. The location and project to list resources on. - // Location must be a valid GCP region, and may not be the "-" wildcard. - // Format: projects/{projectnumber}/locations/{location} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "run.googleapis.com/Service" - } - ]; - - // Maximum number of Services to return in this call. - int32 page_size = 2; - - // A page token received from a previous call to ListServices. - // All other parameters must match. - string page_token = 3; - - // If true, returns deleted (but unexpired) resources along with active ones. - bool show_deleted = 4; -} - -// Response message containing a list of Services. -message ListServicesResponse { - // The resulting list of Services. - repeated Service services = 1; - - // A token indicating there are more items than page_size. Use it in the next - // ListServices request to continue. - string next_page_token = 2; -} - -// Request message for obtaining a Service by its full name. -message GetServiceRequest { - // Required. The full name of the Service. - // Format: projects/{projectnumber}/locations/{location}/services/{service} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "run.googleapis.com/Service" - } - ]; -} - -// Request message to delete a Service by its full name. -message DeleteServiceRequest { - // Required. The full name of the Service. - // Format: projects/{projectnumber}/locations/{location}/services/{service} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "run.googleapis.com/Service" - } - ]; - - // Indicates that the request should be validated without actually - // deleting any resources. - bool validate_only = 2; - - // A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 3; -} - -// Service acts as a top-level container that manages a set of -// configurations and revision templates which implement a network service. -// Service exists to provide a singular abstraction which can be access -// controlled, reasoned about, and which encapsulates software lifecycle -// decisions such as rollout policy and team resource ownership. -message Service { - option (google.api.resource) = { - type: "run.googleapis.com/Service" - pattern: "projects/{project}/locations/{location}/services/{service}" - style: DECLARATIVE_FRIENDLY - }; - - // The fully qualified name of this Service. In CreateServiceRequest, this - // field is ignored, and instead composed from CreateServiceRequest.parent and - // CreateServiceRequest.service_id. - // - // Format: - // projects/{project}/locations/{location}/services/{service_id} - string name = 1; - - // User-provided description of the Service. This field currently has a - // 512-character limit. - string description = 2; - - // Output only. Server assigned unique identifier for the trigger. The value is a UUID4 - // string and guaranteed to remain unchanged until the resource is deleted. - string uid = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A number that monotonically increases every time the user - // modifies the desired state. - // Please note that unlike v1, this is an int64 value. As with most Google - // APIs, its JSON representation will be a `string` instead of an `integer`. - int64 generation = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Map of string keys and values that can be used to organize and categorize - // objects. - // User-provided labels are shared with Google's billing system, so they can - // be used to filter, or break down billing charges by team, component, - // environment, state, etc. For more information, visit - // https://cloud.google.com/resource-manager/docs/creating-managing-labels or - // https://cloud.google.com/run/docs/configuring/labels - // Cloud Run will populate some labels with 'run.googleapis.com' or - // 'serving.knative.dev' namespaces. Those labels are read-only, and user - // changes will not be preserved. - map labels = 5; - - // Unstructured key value map that may be set by external tools to store and - // arbitrary metadata. They are not queryable and should be preserved - // when modifying objects. Cloud Run will populate some annotations using - // 'run.googleapis.com' or 'serving.knative.dev' namespaces. This field - // follows Kubernetes annotations' namespacing, limits, and rules. More info: - // https://kubernetes.io/docs/user-guide/annotations - map annotations = 6; - - // Output only. The creation time. - google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last-modified time. - google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The deletion time. - google.protobuf.Timestamp delete_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For a deleted resource, the time after which it will be - // permamently deleted. - google.protobuf.Timestamp expire_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Email address of the authenticated creator. - string creator = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Email address of the last authenticated modifier. - string last_modifier = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Arbitrary identifier for the API client. - string client = 13; - - // Arbitrary version identifier for the API client. - string client_version = 14; - - // Provides the ingress settings for this Service. On output, returns the - // currently observed ingress settings, or INGRESS_TRAFFIC_UNSPECIFIED if no - // revision is active. - IngressTraffic ingress = 15; - - // The launch stage as defined by [Google Cloud Platform - // Launch Stages](https://cloud.google.com/terms/launch-stages). - // Cloud Run supports `ALPHA`, `BETA`, and `GA`. If no value is specified, GA - // is assumed. - google.api.LaunchStage launch_stage = 16; - - // Settings for the Binary Authorization feature. - BinaryAuthorization binary_authorization = 17; - - // Required. The template used to create revisions for this Service. - RevisionTemplate template = 18 [(google.api.field_behavior) = REQUIRED]; - - // Specifies how to distribute traffic over a collection of Revisions - // belonging to the Service. If traffic is empty or not provided, defaults to - // 100% traffic to the latest `Ready` Revision. - repeated TrafficTarget traffic = 19; - - // Output only. The generation of this Service currently serving traffic. See comments in - // `reconciling` for additional information on reconciliation process in Cloud - // Run. - // Please note that unlike v1, this is an int64 value. As with most Google - // APIs, its JSON representation will be a `string` instead of an `integer`. - int64 observed_generation = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Condition of this Service, containing its readiness status, and - // detailed error information in case it did not reach a serving state. See - // comments in `reconciling` for additional information on reconciliation - // process in Cloud Run. - Condition terminal_condition = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Conditions of all other associated sub-resources. They contain - // additional diagnostics information in case the Service does not reach its - // Serving state. See comments in `reconciling` for additional information on - // reconciliation process in Cloud Run. - repeated Condition conditions = 32 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the latest revision that is serving traffic. See comments in - // `reconciling` for additional information on reconciliation process in Cloud - // Run. - string latest_ready_revision = 33 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - } - ]; - - // Output only. Name of the last created revision. See comments in `reconciling` for - // additional information on reconciliation process in Cloud Run. - string latest_created_revision = 34 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - } - ]; - - // Output only. Detailed status information for corresponding traffic targets. See comments - // in `reconciling` for additional information on reconciliation process in - // Cloud Run. - repeated TrafficTargetStatus traffic_statuses = 35 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The main URI in which this Service is serving traffic. - string uri = 36 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Returns true if the Service is currently being acted upon by the system to - // bring it into the desired state. - // - // When a new Service is created, or an existing one is updated, Cloud Run - // will asynchronously perform all necessary steps to bring the Service to the - // desired serving state. This process is called reconciliation. - // While reconciliation is in process, `observed_generation`, - // `latest_ready_revison`, `traffic_statuses`, and `uri` will have transient - // values that might mismatch the intended state: Once reconciliation is over - // (and this field is false), there are two possible outcomes: reconciliation - // succeeded and the serving state matches the Service, or there was an error, - // and reconciliation failed. This state can be found in - // `terminal_condition.state`. - // - // If reconciliation succeeded, the following fields will match: `traffic` and - // `traffic_statuses`, `observed_generation` and `generation`, - // `latest_ready_revision` and `latest_created_revision`. - // - // If reconciliation failed, `traffic_statuses`, `observed_generation`, and - // `latest_ready_revision` will have the state of the last serving revision, - // or empty for newly created Services. Additional information on the failure - // can be found in `terminal_condition` and `conditions`. - bool reconciling = 98 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A system-generated fingerprint for this version of the - // resource. May be used to detect modification conflict during updates. - string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto deleted file mode 100644 index 18a8c7d..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/traffic_target.proto +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "TrafficTargetProto"; -option java_package = "com.google.cloud.run.v2"; - -// Holds a single traffic routing entry for the Service. Allocations can be done -// to a specific Revision name, or pointing to the latest Ready Revision. -message TrafficTarget { - // The allocation type for this traffic target. - TrafficTargetAllocationType type = 1; - - // Revision to which to send this portion of traffic, if traffic allocation is - // by revision. - string revision = 2 [(google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - }]; - - // Specifies percent of the traffic to this Revision. - // This defaults to zero if unspecified. - int32 percent = 3; - - // Indicates a string to be part of the URI to exclusively reference this - // target. - string tag = 4; -} - -// Represents the observed state of a single `TrafficTarget` entry. -message TrafficTargetStatus { - // The allocation type for this traffic target. - TrafficTargetAllocationType type = 1; - - // Revision to which this traffic is sent. - string revision = 2 [(google.api.resource_reference) = { - type: "run.googleapis.com/Revision" - }]; - - // Specifies percent of the traffic to this Revision. - int32 percent = 3; - - // Indicates the string used in the URI to exclusively reference this target. - string tag = 4; - - // Displays the target URI. - string uri = 5; -} - -// The type of instance allocation. -enum TrafficTargetAllocationType { - // Unspecified instance allocation type. - TRAFFIC_TARGET_ALLOCATION_TYPE_UNSPECIFIED = 0; - - // Allocates instances to the Service's latest ready Revision. - TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST = 1; - - // Allocates instances to a Revision by name. - TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION = 2; -} diff --git a/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto b/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto deleted file mode 100644 index 89748d5..0000000 --- a/owl-bot-staging/v2/protos/google/cloud/run/v2/vendor_settings.proto +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.run.v2; - -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/run/v2;run"; -option java_multiple_files = true; -option java_outer_classname = "VendorSettingsProto"; -option java_package = "com.google.cloud.run.v2"; - -// VPC Access settings. For more information on creating a VPC Connector, visit -// https://cloud.google.com/vpc/docs/configure-serverless-vpc-access For -// information on how to configure Cloud Run with an existing VPC Connector, -// visit https://cloud.google.com/run/docs/configuring/connecting-vpc -message VpcAccess { - // Egress options for VPC access. - enum VpcEgress { - // Unspecified - VPC_EGRESS_UNSPECIFIED = 0; - - // All outbound traffic is routed through the VPC connector. - ALL_TRAFFIC = 1; - - // Only private IP ranges are routed through the VPC connector. - PRIVATE_RANGES_ONLY = 2; - } - - // VPC Access connector name. - // Format: projects/{project}/locations/{location}/connectors/{connector} - string connector = 1 [(google.api.resource_reference) = { - type: "vpcaccess.googleapis.com/Connector" - }]; - - // Traffic VPC egress settings. - VpcEgress egress = 2; -} - -// Settings for Binary Authorization feature. -message BinaryAuthorization { - oneof binauthz_method { - // If True, indicates to use the default project's binary authorization - // policy. If False, binary authorization will be disabled. - bool use_default = 1; - } - - // If present, indicates to use Breakglass using this justification. - // If use_default is False, then it must be empty. - // For more information on breakglass, see - // https://cloud.google.com/binary-authorization/docs/using-breakglass - string breakglass_justification = 2; -} - -// Settings for revision-level scaling settings. -message RevisionScaling { - // Minimum number of serving instances that this resource should have. - int32 min_instance_count = 1; - - // Maximum number of serving instances that this resource should have. - int32 max_instance_count = 2; -} - -// Allowed ingress traffic for the Container. -enum IngressTraffic { - // Unspecified - INGRESS_TRAFFIC_UNSPECIFIED = 0; - - // All inbound traffic is allowed. - INGRESS_TRAFFIC_ALL = 1; - - // Only internal traffic is allowed. - INGRESS_TRAFFIC_INTERNAL_ONLY = 2; - - // Both internal and Google Cloud Load Balancer traffic is allowed. - INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER = 3; -} - -// Alternatives for execution environments. -enum ExecutionEnvironment { - // Unspecified - EXECUTION_ENVIRONMENT_UNSPECIFIED = 0; - - // Uses the First Generation environment. - EXECUTION_ENVIRONMENT_GEN1 = 1; - - // Uses Second Generation environment. - EXECUTION_ENVIRONMENT_GEN2 = 2; -} diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js b/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js deleted file mode 100644 index ab6b399..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/revisions.delete_revision.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START run_v2_generated_Revisions_DeleteRevision_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the Revision to delete. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - */ - // const name = 'abc123' - /** - * Indicates that the request should be validated without actually - * deleting any resources. - */ - // const validateOnly = true - /** - * A system-generated fingerprint for this version of the - * resource. This may be used to detect modification conflict during updates. - */ - // const etag = 'abc123' - - // Imports the Run library - const {RevisionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new RevisionsClient(); - - async function callDeleteRevision() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await runClient.deleteRevision(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteRevision(); - // [END run_v2_generated_Revisions_DeleteRevision_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js b/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js deleted file mode 100644 index 0c67144..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/revisions.get_revision.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START run_v2_generated_Revisions_GetRevision_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Revision. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - */ - // const name = 'abc123' - - // Imports the Run library - const {RevisionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new RevisionsClient(); - - async function callGetRevision() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await runClient.getRevision(request); - console.log(response); - } - - callGetRevision(); - // [END run_v2_generated_Revisions_GetRevision_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js b/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js deleted file mode 100644 index 2263cee..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/revisions.list_revisions.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START run_v2_generated_Revisions_ListRevisions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - */ - // const parent = 'abc123' - /** - * Maximum number of revisions to return in this call. - */ - // const pageSize = 1234 - /** - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - */ - // const pageToken = 'abc123' - /** - * If true, returns deleted (but unexpired) resources along with active ones. - */ - // const showDeleted = true - - // Imports the Run library - const {RevisionsClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new RevisionsClient(); - - async function callListRevisions() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await runClient.listRevisionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRevisions(); - // [END run_v2_generated_Revisions_ListRevisions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.create_service.js b/owl-bot-staging/v2/samples/generated/v2/services.create_service.js deleted file mode 100644 index 7524ecb..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.create_service.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, service, serviceId) { - // [START run_v2_generated_Services_CreateService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location and project in which this service should be created. - * Format: projects/{projectnumber}/locations/{location} - */ - // const parent = 'abc123' - /** - * Required. The Service instance to create. - */ - // const service = {} - /** - * Required. The unique identifier for the Service. The name of the service becomes - * {parent}/services/{service_id}. - */ - // const serviceId = 'abc123' - /** - * Indicates that the request should be validated and default values - * populated, without persisting the request or creating any resources. - */ - // const validateOnly = true - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callCreateService() { - // Construct request - const request = { - parent, - service, - serviceId, - }; - - // Run request - const [operation] = await runClient.createService(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateService(); - // [END run_v2_generated_Services_CreateService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js b/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js deleted file mode 100644 index bcf7ec4..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.delete_service.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START run_v2_generated_Services_DeleteService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Service. - * Format: projects/{projectnumber}/locations/{location}/services/{service} - */ - // const name = 'abc123' - /** - * Indicates that the request should be validated without actually - * deleting any resources. - */ - // const validateOnly = true - /** - * A system-generated fingerprint for this version of the - * resource. May be used to detect modification conflict during updates. - */ - // const etag = 'abc123' - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callDeleteService() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await runClient.deleteService(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteService(); - // [END run_v2_generated_Services_DeleteService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js b/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js deleted file mode 100644 index 52329ca..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.get_iam_policy.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource) { - // [START run_v2_generated_Services_GetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await runClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END run_v2_generated_Services_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.get_service.js b/owl-bot-staging/v2/samples/generated/v2/services.get_service.js deleted file mode 100644 index ffd939c..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.get_service.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START run_v2_generated_Services_GetService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full name of the Service. - * Format: projects/{projectnumber}/locations/{location}/services/{service} - */ - // const name = 'abc123' - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callGetService() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await runClient.getService(request); - console.log(response); - } - - callGetService(); - // [END run_v2_generated_Services_GetService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.list_services.js b/owl-bot-staging/v2/samples/generated/v2/services.list_services.js deleted file mode 100644 index 3daad03..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.list_services.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START run_v2_generated_Services_ListServices_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location and project to list resources on. - * Location must be a valid GCP region, and may not be the "-" wildcard. - * Format: projects/{projectnumber}/locations/{location} - */ - // const parent = 'abc123' - /** - * Maximum number of Services to return in this call. - */ - // const pageSize = 1234 - /** - * A page token received from a previous call to ListServices. - * All other parameters must match. - */ - // const pageToken = 'abc123' - /** - * If true, returns deleted (but unexpired) resources along with active ones. - */ - // const showDeleted = true - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callListServices() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await runClient.listServicesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServices(); - // [END run_v2_generated_Services_ListServices_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js b/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js deleted file mode 100644 index f56b2bd..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.set_iam_policy.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource, policy) { - // [START run_v2_generated_Services_SetIamPolicy_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await runClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END run_v2_generated_Services_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js b/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js deleted file mode 100644 index f7fbd42..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.test_iam_permissions.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource, permissions) { - // [START run_v2_generated_Services_TestIamPermissions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = 'abc123' - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await runClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END run_v2_generated_Services_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/services.update_service.js b/owl-bot-staging/v2/samples/generated/v2/services.update_service.js deleted file mode 100644 index a280ace..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/services.update_service.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(service) { - // [START run_v2_generated_Services_UpdateService_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Service to be updated. - */ - // const service = {} - /** - * Indicates that the request should be validated and default values - * populated, without persisting the request or updating any resources. - */ - // const validateOnly = true - /** - * If set to true, and if the Service does not exist, it will create a new - * one. Caller must have both create and update permissions for this call if - * this is set to true. - */ - // const allowMissing = true - - // Imports the Run library - const {ServicesClient} = require('@google-cloud/run').v2; - - // Instantiates a client - const runClient = new ServicesClient(); - - async function callUpdateService() { - // Construct request - const request = { - service, - }; - - // Run request - const [operation] = await runClient.updateService(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateService(); - // [END run_v2_generated_Services_UpdateService_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json b/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json deleted file mode 100644 index 82e2baf..0000000 --- a/owl-bot-staging/v2/samples/generated/v2/snippet_metadata.google.cloud.run.v2.json +++ /dev/null @@ -1,531 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-run", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.run.v2", - "version": "v2" - } - ] - }, - "snippets": [ - { - "regionTag": "run_v2_generated_Revisions_GetRevision_async", - "title": "Revisions getRevision Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a Revision.", - "canonical": true, - "file": "revisions.get_revision.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetRevision", - "fullName": "google.cloud.run.v2.Revisions.GetRevision", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.run.v2.Revision", - "client": { - "shortName": "RevisionsClient", - "fullName": "google.cloud.run.v2.RevisionsClient" - }, - "method": { - "shortName": "GetRevision", - "fullName": "google.cloud.run.v2.Revisions.GetRevision", - "service": { - "shortName": "Revisions", - "fullName": "google.cloud.run.v2.Revisions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Revisions_ListRevisions_async", - "title": "Revisions listRevisions Sample", - "origin": "API_DEFINITION", - "description": " List Revisions from a given Service, or from a given location.", - "canonical": true, - "file": "revisions.list_revisions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListRevisions", - "fullName": "google.cloud.run.v2.Revisions.ListRevisions", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.run.v2.ListRevisionsResponse", - "client": { - "shortName": "RevisionsClient", - "fullName": "google.cloud.run.v2.RevisionsClient" - }, - "method": { - "shortName": "ListRevisions", - "fullName": "google.cloud.run.v2.Revisions.ListRevisions", - "service": { - "shortName": "Revisions", - "fullName": "google.cloud.run.v2.Revisions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Revisions_DeleteRevision_async", - "title": "Revisions deleteRevision Sample", - "origin": "API_DEFINITION", - "description": " Delete a Revision.", - "canonical": true, - "file": "revisions.delete_revision.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteRevision", - "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "RevisionsClient", - "fullName": "google.cloud.run.v2.RevisionsClient" - }, - "method": { - "shortName": "DeleteRevision", - "fullName": "google.cloud.run.v2.Revisions.DeleteRevision", - "service": { - "shortName": "Revisions", - "fullName": "google.cloud.run.v2.Revisions" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_CreateService_async", - "title": "Revisions createService Sample", - "origin": "API_DEFINITION", - "description": " Creates a new Service in a given project and location.", - "canonical": true, - "file": "services.create_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateService", - "fullName": "google.cloud.run.v2.Services.CreateService", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "service", - "type": ".google.cloud.run.v2.Service" - }, - { - "name": "service_id", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "CreateService", - "fullName": "google.cloud.run.v2.Services.CreateService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_GetService_async", - "title": "Revisions getService Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a Service.", - "canonical": true, - "file": "services.get_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetService", - "fullName": "google.cloud.run.v2.Services.GetService", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.run.v2.Service", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "GetService", - "fullName": "google.cloud.run.v2.Services.GetService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_ListServices_async", - "title": "Revisions listServices Sample", - "origin": "API_DEFINITION", - "description": " List Services.", - "canonical": true, - "file": "services.list_services.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServices", - "fullName": "google.cloud.run.v2.Services.ListServices", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.run.v2.ListServicesResponse", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "ListServices", - "fullName": "google.cloud.run.v2.Services.ListServices", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_UpdateService_async", - "title": "Revisions updateService Sample", - "origin": "API_DEFINITION", - "description": " Updates a Service.", - "canonical": true, - "file": "services.update_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateService", - "fullName": "google.cloud.run.v2.Services.UpdateService", - "async": true, - "parameters": [ - { - "name": "service", - "type": ".google.cloud.run.v2.Service" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "UpdateService", - "fullName": "google.cloud.run.v2.Services.UpdateService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_DeleteService_async", - "title": "Revisions deleteService Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Service. This will cause the Service to stop serving traffic and will delete all revisions.", - "canonical": true, - "file": "services.delete_service.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteService", - "fullName": "google.cloud.run.v2.Services.DeleteService", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "DeleteService", - "fullName": "google.cloud.run.v2.Services.DeleteService", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_GetIamPolicy_async", - "title": "Revisions getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Get the IAM Access Control policy currently in effect for the given Cloud Run Service. This result does not include any inherited policies.", - "canonical": true, - "file": "services.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.run.v2.Services.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.run.v2.Services.GetIamPolicy", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_SetIamPolicy_async", - "title": "Revisions setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the IAM Access control policy for the specified Service. Overwrites any existing policy.", - "canonical": true, - "file": "services.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.run.v2.Services.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.run.v2.Services.SetIamPolicy", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - }, - { - "regionTag": "run_v2_generated_Services_TestIamPermissions_async", - "title": "Revisions testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified Project. There are no permissions required for making this API call.", - "canonical": true, - "file": "services.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.run.v2.Services.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "ServicesClient", - "fullName": "google.cloud.run.v2.ServicesClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.run.v2.Services.TestIamPermissions", - "service": { - "shortName": "Services", - "fullName": "google.cloud.run.v2.Services" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v2/src/index.ts b/owl-bot-staging/v2/src/index.ts deleted file mode 100644 index f7f6340..0000000 --- a/owl-bot-staging/v2/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v2 from './v2'; -const RevisionsClient = v2.RevisionsClient; -type RevisionsClient = v2.RevisionsClient; -const ServicesClient = v2.ServicesClient; -type ServicesClient = v2.ServicesClient; -export {v2, RevisionsClient, ServicesClient}; -export default {v2, RevisionsClient, ServicesClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v2/src/v2/gapic_metadata.json b/owl-bot-staging/v2/src/v2/gapic_metadata.json deleted file mode 100644 index 5990e13..0000000 --- a/owl-bot-staging/v2/src/v2/gapic_metadata.json +++ /dev/null @@ -1,155 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.run.v2", - "libraryPackage": "@google-cloud/run", - "services": { - "Revisions": { - "clients": { - "grpc": { - "libraryClient": "RevisionsClient", - "rpcs": { - "GetRevision": { - "methods": [ - "getRevision" - ] - }, - "DeleteRevision": { - "methods": [ - "deleteRevision" - ] - }, - "ListRevisions": { - "methods": [ - "listRevisions", - "listRevisionsStream", - "listRevisionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RevisionsClient", - "rpcs": { - "GetRevision": { - "methods": [ - "getRevision" - ] - }, - "DeleteRevision": { - "methods": [ - "deleteRevision" - ] - }, - "ListRevisions": { - "methods": [ - "listRevisions", - "listRevisionsStream", - "listRevisionsAsync" - ] - } - } - } - } - }, - "Services": { - "clients": { - "grpc": { - "libraryClient": "ServicesClient", - "rpcs": { - "GetService": { - "methods": [ - "getService" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateService": { - "methods": [ - "createService" - ] - }, - "UpdateService": { - "methods": [ - "updateService" - ] - }, - "DeleteService": { - "methods": [ - "deleteService" - ] - }, - "ListServices": { - "methods": [ - "listServices", - "listServicesStream", - "listServicesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ServicesClient", - "rpcs": { - "GetService": { - "methods": [ - "getService" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateService": { - "methods": [ - "createService" - ] - }, - "UpdateService": { - "methods": [ - "updateService" - ] - }, - "DeleteService": { - "methods": [ - "deleteService" - ] - }, - "ListServices": { - "methods": [ - "listServices", - "listServicesStream", - "listServicesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/index.ts b/owl-bot-staging/v2/src/v2/index.ts deleted file mode 100644 index 5ea97dc..0000000 --- a/owl-bot-staging/v2/src/v2/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {RevisionsClient} from './revisions_client'; -export {ServicesClient} from './services_client'; diff --git a/owl-bot-staging/v2/src/v2/revisions_client.ts b/owl-bot-staging/v2/src/v2/revisions_client.ts deleted file mode 100644 index ecc51b3..0000000 --- a/owl-bot-staging/v2/src/v2/revisions_client.ts +++ /dev/null @@ -1,1016 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/revisions_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './revisions_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Run Revision Control Plane API. - * @class - * @memberof v2 - */ -export class RevisionsClient { - 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}; - operationsClient: gax.OperationsClient; - revisionsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RevisionsClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new RevisionsClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RevisionsClient; - 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; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // 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 = { - cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - revisionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' - ), - }; - - // 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 = { - listRevisions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'revisions') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const deleteRevisionResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Revision') as gax.protobuf.Type; - const deleteRevisionMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Revision') as gax.protobuf.Type; - - this.descriptors.longrunning = { - deleteRevision: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteRevisionResponse.decode.bind(deleteRevisionResponse), - deleteRevisionMetadata.decode.bind(deleteRevisionMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.run.v2.Revisions', 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 = this._gaxModule.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.revisionsStub) { - return this.revisionsStub; - } - - // Put together the "service stub" for - // google.cloud.run.v2.Revisions. - this.revisionsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Revisions') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.run.v2.Revisions, - 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 revisionsStubMethods = - ['getRevision', 'listRevisions', 'deleteRevision']; - for (const methodName of revisionsStubMethods) { - const callPromise = this.revisionsStub.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] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.revisionsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'run.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 'run.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets information about a Revision. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Revision. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - * @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 [Revision]{@link google.cloud.run.v2.Revision}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/revisions.get_revision.js - * region_tag:run_v2_generated_Revisions_GetRevision_async - */ - getRevision( - request?: protos.google.cloud.run.v2.IGetRevisionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|undefined, {}|undefined - ]>; - getRevision( - request: protos.google.cloud.run.v2.IGetRevisionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>): void; - getRevision( - request: protos.google.cloud.run.v2.IGetRevisionRequest, - callback: Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>): void; - getRevision( - request?: protos.google.cloud.run.v2.IGetRevisionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.run.v2.IRevision, - protos.google.cloud.run.v2.IGetRevisionRequest|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.getRevision(request, options, callback); - } - -/** - * Delete a Revision. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Revision to delete. - * Format: - * projects/{project}/locations/{location}/services/{service}/revisions/{revision} - * @param {boolean} request.validateOnly - * Indicates that the request should be validated without actually - * deleting any resources. - * @param {string} request.etag - * A system-generated fingerprint for this version of the - * resource. This may be used to detect modification conflict during updates. - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/revisions.delete_revision.js - * region_tag:run_v2_generated_Revisions_DeleteRevision_async - */ - deleteRevision( - request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteRevision( - request: protos.google.cloud.run.v2.IDeleteRevisionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteRevision( - request: protos.google.cloud.run.v2.IDeleteRevisionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteRevision( - request?: protos.google.cloud.run.v2.IDeleteRevisionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.deleteRevision(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteRevision()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/revisions.delete_revision.js - * region_tag:run_v2_generated_Revisions_DeleteRevision_async - */ - async checkDeleteRevisionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteRevision, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * List Revisions from a given Service, or from a given location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - * @param {number} request.pageSize - * Maximum number of revisions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 [Revision]{@link google.cloud.run.v2.Revision}. - * 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 `listRevisionsAsync()` - * 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. - */ - listRevisions( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IRevision[], - protos.google.cloud.run.v2.IListRevisionsRequest|null, - protos.google.cloud.run.v2.IListRevisionsResponse - ]>; - listRevisions( - request: protos.google.cloud.run.v2.IListRevisionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>): void; - listRevisions( - request: protos.google.cloud.run.v2.IListRevisionsRequest, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>): void; - listRevisions( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>, - callback?: PaginationCallback< - protos.google.cloud.run.v2.IListRevisionsRequest, - protos.google.cloud.run.v2.IListRevisionsResponse|null|undefined, - protos.google.cloud.run.v2.IRevision>): - Promise<[ - protos.google.cloud.run.v2.IRevision[], - protos.google.cloud.run.v2.IListRevisionsRequest|null, - protos.google.cloud.run.v2.IListRevisionsResponse - ]>|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.listRevisions(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 Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - * @param {number} request.pageSize - * Maximum number of revisions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 [Revision]{@link google.cloud.run.v2.Revision} 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 `listRevisionsAsync()` - * 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. - */ - listRevisionsStream( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listRevisions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRevisions.createStream( - this.innerApiCalls.listRevisions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRevisions`, 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 Service from which the Revisions should be listed. - * To list all Revisions across Services, use "-" instead of Service name. - * Format: - * projects/{project}/locations/{location}/services/{service} - * @param {number} request.pageSize - * Maximum number of revisions to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListRevisions. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 - * [Revision]{@link google.cloud.run.v2.Revision}. 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 include:samples/generated/v2/revisions.list_revisions.js - * region_tag:run_v2_generated_Revisions_ListRevisions_async - */ - listRevisionsAsync( - request?: protos.google.cloud.run.v2.IListRevisionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listRevisions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRevisions.asyncIterate( - this.innerApiCalls['listRevisions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified cryptoKey resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} key_ring - * @param {string} crypto_key - * @returns {string} Resource name string. - */ - cryptoKeyPath(project:string,location:string,keyRing:string,cryptoKey:string) { - return this.pathTemplates.cryptoKeyPathTemplate.render({ - project: project, - location: location, - key_ring: keyRing, - crypto_key: cryptoKey, - }); - } - - /** - * Parse the project from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; - } - - /** - * Parse the location from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the location. - */ - matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; - } - - /** - * Parse the key_ring from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the key_ring. - */ - matchKeyRingFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).key_ring; - } - - /** - * Parse the crypto_key from CryptoKey resource. - * - * @param {string} cryptoKeyName - * A fully-qualified path representing CryptoKey resource. - * @returns {string} A string representing the crypto_key. - */ - matchCryptoKeyFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).crypto_key; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).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 revision resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @param {string} revision - * @returns {string} Resource name string. - */ - revisionPath(project:string,location:string,service:string,revision:string) { - return this.pathTemplates.revisionPathTemplate.render({ - project: project, - location: location, - service: service, - revision: revision, - }); - } - - /** - * Parse the project from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).project; - } - - /** - * Parse the location from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).location; - } - - /** - * Parse the service from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the service. - */ - matchServiceFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).service; - } - - /** - * Parse the revision from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the revision. - */ - matchRevisionFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(project:string,location:string,service:string) { - return this.pathTemplates.servicePathTemplate.render({ - project: project, - location: location, - service: service, - }); - } - - /** - * Parse the project from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).project; - } - - /** - * Parse the location from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).location; - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.revisionsStub && !this._terminated) { - return this.revisionsStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/revisions_client_config.json b/owl-bot-staging/v2/src/v2/revisions_client_config.json deleted file mode 100644 index f5a18a2..0000000 --- a/owl-bot-staging/v2/src/v2/revisions_client_config.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "interfaces": { - "google.cloud.run.v2.Revisions": { - "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": { - "GetRevision": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRevisions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteRevision": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/revisions_proto_list.json b/owl-bot-staging/v2/src/v2/revisions_proto_list.json deleted file mode 100644 index 455cae6..0000000 --- a/owl-bot-staging/v2/src/v2/revisions_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/run/v2/condition.proto", - "../../protos/google/cloud/run/v2/k8s.min.proto", - "../../protos/google/cloud/run/v2/revision.proto", - "../../protos/google/cloud/run/v2/revision_template.proto", - "../../protos/google/cloud/run/v2/service.proto", - "../../protos/google/cloud/run/v2/traffic_target.proto", - "../../protos/google/cloud/run/v2/vendor_settings.proto" -] diff --git a/owl-bot-staging/v2/src/v2/services_client.ts b/owl-bot-staging/v2/src/v2/services_client.ts deleted file mode 100644 index 228aaf7..0000000 --- a/owl-bot-staging/v2/src/v2/services_client.ts +++ /dev/null @@ -1,1423 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/services_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './services_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Run Service Control Plane API - * @class - * @memberof v2 - */ -export class ServicesClient { - 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}; - operationsClient: gax.OperationsClient; - servicesStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ServicesClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ServicesClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ServicesClient; - 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; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // 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 = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - revisionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}/revisions/{revision}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/services/{service}' - ), - }; - - // 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 = { - listServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createServiceResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const createServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const updateServiceResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const updateServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const deleteServiceResponse = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - const deleteServiceMetadata = protoFilesRoot.lookup( - '.google.cloud.run.v2.Service') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createService: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createServiceResponse.decode.bind(createServiceResponse), - createServiceMetadata.decode.bind(createServiceMetadata)), - updateService: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateServiceResponse.decode.bind(updateServiceResponse), - updateServiceMetadata.decode.bind(updateServiceMetadata)), - deleteService: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteServiceResponse.decode.bind(deleteServiceResponse), - deleteServiceMetadata.decode.bind(deleteServiceMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.run.v2.Services', 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 = this._gaxModule.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.servicesStub) { - return this.servicesStub; - } - - // Put together the "service stub" for - // google.cloud.run.v2.Services. - this.servicesStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.run.v2.Services') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.run.v2.Services, - 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 servicesStubMethods = - ['createService', 'getService', 'listServices', 'updateService', 'deleteService', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of servicesStubMethods) { - const callPromise = this.servicesStub.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] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.servicesStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'run.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 'run.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets information about a Service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Service. - * Format: projects/{projectnumber}/locations/{location}/services/{service} - * @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 [Service]{@link google.cloud.run.v2.Service}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/services.get_service.js - * region_tag:run_v2_generated_Services_GetService_async - */ - getService( - request?: protos.google.cloud.run.v2.IGetServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|undefined, {}|undefined - ]>; - getService( - request: protos.google.cloud.run.v2.IGetServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; - getService( - request: protos.google.cloud.run.v2.IGetServiceRequest, - callback: Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; - getService( - request?: protos.google.cloud.run.v2.IGetServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.run.v2.IService, - protos.google.cloud.run.v2.IGetServiceRequest|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.getService(request, options, callback); - } -/** - * Get the IAM Access Control policy currently in effect for the given - * Cloud Run Service. This result does not include any inherited policies. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/services.get_iam_policy.js - * region_tag:run_v2_generated_Services_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the IAM Access control policy for the specified Service. Overwrites - * any existing policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/services.set_iam_policy.js - * region_tag:run_v2_generated_Services_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified Project. - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/services.test_iam_permissions.js - * region_tag:run_v2_generated_Services_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Creates a new Service in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project in which this service should be created. - * Format: projects/{projectnumber}/locations/{location} - * @param {google.cloud.run.v2.Service} request.service - * Required. The Service instance to create. - * @param {string} request.serviceId - * Required. The unique identifier for the Service. The name of the service becomes - * {parent}/services/{service_id}. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated and default values - * populated, without persisting the request or creating any resources. - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.create_service.js - * region_tag:run_v2_generated_Services_CreateService_async - */ - createService( - request?: protos.google.cloud.run.v2.ICreateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createService( - request: protos.google.cloud.run.v2.ICreateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createService( - request: protos.google.cloud.run.v2.ICreateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createService( - request?: protos.google.cloud.run.v2.ICreateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.createService(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createService()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.create_service.js - * region_tag:run_v2_generated_Services_CreateService_async - */ - async checkCreateServiceProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a Service. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.run.v2.Service} request.service - * Required. The Service to be updated. - * @param {boolean} request.validateOnly - * Indicates that the request should be validated and default values - * populated, without persisting the request or updating any resources. - * @param {boolean} request.allowMissing - * If set to true, and if the Service does not exist, it will create a new - * one. Caller must have both create and update permissions for this call if - * this is set to true. - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.update_service.js - * region_tag:run_v2_generated_Services_UpdateService_async - */ - updateService( - request?: protos.google.cloud.run.v2.IUpdateServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateService( - request: protos.google.cloud.run.v2.IUpdateServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateService( - request: protos.google.cloud.run.v2.IUpdateServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateService( - request?: protos.google.cloud.run.v2.IUpdateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.service?.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.updateService(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateService()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.update_service.js - * region_tag:run_v2_generated_Services_UpdateService_async - */ - async checkUpdateServiceProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a Service. - * This will cause the Service to stop serving traffic and will delete all - * revisions. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of the Service. - * Format: projects/{projectnumber}/locations/{location}/services/{service} - * @param {boolean} request.validateOnly - * Indicates that the request should be validated without actually - * deleting any resources. - * @param {string} request.etag - * A system-generated fingerprint for this version of the - * resource. May be used to detect modification conflict during updates. - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.delete_service.js - * region_tag:run_v2_generated_Services_DeleteService_async - */ - deleteService( - request?: protos.google.cloud.run.v2.IDeleteServiceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteService( - request: protos.google.cloud.run.v2.IDeleteServiceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteService( - request: protos.google.cloud.run.v2.IDeleteServiceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteService( - request?: protos.google.cloud.run.v2.IDeleteServiceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.name; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)(?:/.*)?')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.deleteService(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteService()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/services.delete_service.js - * region_tag:run_v2_generated_Services_DeleteService_async - */ - async checkDeleteServiceProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteService, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * List Services. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location and project to list resources on. - * Location must be a valid GCP region, and may not be the "-" wildcard. - * Format: projects/{projectnumber}/locations/{location} - * @param {number} request.pageSize - * Maximum number of Services to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListServices. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 [Service]{@link google.cloud.run.v2.Service}. - * 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 `listServicesAsync()` - * 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. - */ - listServices( - request?: protos.google.cloud.run.v2.IListServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.run.v2.IService[], - protos.google.cloud.run.v2.IListServicesRequest|null, - protos.google.cloud.run.v2.IListServicesResponse - ]>; - listServices( - request: protos.google.cloud.run.v2.IListServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>): void; - listServices( - request: protos.google.cloud.run.v2.IListServicesRequest, - callback: PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>): void; - listServices( - request?: protos.google.cloud.run.v2.IListServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>, - callback?: PaginationCallback< - protos.google.cloud.run.v2.IListServicesRequest, - protos.google.cloud.run.v2.IListServicesResponse|null|undefined, - protos.google.cloud.run.v2.IService>): - Promise<[ - protos.google.cloud.run.v2.IService[], - protos.google.cloud.run.v2.IListServicesRequest|null, - protos.google.cloud.run.v2.IListServicesResponse - ]>|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 || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - this.initialize(); - return this.innerApiCalls.listServices(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 location and project to list resources on. - * Location must be a valid GCP region, and may not be the "-" wildcard. - * Format: projects/{projectnumber}/locations/{location} - * @param {number} request.pageSize - * Maximum number of Services to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListServices. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 [Service]{@link google.cloud.run.v2.Service} 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 `listServicesAsync()` - * 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. - */ - listServicesStream( - request?: protos.google.cloud.run.v2.IListServicesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listServices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServices.createStream( - this.innerApiCalls.listServices as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServices`, 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 location and project to list resources on. - * Location must be a valid GCP region, and may not be the "-" wildcard. - * Format: projects/{projectnumber}/locations/{location} - * @param {number} request.pageSize - * Maximum number of Services to return in this call. - * @param {string} request.pageToken - * A page token received from a previous call to ListServices. - * All other parameters must match. - * @param {boolean} request.showDeleted - * If true, returns deleted (but unexpired) resources along with active ones. - * @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 - * [Service]{@link google.cloud.run.v2.Service}. 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 include:samples/generated/v2/services.list_services.js - * region_tag:run_v2_generated_Services_ListServices_async - */ - listServicesAsync( - request?: protos.google.cloud.run.v2.IListServicesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - let routingParameter = {}; - { - const fieldValue = request.parent; - if (fieldValue !== undefined && fieldValue !== null) { - const match = fieldValue.toString().match(RegExp('projects/[^/]+/locations/(?[^/]+)')); - if (match) { - const parameterValue = match.groups?.['location'] ?? fieldValue; - Object.assign(routingParameter, { location: parameterValue }); - } - } - } - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams( - routingParameter - ); - const defaultCallSettings = this._defaults['listServices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServices.asyncIterate( - this.innerApiCalls['listServices'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).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 revision resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @param {string} revision - * @returns {string} Resource name string. - */ - revisionPath(project:string,location:string,service:string,revision:string) { - return this.pathTemplates.revisionPathTemplate.render({ - project: project, - location: location, - service: service, - revision: revision, - }); - } - - /** - * Parse the project from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).project; - } - - /** - * Parse the location from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).location; - } - - /** - * Parse the service from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the service. - */ - matchServiceFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).service; - } - - /** - * Parse the revision from Revision resource. - * - * @param {string} revisionName - * A fully-qualified path representing Revision resource. - * @returns {string} A string representing the revision. - */ - matchRevisionFromRevisionName(revisionName: string) { - return this.pathTemplates.revisionPathTemplate.match(revisionName).revision; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(project:string,location:string,service:string) { - return this.pathTemplates.servicePathTemplate.render({ - project: project, - location: location, - service: service, - }); - } - - /** - * Parse the project from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the project. - */ - matchProjectFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).project; - } - - /** - * Parse the location from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the location. - */ - matchLocationFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).location; - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.servicesStub && !this._terminated) { - return this.servicesStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v2/src/v2/services_client_config.json b/owl-bot-staging/v2/src/v2/services_client_config.json deleted file mode 100644 index d9a3364..0000000 --- a/owl-bot-staging/v2/src/v2/services_client_config.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "interfaces": { - "google.cloud.run.v2.Services": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateService": { - "timeout_millis": 15000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetService": { - "timeout_millis": 10000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListServices": { - "timeout_millis": 10000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateService": { - "timeout_millis": 15000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteService": { - "timeout_millis": 10000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v2/src/v2/services_proto_list.json b/owl-bot-staging/v2/src/v2/services_proto_list.json deleted file mode 100644 index 455cae6..0000000 --- a/owl-bot-staging/v2/src/v2/services_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/run/v2/condition.proto", - "../../protos/google/cloud/run/v2/k8s.min.proto", - "../../protos/google/cloud/run/v2/revision.proto", - "../../protos/google/cloud/run/v2/revision_template.proto", - "../../protos/google/cloud/run/v2/service.proto", - "../../protos/google/cloud/run/v2/traffic_target.proto", - "../../protos/google/cloud/run/v2/vendor_settings.proto" -] diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 01b536f..0000000 --- a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const run = require('@google-cloud/run'); - -function main() { - const revisionsClient = new run.RevisionsClient(); - const servicesClient = new run.ServicesClient(); -} - -main(); diff --git a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 769c1b4..0000000 --- a/owl-bot-staging/v2/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {RevisionsClient, ServicesClient} from '@google-cloud/run'; - -// check that the client class type name can be used -function doStuffWithRevisionsClient(client: RevisionsClient) { - client.close(); -} -function doStuffWithServicesClient(client: ServicesClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const revisionsClient = new RevisionsClient(); - doStuffWithRevisionsClient(revisionsClient); - // check that the client instance can be created - const servicesClient = new ServicesClient(); - doStuffWithServicesClient(servicesClient); -} - -main(); diff --git a/owl-bot-staging/v2/system-test/install.ts b/owl-bot-staging/v2/system-test/install.ts deleted file mode 100644 index 557a575..0000000 --- a/owl-bot-staging/v2/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v2/test/gapic_revisions_v2.ts b/owl-bot-staging/v2/test/gapic_revisions_v2.ts deleted file mode 100644 index 4b4fb53..0000000 --- a/owl-bot-staging/v2/test/gapic_revisions_v2.ts +++ /dev/null @@ -1,932 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as revisionsModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -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('v2.RevisionsClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = revisionsModule.v2.RevisionsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = revisionsModule.v2.RevisionsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = revisionsModule.v2.RevisionsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new revisionsModule.v2.RevisionsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new revisionsModule.v2.RevisionsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.revisionsStub, undefined); - await client.initialize(); - assert(client.revisionsStub); - }); - - it('has close method for the initialized client', done => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.revisionsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.revisionsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new revisionsModule.v2.RevisionsClient({ - 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 revisionsModule.v2.RevisionsClient({ - 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('getRevision', () => { - it('invokes getRevision without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Revision()); - client.innerApiCalls.getRevision = stubSimpleCall(expectedResponse); - const [response] = await client.getRevision(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getRevision without error using callback', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Revision()); - client.innerApiCalls.getRevision = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRevision( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getRevision with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getRevision = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRevision(request), expectedError); - assert((client.innerApiCalls.getRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getRevision with closed client', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetRevisionRequest()); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getRevision(request), expectedError); - }); - }); - - describe('deleteRevision', () => { - it('invokes deleteRevision without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteRevision = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteRevision(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteRevision without error using callback', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteRevision = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteRevision( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteRevision with call error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteRevision(request), expectedError); - assert((client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteRevision with LRO error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteRevisionRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRevision = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteRevision(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteRevision as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteRevisionProgress without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteRevisionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteRevisionProgress with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteRevisionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listRevisions', () => { - it('invokes listRevisions without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.innerApiCalls.listRevisions = stubSimpleCall(expectedResponse); - const [response] = await client.listRevisions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listRevisions without error using callback', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.innerApiCalls.listRevisions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRevisions( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IRevision[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listRevisions with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listRevisions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRevisions(request), expectedError); - assert((client.innerApiCalls.listRevisions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listRevisionsStream without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRevisionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Revision[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { - 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.listRevisions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); - assert.strictEqual( - (client.descriptors.page.listRevisions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listRevisionsStream with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedError = new Error('expected'); - client.descriptors.page.listRevisions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRevisionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Revision[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Revision) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRevisions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRevisions, request)); - assert.strictEqual( - (client.descriptors.page.listRevisions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listRevisions without error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - generateSampleMessage(new protos.google.cloud.run.v2.Revision()), - ]; - client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.run.v2.IRevision[] = []; - const iterable = client.listRevisionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listRevisions with error', async () => { - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListRevisionsRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.parent = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&');const expectedError = new Error('expected'); - client.descriptors.page.listRevisions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRevisionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.run.v2.IRevision[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listRevisions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('cryptoKey', () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.cryptoKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.cryptoKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('cryptoKeyPath', () => { - const result = client.cryptoKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.cryptoKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCryptoKeyName', () => { - const result = client.matchProjectFromCryptoKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCryptoKeyName', () => { - const result = client.matchLocationFromCryptoKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromCryptoKeyName', () => { - const result = client.matchKeyRingFromCryptoKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromCryptoKeyName', () => { - const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - 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('revision', () => { - const fakePath = "/rendered/path/revision"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - revision: "revisionValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.revisionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.revisionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('revisionPath', () => { - const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRevisionName', () => { - const result = client.matchProjectFromRevisionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRevisionName', () => { - const result = client.matchLocationFromRevisionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromRevisionName', () => { - const result = client.matchServiceFromRevisionName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRevisionFromRevisionName', () => { - const result = client.matchRevisionFromRevisionName(fakePath); - assert.strictEqual(result, "revisionValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new revisionsModule.v2.RevisionsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/test/gapic_services_v2.ts b/owl-bot-staging/v2/test/gapic_services_v2.ts deleted file mode 100644 index 3ec3f34..0000000 --- a/owl-bot-staging/v2/test/gapic_services_v2.ts +++ /dev/null @@ -1,1485 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as servicesModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -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('v2.ServicesClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = servicesModule.v2.ServicesClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = servicesModule.v2.ServicesClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = servicesModule.v2.ServicesClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new servicesModule.v2.ServicesClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new servicesModule.v2.ServicesClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servicesStub, undefined); - await client.initialize(); - assert(client.servicesStub); - }); - - it('has close method for the initialized client', done => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.servicesStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.servicesStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servicesModule.v2.ServicesClient({ - 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 servicesModule.v2.ServicesClient({ - 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('getService', () => { - it('invokes getService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Service()); - client.innerApiCalls.getService = stubSimpleCall(expectedResponse); - const [response] = await client.getService(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.run.v2.Service()); - client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getService( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getService as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getService with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getService = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getService(request), expectedError); - assert((client.innerApiCalls.getService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getService with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.GetServiceRequest()); - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getService(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createService', () => { - it('invokes createService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createService = stubLongRunningCall(expectedResponse); - const [operation] = await client.createService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createService as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createService with call error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createService(request), expectedError); - assert((client.innerApiCalls.createService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createService with LRO error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.CreateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createService(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateServiceProgress without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateServiceProgress with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateService', () => { - it('invokes updateService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateService = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateService as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateService with call error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateService(request), expectedError); - assert((client.innerApiCalls.updateService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateService with LRO error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.UpdateServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - request.service = {}; - // path template: projects/*/locations/{location=*}/** - request.service.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateService(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateServiceProgress without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateServiceProgress with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteService', () => { - it('invokes deleteService without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteService = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteService(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteService without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteService = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteService( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteService as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteService with call error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteService(request), expectedError); - assert((client.innerApiCalls.deleteService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteService with LRO error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.DeleteServiceRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*}/** - request.name = 'projects/value/locations/value/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteService(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteService as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteServiceProgress without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteServiceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteServiceProgress with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteServiceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listServices', () => { - it('invokes listServices without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); - const [response] = await client.listServices(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServices as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServices without error using callback', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServices( - request, - (err?: Error|null, result?: protos.google.cloud.run.v2.IService[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listServices as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listServices with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServices(request), expectedError); - assert((client.innerApiCalls.listServices as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listServicesStream without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Service[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Service) => { - 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.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert.strictEqual( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listServicesStream with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedError = new Error('expected'); - client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.run.v2.Service[] = []; - stream.on('data', (response: protos.google.cloud.run.v2.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert.strictEqual( - (client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServices without error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&'); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - generateSampleMessage(new protos.google.cloud.run.v2.Service()), - ]; - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.run.v2.IService[] = []; - const iterable = client.listServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listServices with error', async () => { - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.run.v2.ListServicesRequest()); - const expectedHeaderRequestParamsObj: {[key: string]: string} = {}; - // path template: projects/*/locations/{location=*} - request.parent = 'projects/value/locations/value'; - expectedHeaderRequestParamsObj['location'] = 'value'; - const expectedHeaderRequestParams = Object.entries(expectedHeaderRequestParamsObj).map(([key, value]) => `${key}=${value}`).join('&');const expectedError = new Error('expected'); - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.run.v2.IService[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new servicesModule.v2.ServicesClient({ - 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('revision', () => { - const fakePath = "/rendered/path/revision"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - revision: "revisionValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.revisionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.revisionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('revisionPath', () => { - const result = client.revisionPath("projectValue", "locationValue", "serviceValue", "revisionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.revisionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRevisionName', () => { - const result = client.matchProjectFromRevisionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRevisionName', () => { - const result = client.matchLocationFromRevisionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromRevisionName', () => { - const result = client.matchServiceFromRevisionName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRevisionFromRevisionName', () => { - const result = client.matchRevisionFromRevisionName(fakePath); - assert.strictEqual(result, "revisionValue"); - assert((client.pathTemplates.revisionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - service: "serviceValue", - }; - const client = new servicesModule.v2.ServicesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("projectValue", "locationValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromServiceName', () => { - const result = client.matchLocationFromServiceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v2/tsconfig.json b/owl-bot-staging/v2/tsconfig.json deleted file mode 100644 index c78f1c8..0000000 --- a/owl-bot-staging/v2/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v2/webpack.config.js b/owl-bot-staging/v2/webpack.config.js deleted file mode 100644 index 36eeb4b..0000000 --- a/owl-bot-staging/v2/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Revisions', - filename: './revisions.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', -};