From 285b66ec32680ec56b2181220e4b44ff749446d0 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 2 Mar 2023 14:50:05 +0000 Subject: [PATCH 1/2] feat: Adding new fields for Serverless analytics PiperOrigin-RevId: 513499163 Source-Link: https://github.com/googleapis/googleapis/commit/c3ffffa624534dd6431db695245f374d552e973d Source-Link: https://github.com/googleapis/googleapis-gen/commit/3e262dc86a9e73ea0b6cfd7d19ac7685ac34a0e5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiM2UyNjJkYzg2YTllNzNlYTBiNmNmZDdkMTlhYzc2ODVhYzM0YTBlNSJ9 --- .../admin/database/v1/.eslintignore | 7 + .../admin/database/v1/.eslintrc.json | 3 + owl-bot-staging/admin/database/v1/.gitignore | 14 + owl-bot-staging/admin/database/v1/.jsdoc.js | 55 + owl-bot-staging/admin/database/v1/.mocharc.js | 33 + .../admin/database/v1/.prettierrc.js | 22 + owl-bot-staging/admin/database/v1/README.md | 1 + .../admin/database/v1/linkinator.config.json | 16 + .../admin/database/v1/package.json | 64 + .../spanner/admin/database/v1/backup.proto | 609 +++ .../spanner/admin/database/v1/common.proto | 112 + .../database/v1/spanner_database_admin.proto | 930 +++++ .../admin/database/v1/src/index.ts | 25 + .../v1/src/v1/database_admin_client.ts | 3557 ++++++++++++++++ .../src/v1/database_admin_client_config.json | 130 + .../v1/src/v1/database_admin_proto_list.json | 5 + .../database/v1/src/v1/gapic_metadata.json | 233 ++ .../admin/database/v1/src/v1/index.ts | 19 + .../v1/test/gapic_database_admin_v1.ts | 3680 +++++++++++++++++ .../admin/database/v1/tsconfig.json | 19 + .../admin/database/v1/webpack.config.js | 64 + .../admin/instance/v1/.eslintignore | 7 + .../admin/instance/v1/.eslintrc.json | 3 + owl-bot-staging/admin/instance/v1/.gitignore | 14 + owl-bot-staging/admin/instance/v1/.jsdoc.js | 55 + owl-bot-staging/admin/instance/v1/.mocharc.js | 33 + .../admin/instance/v1/.prettierrc.js | 22 + owl-bot-staging/admin/instance/v1/README.md | 1 + .../admin/instance/v1/linkinator.config.json | 16 + .../admin/instance/v1/package.json | 64 + .../spanner/admin/instance/v1/common.proto | 42 + .../instance/v1/spanner_instance_admin.proto | 1081 +++++ .../admin/instance/v1/src/index.ts | 25 + .../instance/v1/src/v1/gapic_metadata.json | 175 + .../admin/instance/v1/src/v1/index.ts | 19 + .../v1/src/v1/instance_admin_client.ts | 2419 +++++++++++ .../src/v1/instance_admin_client_config.json | 101 + .../v1/src/v1/instance_admin_proto_list.json | 4 + .../v1/test/gapic_instance_admin_v1.ts | 2437 +++++++++++ .../admin/instance/v1/tsconfig.json | 19 + .../admin/instance/v1/webpack.config.js | 64 + owl-bot-staging/v1/.eslintignore | 7 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 16 + owl-bot-staging/v1/package.json | 64 + .../google/spanner/v1/commit_response.proto | 50 + .../v1/protos/google/spanner/v1/keys.proto | 163 + .../protos/google/spanner/v1/mutation.proto | 107 + .../protos/google/spanner/v1/query_plan.proto | 128 + .../protos/google/spanner/v1/result_set.proto | 216 + .../v1/protos/google/spanner/v1/spanner.proto | 1042 +++++ .../google/spanner/v1/transaction.proto | 525 +++ .../v1/protos/google/spanner/v1/type.proto | 174 + owl-bot-staging/v1/src/index.ts | 25 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 167 + owl-bot-staging/v1/src/v1/index.ts | 19 + owl-bot-staging/v1/src/v1/spanner_client.ts | 2047 +++++++++ .../v1/src/v1/spanner_client_config.json | 113 + .../v1/src/v1/spanner_proto_list.json | 10 + owl-bot-staging/v1/test/gapic_spanner_v1.ts | 2047 +++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + 67 files changed, 23330 insertions(+) create mode 100644 owl-bot-staging/admin/database/v1/.eslintignore create mode 100644 owl-bot-staging/admin/database/v1/.eslintrc.json create mode 100644 owl-bot-staging/admin/database/v1/.gitignore create mode 100644 owl-bot-staging/admin/database/v1/.jsdoc.js create mode 100644 owl-bot-staging/admin/database/v1/.mocharc.js create mode 100644 owl-bot-staging/admin/database/v1/.prettierrc.js create mode 100644 owl-bot-staging/admin/database/v1/README.md create mode 100644 owl-bot-staging/admin/database/v1/linkinator.config.json create mode 100644 owl-bot-staging/admin/database/v1/package.json create mode 100644 owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/backup.proto create mode 100644 owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/common.proto create mode 100644 owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/spanner_database_admin.proto create mode 100644 owl-bot-staging/admin/database/v1/src/index.ts create mode 100644 owl-bot-staging/admin/database/v1/src/v1/database_admin_client.ts create mode 100644 owl-bot-staging/admin/database/v1/src/v1/database_admin_client_config.json create mode 100644 owl-bot-staging/admin/database/v1/src/v1/database_admin_proto_list.json create mode 100644 owl-bot-staging/admin/database/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/admin/database/v1/src/v1/index.ts create mode 100644 owl-bot-staging/admin/database/v1/test/gapic_database_admin_v1.ts create mode 100644 owl-bot-staging/admin/database/v1/tsconfig.json create mode 100644 owl-bot-staging/admin/database/v1/webpack.config.js create mode 100644 owl-bot-staging/admin/instance/v1/.eslintignore create mode 100644 owl-bot-staging/admin/instance/v1/.eslintrc.json create mode 100644 owl-bot-staging/admin/instance/v1/.gitignore create mode 100644 owl-bot-staging/admin/instance/v1/.jsdoc.js create mode 100644 owl-bot-staging/admin/instance/v1/.mocharc.js create mode 100644 owl-bot-staging/admin/instance/v1/.prettierrc.js create mode 100644 owl-bot-staging/admin/instance/v1/README.md create mode 100644 owl-bot-staging/admin/instance/v1/linkinator.config.json create mode 100644 owl-bot-staging/admin/instance/v1/package.json create mode 100644 owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/common.proto create mode 100644 owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto create mode 100644 owl-bot-staging/admin/instance/v1/src/index.ts create mode 100644 owl-bot-staging/admin/instance/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/admin/instance/v1/src/v1/index.ts create mode 100644 owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client.ts create mode 100644 owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client_config.json create mode 100644 owl-bot-staging/admin/instance/v1/src/v1/instance_admin_proto_list.json create mode 100644 owl-bot-staging/admin/instance/v1/test/gapic_instance_admin_v1.ts create mode 100644 owl-bot-staging/admin/instance/v1/tsconfig.json create mode 100644 owl-bot-staging/admin/instance/v1/webpack.config.js create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/commit_response.proto create mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/keys.proto create mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/mutation.proto create mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/query_plan.proto create mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/result_set.proto create mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/spanner.proto create mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/transaction.proto create mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/type.proto create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/src/v1/spanner_client.ts create mode 100644 owl-bot-staging/v1/src/v1/spanner_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/spanner_proto_list.json create mode 100644 owl-bot-staging/v1/test/gapic_spanner_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js diff --git a/owl-bot-staging/admin/database/v1/.eslintignore b/owl-bot-staging/admin/database/v1/.eslintignore new file mode 100644 index 000000000..cfc348ec4 --- /dev/null +++ b/owl-bot-staging/admin/database/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/admin/database/v1/.eslintrc.json b/owl-bot-staging/admin/database/v1/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/admin/database/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/admin/database/v1/.gitignore b/owl-bot-staging/admin/database/v1/.gitignore new file mode 100644 index 000000000..d4f03a0df --- /dev/null +++ b/owl-bot-staging/admin/database/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/admin/database/v1/.jsdoc.js b/owl-bot-staging/admin/database/v1/.jsdoc.js new file mode 100644 index 000000000..e37e0473a --- /dev/null +++ b/owl-bot-staging/admin/database/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/spanner', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/admin/database/v1/.mocharc.js b/owl-bot-staging/admin/database/v1/.mocharc.js new file mode 100644 index 000000000..1a38f257d --- /dev/null +++ b/owl-bot-staging/admin/database/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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/admin/database/v1/.prettierrc.js b/owl-bot-staging/admin/database/v1/.prettierrc.js new file mode 100644 index 000000000..55639e70f --- /dev/null +++ b/owl-bot-staging/admin/database/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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/admin/database/v1/README.md b/owl-bot-staging/admin/database/v1/README.md new file mode 100644 index 000000000..c258fda43 --- /dev/null +++ b/owl-bot-staging/admin/database/v1/README.md @@ -0,0 +1 @@ +Database: Nodejs Client diff --git a/owl-bot-staging/admin/database/v1/linkinator.config.json b/owl-bot-staging/admin/database/v1/linkinator.config.json new file mode 100644 index 000000000..befd23c86 --- /dev/null +++ b/owl-bot-staging/admin/database/v1/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/admin/database/v1/package.json b/owl-bot-staging/admin/database/v1/package.json new file mode 100644 index 000000000..c95291c19 --- /dev/null +++ b/owl-bot-staging/admin/database/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/spanner", + "version": "0.1.0", + "description": "Database client for Node.js", + "repository": "googleapis/nodejs-database", + "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 database", + "database", + "database admin" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "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.5.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/backup.proto b/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/backup.proto new file mode 100644 index 000000000..5e019543e --- /dev/null +++ b/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/backup.proto @@ -0,0 +1,609 @@ +// 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.spanner.admin.database.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/spanner/admin/database/v1/common.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database"; +option java_multiple_files = true; +option java_outer_classname = "BackupProto"; +option java_package = "com.google.spanner.admin.database.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1"; + +// A backup of a Cloud Spanner database. +message Backup { + option (google.api.resource) = { + type: "spanner.googleapis.com/Backup" + pattern: "projects/{project}/instances/{instance}/backups/{backup}" + }; + + // Indicates the current state of the backup. + enum State { + // Not specified. + STATE_UNSPECIFIED = 0; + + // The pending backup is still being created. Operations on the + // backup may fail with `FAILED_PRECONDITION` in this state. + CREATING = 1; + + // The backup is complete and ready for use. + READY = 2; + } + + // Required for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation. + // Name of the database from which this backup was + // created. This needs to be in the same instance as the backup. + // Values are of the form + // `projects//instances//databases/`. + string database = 2 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + }]; + + // The backup will contain an externally consistent copy of the database at + // the timestamp specified by `version_time`. If `version_time` is not + // specified, the system will set `version_time` to the `create_time` of the + // backup. + google.protobuf.Timestamp version_time = 9; + + // Required for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + // operation. The expiration time of the backup, with microseconds + // granularity that must be at least 6 hours and at most 366 days + // from the time the CreateBackup request is processed. Once the `expire_time` + // has passed, the backup is eligible to be automatically deleted by Cloud + // Spanner to free the resources used by the backup. + google.protobuf.Timestamp expire_time = 3; + + // Output only for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation. + // Required for the [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup] operation. + // + // A globally unique identifier for the backup which cannot be + // changed. Values are of the form + // `projects//instances//backups/[a-z][a-z0-9_\-]*[a-z0-9]` + // The final segment of the name must be between 2 and 60 characters + // in length. + // + // The backup is stored in the location(s) specified in the instance + // configuration of the instance containing the backup, identified + // by the prefix of the backup name of the form + // `projects//instances/`. + string name = 1; + + // Output only. The time the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + // request is received. If the request does not specify `version_time`, the + // `version_time` of the backup will be equivalent to the `create_time`. + google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Size of the backup in bytes. + int64 size_bytes = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current state of the backup. + State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The names of the restored databases that reference the backup. + // The database names are of + // the form `projects//instances//databases/`. + // Referencing databases may exist in different instances. The existence of + // any referencing database prevents the backup from being deleted. When a + // restored database from the backup enters the `READY` state, the reference + // to the backup is removed. + repeated string referencing_databases = 7 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; + + // Output only. The encryption information for the backup. + EncryptionInfo encryption_info = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The database dialect information for the backup. + DatabaseDialect database_dialect = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The names of the destination backups being created by copying + // this source backup. The backup names are of the form + // `projects//instances//backups/`. + // Referencing backups may exist in different instances. The existence of + // any referencing backup prevents the backup from being deleted. When the + // copy operation is done (either successfully completed or cancelled or the + // destination backup is deleted), the reference to the backup is removed. + repeated string referencing_backups = 11 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + } + ]; + + // Output only. The max allowed expiration time of the backup, with + // microseconds granularity. A backup's expiration time can be configured in + // multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or + // copying an existing backup, the expiration time specified must be + // less than `Backup.max_expire_time`. + google.protobuf.Timestamp max_expire_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The request for [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]. +message CreateBackupRequest { + // Required. The name of the instance in which the backup will be + // created. This must be the same instance that contains the database the + // backup will be created from. The backup will be stored in the + // location(s) specified in the instance configuration of this + // instance. Values are of the form + // `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // Required. The id of the backup to be created. The `backup_id` appended to + // `parent` forms the full backup name of the form + // `projects//instances//backups/`. + string backup_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The backup to create. + Backup backup = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The encryption configuration used to encrypt the backup. If this field is + // not specified, the backup will use the same + // encryption configuration as the database by default, namely + // [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] = + // `USE_DATABASE_ENCRYPTION`. + CreateBackupEncryptionConfig encryption_config = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Metadata type for the operation returned by +// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]. +message CreateBackupMetadata { + // The name of the backup being created. + string name = 1 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + }]; + + // The name of the database the backup is created from. + string database = 2 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + }]; + + // The progress of the + // [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation. + OperationProgress progress = 3; + + // The time at which cancellation of this operation was received. + // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + // starts asynchronous cancellation on a long-running operation. The server + // makes a best effort to cancel the operation, but success is not guaranteed. + // Clients can use + // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + // other methods to check whether the cancellation succeeded or whether the + // operation completed despite cancellation. On successful cancellation, + // the operation is not deleted; instead, it becomes an operation with + // an [Operation.error][google.longrunning.Operation.error] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of 1, + // corresponding to `Code.CANCELLED`. + google.protobuf.Timestamp cancel_time = 4; +} + +// The request for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]. +message CopyBackupRequest { + // Required. The name of the destination instance that will contain the backup copy. + // Values are of the form: `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // Required. The id of the backup copy. + // The `backup_id` appended to `parent` forms the full backup_uri of the form + // `projects//instances//backups/`. + string backup_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The source backup to be copied. + // The source backup needs to be in READY state for it to be copied. + // Once CopyBackup is in progress, the source backup cannot be deleted or + // cleaned up on expiration until CopyBackup is finished. + // Values are of the form: + // `projects//instances//backups/`. + string source_backup = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + } + ]; + + // Required. The expiration time of the backup in microsecond granularity. + // The expiration time must be at least 6 hours and at most 366 days + // from the `create_time` of the source backup. Once the `expire_time` has + // passed, the backup is eligible to be automatically deleted by Cloud Spanner + // to free the resources used by the backup. + google.protobuf.Timestamp expire_time = 4 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The encryption configuration used to encrypt the backup. If this field is + // not specified, the backup will use the same + // encryption configuration as the source backup by default, namely + // [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] = + // `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + CopyBackupEncryptionConfig encryption_config = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Metadata type for the google.longrunning.Operation returned by +// [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]. +message CopyBackupMetadata { + // The name of the backup being created through the copy operation. + // Values are of the form + // `projects//instances//backups/`. + string name = 1 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + }]; + + // The name of the source backup that is being copied. + // Values are of the form + // `projects//instances//backups/`. + string source_backup = 2 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + }]; + + // The progress of the + // [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] operation. + OperationProgress progress = 3; + + // The time at which cancellation of CopyBackup operation was received. + // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + // starts asynchronous cancellation on a long-running operation. The server + // makes a best effort to cancel the operation, but success is not guaranteed. + // Clients can use + // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + // other methods to check whether the cancellation succeeded or whether the + // operation completed despite cancellation. On successful cancellation, + // the operation is not deleted; instead, it becomes an operation with + // an [Operation.error][google.longrunning.Operation.error] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of 1, + // corresponding to `Code.CANCELLED`. + google.protobuf.Timestamp cancel_time = 4; +} + +// The request for [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup]. +message UpdateBackupRequest { + // Required. The backup to update. `backup.name`, and the fields to be updated + // as specified by `update_mask` are required. Other fields are ignored. + // Update is only supported for the following fields: + // * `backup.expire_time`. + Backup backup = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A mask specifying which fields (e.g. `expire_time`) in the + // Backup resource should be updated. This mask is relative to the Backup + // resource, not to the request message. The field mask must always be + // specified; this prevents any future fields from being erased accidentally + // by clients that do not know about them. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for [GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup]. +message GetBackupRequest { + // Required. Name of the backup. + // Values are of the form + // `projects//instances//backups/`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + } + ]; +} + +// The request for [DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup]. +message DeleteBackupRequest { + // Required. Name of the backup to delete. + // Values are of the form + // `projects//instances//backups/`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + } + ]; +} + +// The request for [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]. +message ListBackupsRequest { + // Required. The instance to list backups from. Values are of the + // form `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // An expression that filters the list of returned backups. + // + // A filter expression consists of a field name, a comparison operator, and a + // value for filtering. + // The value must be a string, a number, or a boolean. The comparison operator + // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + // Colon `:` is the contains operator. Filter rules are not case sensitive. + // + // The following fields in the [Backup][google.spanner.admin.database.v1.Backup] are eligible for filtering: + // + // * `name` + // * `database` + // * `state` + // * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + // * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + // * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + // * `size_bytes` + // + // You can combine multiple expressions by enclosing each expression in + // parentheses. By default, expressions are combined with AND logic, but + // you can specify AND, OR, and NOT logic explicitly. + // + // Here are a few examples: + // + // * `name:Howl` - The backup's name contains the string "howl". + // * `database:prod` + // - The database's name contains the string "prod". + // * `state:CREATING` - The backup is pending creation. + // * `state:READY` - The backup is fully created and ready for use. + // * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` + // - The backup name contains the string "howl" and `create_time` + // of the backup is before 2018-03-28T14:50:00Z. + // * `expire_time < \"2018-03-28T14:50:00Z\"` + // - The backup `expire_time` is before 2018-03-28T14:50:00Z. + // * `size_bytes > 10000000000` - The backup's size is greater than 10GB + string filter = 2; + + // Number of backups to be returned in the response. If 0 or + // less, defaults to the server's maximum allowed page size. + int32 page_size = 3; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.database.v1.ListBackupsResponse.next_page_token] from a + // previous [ListBackupsResponse][google.spanner.admin.database.v1.ListBackupsResponse] to the same `parent` and with the same + // `filter`. + string page_token = 4; +} + +// The response for [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]. +message ListBackupsResponse { + // The list of matching backups. Backups returned are ordered by `create_time` + // in descending order, starting from the most recent `create_time`. + repeated Backup backups = 1; + + // `next_page_token` can be sent in a subsequent + // [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups] call to fetch more + // of the matching backups. + string next_page_token = 2; +} + +// The request for +// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]. +message ListBackupOperationsRequest { + // Required. The instance of the backup operations. Values are of + // the form `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // An expression that filters the list of returned backup operations. + // + // A filter expression consists of a field name, a + // comparison operator, and a value for filtering. + // The value must be a string, a number, or a boolean. The comparison operator + // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + // Colon `:` is the contains operator. Filter rules are not case sensitive. + // + // The following fields in the [operation][google.longrunning.Operation] + // are eligible for filtering: + // + // * `name` - The name of the long-running operation + // * `done` - False if the operation is in progress, else true. + // * `metadata.@type` - the type of metadata. For example, the type string + // for [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] is + // `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. + // * `metadata.` - any field in metadata.value. + // `metadata.@type` must be specified first if filtering on metadata + // fields. + // * `error` - Error associated with the long-running operation. + // * `response.@type` - the type of response. + // * `response.` - any field in response.value. + // + // You can combine multiple expressions by enclosing each expression in + // parentheses. By default, expressions are combined with AND logic, but + // you can specify AND, OR, and NOT logic explicitly. + // + // Here are a few examples: + // + // * `done:true` - The operation is complete. + // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + // `metadata.database:prod` - Returns operations where: + // * The operation's metadata type is [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + // * The database the backup was taken from has a name containing the + // string "prod". + // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + // `(metadata.name:howl) AND` \ + // `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + // `(error:*)` - Returns operations where: + // * The operation's metadata type is [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + // * The backup name contains the string "howl". + // * The operation started before 2018-03-28T14:50:00Z. + // * The operation resulted in an error. + // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ + // `(metadata.source_backup:test) AND` \ + // `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ + // `(error:*)` - Returns operations where: + // * The operation's metadata type is [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + // * The source backup of the copied backup name contains the string + // "test". + // * The operation started before 2022-01-18T14:50:00Z. + // * The operation resulted in an error. + // * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + // `(metadata.database:test_db)) OR` \ + // `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) + // AND` \ + // `(metadata.source_backup:test_bkp)) AND` \ + // `(error:*)` - Returns operations where: + // * The operation's metadata matches either of criteria: + // * The operation's metadata type is [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] AND the + // database the backup was taken from has name containing string + // "test_db" + // * The operation's metadata type is [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata] AND the + // backup the backup was copied from has name containing string + // "test_bkp" + // * The operation resulted in an error. + string filter = 2; + + // Number of operations to be returned in the response. If 0 or + // less, defaults to the server's maximum allowed page size. + int32 page_size = 3; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token] + // from a previous [ListBackupOperationsResponse][google.spanner.admin.database.v1.ListBackupOperationsResponse] to the + // same `parent` and with the same `filter`. + string page_token = 4; +} + +// The response for +// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]. +message ListBackupOperationsResponse { + // The list of matching backup [long-running + // operations][google.longrunning.Operation]. Each operation's name will be + // prefixed by the backup's name. The operation's + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. Operations returned + // include those that are pending or have completed/failed/canceled within the + // last 7 days. Operations returned are ordered by + // `operation.metadata.value.progress.start_time` in descending order starting + // from the most recently started operation. + repeated google.longrunning.Operation operations = 1; + + // `next_page_token` can be sent in a subsequent + // [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations] + // call to fetch more of the matching metadata. + string next_page_token = 2; +} + +// Information about a backup. +message BackupInfo { + // Name of the backup. + string backup = 1 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + }]; + + // The backup contains an externally consistent copy of `source_database` at + // the timestamp specified by `version_time`. If the + // [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] request did not specify + // `version_time`, the `version_time` of the backup is equivalent to the + // `create_time`. + google.protobuf.Timestamp version_time = 4; + + // The time the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] request was + // received. + google.protobuf.Timestamp create_time = 2; + + // Name of the database the backup was created from. + string source_database = 3 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + }]; +} + +// Encryption configuration for the backup to create. +message CreateBackupEncryptionConfig { + // Encryption types for the backup. + enum EncryptionType { + // Unspecified. Do not use. + ENCRYPTION_TYPE_UNSPECIFIED = 0; + + // Use the same encryption configuration as the database. This is the + // default option when + // [encryption_config][google.spanner.admin.database.v1.CreateBackupEncryptionConfig] is empty. + // For example, if the database is using `Customer_Managed_Encryption`, the + // backup will be using the same Cloud KMS key as the database. + USE_DATABASE_ENCRYPTION = 1; + + // Use Google default encryption. + GOOGLE_DEFAULT_ENCRYPTION = 2; + + // Use customer managed encryption. If specified, `kms_key_name` + // must contain a valid Cloud KMS key. + CUSTOMER_MANAGED_ENCRYPTION = 3; + } + + // Required. The encryption type of the backup. + EncryptionType encryption_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The Cloud KMS key that will be used to protect the backup. + // This field should be set only when + // [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] is + // `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + // `projects//locations//keyRings//cryptoKeys/`. + string kms_key_name = 2 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + } + ]; +} + +// Encryption configuration for the copied backup. +message CopyBackupEncryptionConfig { + // Encryption types for the backup. + enum EncryptionType { + // Unspecified. Do not use. + ENCRYPTION_TYPE_UNSPECIFIED = 0; + + // This is the default option for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] + // when [encryption_config][google.spanner.admin.database.v1.CopyBackupEncryptionConfig] is not specified. + // For example, if the source backup is using `Customer_Managed_Encryption`, + // the backup will be using the same Cloud KMS key as the source backup. + USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; + + // Use Google default encryption. + GOOGLE_DEFAULT_ENCRYPTION = 2; + + // Use customer managed encryption. If specified, `kms_key_name` + // must contain a valid Cloud KMS key. + CUSTOMER_MANAGED_ENCRYPTION = 3; + } + + // Required. The encryption type of the backup. + EncryptionType encryption_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The Cloud KMS key that will be used to protect the backup. + // This field should be set only when + // [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is + // `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + // `projects//locations//keyRings//cryptoKeys/`. + string kms_key_name = 2 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + } + ]; +} diff --git a/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/common.proto b/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/common.proto new file mode 100644 index 000000000..720ebb95d --- /dev/null +++ b/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/common.proto @@ -0,0 +1,112 @@ +// 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.spanner.admin.database.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.spanner.admin.database.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1"; +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: "cloudkms.googleapis.com/CryptoKeyVersion" + pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}" +}; + +// Encapsulates progress related information for a Cloud Spanner long +// running operation. +message OperationProgress { + // Percent completion of the operation. + // Values are between 0 and 100 inclusive. + int32 progress_percent = 1; + + // Time the request was received. + google.protobuf.Timestamp start_time = 2; + + // If set, the time at which this operation failed or was completed + // successfully. + google.protobuf.Timestamp end_time = 3; +} + +// Encryption configuration for a Cloud Spanner database. +message EncryptionConfig { + // The Cloud KMS key to be used for encrypting and decrypting + // the database. Values are of the form + // `projects//locations//keyRings//cryptoKeys/`. + string kms_key_name = 2 [(google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + }]; +} + +// Encryption information for a Cloud Spanner database or backup. +message EncryptionInfo { + // Possible encryption types. + enum Type { + // Encryption type was not specified, though data at rest remains encrypted. + TYPE_UNSPECIFIED = 0; + + // The data is encrypted at rest with a key that is + // fully managed by Google. No key version or status will be populated. + // This is the default state. + GOOGLE_DEFAULT_ENCRYPTION = 1; + + // The data is encrypted at rest with a key that is + // managed by the customer. The active version of the key. `kms_key_version` + // will be populated, and `encryption_status` may be populated. + CUSTOMER_MANAGED_ENCRYPTION = 2; + } + + // Output only. The type of encryption. + Type encryption_type = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If present, the status of a recent encrypt/decrypt call on underlying data + // for this database or backup. Regardless of status, data is always encrypted + // at rest. + google.rpc.Status encryption_status = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A Cloud KMS key version that is being used to protect the database or + // backup. + string kms_key_version = 2 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKeyVersion" + } + ]; +} + +// Indicates the dialect type of a database. +enum DatabaseDialect { + // Default value. This value will create a database with the + // GOOGLE_STANDARD_SQL dialect. + DATABASE_DIALECT_UNSPECIFIED = 0; + + // Google standard SQL. + GOOGLE_STANDARD_SQL = 1; + + // PostgreSQL supported SQL. + POSTGRESQL = 2; +} diff --git a/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/spanner_database_admin.proto b/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/spanner_database_admin.proto new file mode 100644 index 000000000..91489ae4b --- /dev/null +++ b/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/spanner_database_admin.proto @@ -0,0 +1,930 @@ +// 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.spanner.admin.database.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "google/spanner/admin/database/v1/backup.proto"; +import "google/spanner/admin/database/v1/common.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database"; +option java_multiple_files = true; +option java_outer_classname = "SpannerDatabaseAdminProto"; +option java_package = "com.google.spanner.admin.database.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1"; +option (google.api.resource_definition) = { + type: "spanner.googleapis.com/Instance" + pattern: "projects/{project}/instances/{instance}" +}; + +// Cloud Spanner Database Admin API +// +// The Cloud Spanner Database Admin API can be used to: +// * create, drop, and list databases +// * update the schema of pre-existing databases +// * create, delete and list backups for a database +// * restore a database from an existing backup +service DatabaseAdmin { + option (google.api.default_host) = "spanner.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/spanner.admin"; + + // Lists Cloud Spanner databases. + rpc ListDatabases(ListDatabasesRequest) returns (ListDatabasesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/instances/*}/databases" + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a new Cloud Spanner database and starts to prepare it for serving. + // The returned [long-running operation][google.longrunning.Operation] will + // have a name of the format `/operations/` and + // can be used to track preparation of the database. The + // [metadata][google.longrunning.Operation.metadata] field type is + // [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The + // [response][google.longrunning.Operation.response] field type is + // [Database][google.spanner.admin.database.v1.Database], if successful. + rpc CreateDatabase(CreateDatabaseRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/instances/*}/databases" + body: "*" + }; + option (google.api.method_signature) = "parent,create_statement"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.database.v1.Database" + metadata_type: "google.spanner.admin.database.v1.CreateDatabaseMetadata" + }; + } + + // Gets the state of a Cloud Spanner database. + rpc GetDatabase(GetDatabaseRequest) returns (Database) { + option (google.api.http) = { + get: "/v1/{name=projects/*/instances/*/databases/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the schema of a Cloud Spanner database by + // creating/altering/dropping tables, columns, indexes, etc. The returned + // [long-running operation][google.longrunning.Operation] will have a name of + // the format `/operations/` and can be used to + // track execution of the schema change(s). The + // [metadata][google.longrunning.Operation.metadata] field type is + // [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. + rpc UpdateDatabaseDdl(UpdateDatabaseDdlRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{database=projects/*/instances/*/databases/*}/ddl" + body: "*" + }; + option (google.api.method_signature) = "database,statements"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata" + }; + } + + // Drops (aka deletes) a Cloud Spanner database. + // Completed backups for the database will be retained according to their + // `expire_time`. + // Note: Cloud Spanner might continue to accept requests for a few seconds + // after the database has been deleted. + rpc DropDatabase(DropDatabaseRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{database=projects/*/instances/*/databases/*}" + }; + option (google.api.method_signature) = "database"; + } + + // Returns the schema of a Cloud Spanner database as a list of formatted + // DDL statements. This method does not show pending schema updates, those may + // be queried using the [Operations][google.longrunning.Operations] API. + rpc GetDatabaseDdl(GetDatabaseDdlRequest) returns (GetDatabaseDdlResponse) { + option (google.api.http) = { + get: "/v1/{database=projects/*/instances/*/databases/*}/ddl" + }; + option (google.api.method_signature) = "database"; + } + + // Sets the access control policy on a database or backup resource. + // Replaces any existing policy. + // + // Authorization requires `spanner.databases.setIamPolicy` + // permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + // For backups, authorization requires `spanner.backups.setIamPolicy` + // permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*/instances/*/backups/*}:setIamPolicy" + body: "*" + } + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Gets the access control policy for a database or backup resource. + // Returns an empty policy if a database or backup exists but does not have a + // policy set. + // + // Authorization requires `spanner.databases.getIamPolicy` permission on + // [resource][google.iam.v1.GetIamPolicyRequest.resource]. + // For backups, authorization requires `spanner.backups.getIamPolicy` + // permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*/instances/*/backups/*}:getIamPolicy" + body: "*" + } + }; + option (google.api.method_signature) = "resource"; + } + + // Returns permissions that the caller has on the specified database or backup + // resource. + // + // Attempting this RPC on a non-existent Cloud Spanner database will + // result in a NOT_FOUND error if the user has + // `spanner.databases.list` permission on the containing Cloud + // Spanner instance. Otherwise returns an empty set of permissions. + // Calling this method on a backup that does not exist will + // result in a NOT_FOUND error if the user has + // `spanner.backups.list` permission on the containing instance. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*/instances/*/backups/*}:testIamPermissions" + body: "*" + } + additional_bindings { + post: "/v1/{resource=projects/*/instances/*/databases/*/databaseRoles/*}:testIamPermissions" + body: "*" + } + }; + option (google.api.method_signature) = "resource,permissions"; + } + + // Starts creating a new Cloud Spanner Backup. + // The returned backup [long-running operation][google.longrunning.Operation] + // will have a name of the format + // `projects//instances//backups//operations/` + // and can be used to track creation of the backup. The + // [metadata][google.longrunning.Operation.metadata] field type is + // [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The + // [response][google.longrunning.Operation.response] field type is + // [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the + // creation and delete the backup. + // There can be only one pending backup creation per database. Backup creation + // of different databases can run concurrently. + rpc CreateBackup(CreateBackupRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/instances/*}/backups" + body: "backup" + }; + option (google.api.method_signature) = "parent,backup,backup_id"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.database.v1.Backup" + metadata_type: "google.spanner.admin.database.v1.CreateBackupMetadata" + }; + } + + // Starts copying a Cloud Spanner Backup. + // The returned backup [long-running operation][google.longrunning.Operation] + // will have a name of the format + // `projects//instances//backups//operations/` + // and can be used to track copying of the backup. The operation is associated + // with the destination backup. + // The [metadata][google.longrunning.Operation.metadata] field type is + // [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + // The [response][google.longrunning.Operation.response] field type is + // [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the + // copying and delete the backup. + // Concurrent CopyBackup requests can run on the same source backup. + rpc CopyBackup(CopyBackupRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/instances/*}/backups:copy" + body: "*" + }; + option (google.api.method_signature) = "parent,backup_id,source_backup,expire_time"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.database.v1.Backup" + metadata_type: "google.spanner.admin.database.v1.CopyBackupMetadata" + }; + } + + // Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + rpc GetBackup(GetBackupRequest) returns (Backup) { + option (google.api.http) = { + get: "/v1/{name=projects/*/instances/*/backups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + rpc UpdateBackup(UpdateBackupRequest) returns (Backup) { + option (google.api.http) = { + patch: "/v1/{backup.name=projects/*/instances/*/backups/*}" + body: "backup" + }; + option (google.api.method_signature) = "backup,update_mask"; + } + + // Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + rpc DeleteBackup(DeleteBackupRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/instances/*/backups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists completed and pending backups. + // Backups returned are ordered by `create_time` in descending order, + // starting from the most recent `create_time`. + rpc ListBackups(ListBackupsRequest) returns (ListBackupsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/instances/*}/backups" + }; + option (google.api.method_signature) = "parent"; + } + + // Create a new database by restoring from a completed backup. The new + // database must be in the same project and in an instance with the same + // instance configuration as the instance containing + // the backup. The returned database [long-running + // operation][google.longrunning.Operation] has a name of the format + // `projects//instances//databases//operations/`, + // and can be used to track the progress of the operation, and to cancel it. + // The [metadata][google.longrunning.Operation.metadata] field type is + // [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + // The [response][google.longrunning.Operation.response] type + // is [Database][google.spanner.admin.database.v1.Database], if + // successful. Cancelling the returned operation will stop the restore and + // delete the database. + // There can be only one database being restored into an instance at a time. + // Once the restore operation completes, a new restore operation can be + // initiated, without waiting for the optimize operation associated with the + // first restore to complete. + rpc RestoreDatabase(RestoreDatabaseRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/instances/*}/databases:restore" + body: "*" + }; + option (google.api.method_signature) = "parent,database_id,backup"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.database.v1.Database" + metadata_type: "google.spanner.admin.database.v1.RestoreDatabaseMetadata" + }; + } + + // Lists database [longrunning-operations][google.longrunning.Operation]. + // A database operation has a name of the form + // `projects//instances//databases//operations/`. + // The long-running operation + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. Operations returned + // include those that have completed/failed/canceled within the last 7 days, + // and pending operations. + rpc ListDatabaseOperations(ListDatabaseOperationsRequest) returns (ListDatabaseOperationsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/instances/*}/databaseOperations" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists the backup [long-running operations][google.longrunning.Operation] in + // the given instance. A backup operation has a name of the form + // `projects//instances//backups//operations/`. + // The long-running operation + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. Operations returned + // include those that have completed/failed/canceled within the last 7 days, + // and pending operations. Operations returned are ordered by + // `operation.metadata.value.progress.start_time` in descending order starting + // from the most recently started operation. + rpc ListBackupOperations(ListBackupOperationsRequest) returns (ListBackupOperationsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/instances/*}/backupOperations" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists Cloud Spanner database roles. + rpc ListDatabaseRoles(ListDatabaseRolesRequest) returns (ListDatabaseRolesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/instances/*/databases/*}/databaseRoles" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Information about the database restore. +message RestoreInfo { + // The type of the restore source. + RestoreSourceType source_type = 1; + + // Information about the source used to restore the database. + oneof source_info { + // Information about the backup used to restore the database. The backup + // may no longer exist. + BackupInfo backup_info = 2; + } +} + +// A Cloud Spanner database. +message Database { + option (google.api.resource) = { + type: "spanner.googleapis.com/Database" + pattern: "projects/{project}/instances/{instance}/databases/{database}" + }; + + // Indicates the current state of the database. + enum State { + // Not specified. + STATE_UNSPECIFIED = 0; + + // The database is still being created. Operations on the database may fail + // with `FAILED_PRECONDITION` in this state. + CREATING = 1; + + // The database is fully created and ready for use. + READY = 2; + + // The database is fully created and ready for use, but is still + // being optimized for performance and cannot handle full load. + // + // In this state, the database still references the backup + // it was restore from, preventing the backup + // from being deleted. When optimizations are complete, the full performance + // of the database will be restored, and the database will transition to + // `READY` state. + READY_OPTIMIZING = 3; + } + + // Required. The name of the database. Values are of the form + // `projects//instances//databases/`, + // where `` is as specified in the `CREATE DATABASE` + // statement. This name can be passed to other API methods to + // identify the database. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Output only. The current database state. + State state = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If exists, the time at which the database creation started. + google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Applicable only for restored databases. Contains information + // about the restore source. + RestoreInfo restore_info = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For databases that are using customer managed encryption, this + // field contains the encryption configuration for the database. + // For databases that are using Google default or other types of encryption, + // this field is empty. + EncryptionConfig encryption_config = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For databases that are using customer managed encryption, this + // field contains the encryption information for the database, such as + // encryption state and the Cloud KMS key versions that are in use. + // + // For databases that are using Google default or other types of encryption, + // this field is empty. + // + // This field is propagated lazily from the backend. There might be a delay + // from when a key version is being used and when it appears in this field. + repeated EncryptionInfo encryption_info = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The period in which Cloud Spanner retains all versions of data + // for the database. This is the same as the value of version_retention_period + // database option set using + // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]. Defaults to 1 hour, + // if not set. + string version_retention_period = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Earliest timestamp at which older versions of the data can be + // read. This value is continuously updated by Cloud Spanner and becomes stale + // the moment it is queried. If you are using this value to recover data, make + // sure to account for the time from the moment when the value is queried to + // the moment when you initiate the recovery. + google.protobuf.Timestamp earliest_version_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The read-write region which contains the database's leader + // replicas. + // + // This is the same as the value of default_leader + // database option set using DatabaseAdmin.CreateDatabase or + // DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty. + string default_leader = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The dialect of the Cloud Spanner Database. + DatabaseDialect database_dialect = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The request for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]. +message ListDatabasesRequest { + // Required. The instance whose databases should be listed. + // Values are of the form `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // Number of databases to be returned in the response. If 0 or less, + // defaults to the server's maximum allowed page size. + int32 page_size = 3; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] from a + // previous [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse]. + string page_token = 4; +} + +// The response for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]. +message ListDatabasesResponse { + // Databases that matched the request. + repeated Database databases = 1; + + // `next_page_token` can be sent in a subsequent + // [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] call to fetch more + // of the matching databases. + string next_page_token = 2; +} + +// The request for [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase]. +message CreateDatabaseRequest { + // Required. The name of the instance that will serve the new database. + // Values are of the form `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // Required. A `CREATE DATABASE` statement, which specifies the ID of the + // new database. The database ID must conform to the regular expression + // `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length. + // If the database ID is a reserved word or if it contains a hyphen, the + // database ID must be enclosed in backticks (`` ` ``). + string create_statement = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. A list of DDL statements to run inside the newly created + // database. Statements can create tables, indexes, etc. These + // statements execute atomically with the creation of the database: + // if there is an error in any statement, the database is not created. + repeated string extra_statements = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The encryption configuration for the database. If this field is not + // specified, Cloud Spanner will encrypt/decrypt all data at rest using + // Google default encryption. + EncryptionConfig encryption_config = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The dialect of the Cloud Spanner Database. + DatabaseDialect database_dialect = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Metadata type for the operation returned by +// [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase]. +message CreateDatabaseMetadata { + // The database being created. + string database = 1 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + }]; +} + +// The request for [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase]. +message GetDatabaseRequest { + // Required. The name of the requested database. Values are of the form + // `projects//instances//databases/`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; +} + +// Enqueues the given DDL statements to be applied, in order but not +// necessarily all at once, to the database schema at some point (or +// points) in the future. The server checks that the statements +// are executable (syntactically valid, name tables that exist, etc.) +// before enqueueing them, but they may still fail upon +// later execution (e.g., if a statement from another batch of +// statements is applied first and it conflicts in some way, or if +// there is some data-related problem like a `NULL` value in a column to +// which `NOT NULL` would be added). If a statement fails, all +// subsequent statements in the batch are automatically cancelled. +// +// Each batch of statements is assigned a name which can be used with +// the [Operations][google.longrunning.Operations] API to monitor +// progress. See the +// [operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id] field for more +// details. +message UpdateDatabaseDdlRequest { + // Required. The database to update. + string database = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; + + // Required. DDL statements to be applied to the database. + repeated string statements = 2 [(google.api.field_behavior) = REQUIRED]; + + // If empty, the new update request is assigned an + // automatically-generated operation ID. Otherwise, `operation_id` + // is used to construct the name of the resulting + // [Operation][google.longrunning.Operation]. + // + // Specifying an explicit operation ID simplifies determining + // whether the statements were executed in the event that the + // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] call is replayed, + // or the return value is otherwise lost: the [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] and + // `operation_id` fields can be combined to form the + // [name][google.longrunning.Operation.name] of the resulting + // [longrunning.Operation][google.longrunning.Operation]: `/operations/`. + // + // `operation_id` should be unique within the database, and must be + // a valid identifier: `[a-z][a-z0-9_]*`. Note that + // automatically-generated operation IDs always begin with an + // underscore. If the named operation already exists, + // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] returns + // `ALREADY_EXISTS`. + string operation_id = 3; +} + +// Metadata type for the operation returned by +// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]. +message UpdateDatabaseDdlMetadata { + // The database being modified. + string database = 1 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + }]; + + // For an update this list contains all the statements. For an + // individual statement, this list contains only that statement. + repeated string statements = 2; + + // Reports the commit timestamps of all statements that have + // succeeded so far, where `commit_timestamps[i]` is the commit + // timestamp for the statement `statements[i]`. + repeated google.protobuf.Timestamp commit_timestamps = 3; + + // Output only. When true, indicates that the operation is throttled e.g + // due to resource constraints. When resources become available the operation + // will resume and this field will be false again. + bool throttled = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The progress of the + // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] operations. + // Currently, only index creation statements will have a continuously + // updating progress. + // For non-index creation statements, `progress[i]` will have start time + // and end time populated with commit timestamp of operation, + // as well as a progress of 100% once the operation has completed. + // `progress[i]` is the operation progress for `statements[i]`. + repeated OperationProgress progress = 5; +} + +// The request for [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase]. +message DropDatabaseRequest { + // Required. The database to be dropped. + string database = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; +} + +// The request for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl]. +message GetDatabaseDdlRequest { + // Required. The database whose schema we wish to get. + // Values are of the form + // `projects//instances//databases/` + string database = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; +} + +// The response for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl]. +message GetDatabaseDdlResponse { + // A list of formatted DDL statements defining the schema of the database + // specified in the request. + repeated string statements = 1; +} + +// The request for +// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]. +message ListDatabaseOperationsRequest { + // Required. The instance of the database operations. + // Values are of the form `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // An expression that filters the list of returned operations. + // + // A filter expression consists of a field name, a + // comparison operator, and a value for filtering. + // The value must be a string, a number, or a boolean. The comparison operator + // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + // Colon `:` is the contains operator. Filter rules are not case sensitive. + // + // The following fields in the [Operation][google.longrunning.Operation] + // are eligible for filtering: + // + // * `name` - The name of the long-running operation + // * `done` - False if the operation is in progress, else true. + // * `metadata.@type` - the type of metadata. For example, the type string + // for [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata] is + // `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. + // * `metadata.` - any field in metadata.value. + // `metadata.@type` must be specified first, if filtering on metadata + // fields. + // * `error` - Error associated with the long-running operation. + // * `response.@type` - the type of response. + // * `response.` - any field in response.value. + // + // You can combine multiple expressions by enclosing each expression in + // parentheses. By default, expressions are combined with AND logic. However, + // you can specify AND, OR, and NOT logic explicitly. + // + // Here are a few examples: + // + // * `done:true` - The operation is complete. + // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ + // `(metadata.source_type:BACKUP) AND` \ + // `(metadata.backup_info.backup:backup_howl) AND` \ + // `(metadata.name:restored_howl) AND` \ + // `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + // `(error:*)` - Return operations where: + // * The operation's metadata type is [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + // * The database is restored from a backup. + // * The backup name contains "backup_howl". + // * The restored database's name contains "restored_howl". + // * The operation started before 2018-03-28T14:50:00Z. + // * The operation resulted in an error. + string filter = 2; + + // Number of operations to be returned in the response. If 0 or + // less, defaults to the server's maximum allowed page size. + int32 page_size = 3; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token] + // from a previous [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse] to the + // same `parent` and with the same `filter`. + string page_token = 4; +} + +// The response for +// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]. +message ListDatabaseOperationsResponse { + // The list of matching database [long-running + // operations][google.longrunning.Operation]. Each operation's name will be + // prefixed by the database's name. The operation's + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. + repeated google.longrunning.Operation operations = 1; + + // `next_page_token` can be sent in a subsequent + // [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations] + // call to fetch more of the matching metadata. + string next_page_token = 2; +} + +// The request for +// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]. +message RestoreDatabaseRequest { + // Required. The name of the instance in which to create the + // restored database. This instance must be in the same project and + // have the same instance configuration as the instance containing + // the source backup. Values are of the form + // `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // Required. The id of the database to create and restore to. This + // database must not already exist. The `database_id` appended to + // `parent` forms the full database name of the form + // `projects//instances//databases/`. + string database_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The source from which to restore. + oneof source { + // Name of the backup from which to restore. Values are of the form + // `projects//instances//backups/`. + string backup = 3 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + }]; + } + + // Optional. An encryption configuration describing the encryption type and key + // resources in Cloud KMS used to encrypt/decrypt the database to restore to. + // If this field is not specified, the restored database will use + // the same encryption configuration as the backup by default, namely + // [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] = + // `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + RestoreDatabaseEncryptionConfig encryption_config = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Encryption configuration for the restored database. +message RestoreDatabaseEncryptionConfig { + // Encryption types for the database to be restored. + enum EncryptionType { + // Unspecified. Do not use. + ENCRYPTION_TYPE_UNSPECIFIED = 0; + + // This is the default option when + // [encryption_config][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig] is not specified. + USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; + + // Use Google default encryption. + GOOGLE_DEFAULT_ENCRYPTION = 2; + + // Use customer managed encryption. If specified, `kms_key_name` must + // must contain a valid Cloud KMS key. + CUSTOMER_MANAGED_ENCRYPTION = 3; + } + + // Required. The encryption type of the restored database. + EncryptionType encryption_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The Cloud KMS key that will be used to encrypt/decrypt the restored + // database. This field should be set only when + // [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] is + // `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form + // `projects//locations//keyRings//cryptoKeys/`. + string kms_key_name = 2 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "cloudkms.googleapis.com/CryptoKey" + } + ]; +} + +// Metadata type for the long-running operation returned by +// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]. +message RestoreDatabaseMetadata { + // Name of the database being created and restored to. + string name = 1 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + }]; + + // The type of the restore source. + RestoreSourceType source_type = 2; + + // Information about the source used to restore the database, as specified by + // `source` in [RestoreDatabaseRequest][google.spanner.admin.database.v1.RestoreDatabaseRequest]. + oneof source_info { + // Information about the backup used to restore the database. + BackupInfo backup_info = 3; + } + + // The progress of the + // [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase] + // operation. + OperationProgress progress = 4; + + // The time at which cancellation of this operation was received. + // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + // starts asynchronous cancellation on a long-running operation. The server + // makes a best effort to cancel the operation, but success is not guaranteed. + // Clients can use + // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + // other methods to check whether the cancellation succeeded or whether the + // operation completed despite cancellation. On successful cancellation, + // the operation is not deleted; instead, it becomes an operation with + // an [Operation.error][google.longrunning.Operation.error] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`. + google.protobuf.Timestamp cancel_time = 5; + + // If exists, the name of the long-running operation that will be used to + // track the post-restore optimization process to optimize the performance of + // the restored database, and remove the dependency on the restore source. + // The name is of the form + // `projects//instances//databases//operations/` + // where the is the name of database being created and restored to. + // The metadata type of the long-running operation is + // [OptimizeRestoredDatabaseMetadata][google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]. This long-running operation will be + // automatically created by the system after the RestoreDatabase long-running + // operation completes successfully. This operation will not be created if the + // restore was not successful. + string optimize_database_operation_name = 6; +} + +// Metadata type for the long-running operation used to track the progress +// of optimizations performed on a newly restored database. This long-running +// operation is automatically created by the system after the successful +// completion of a database restore, and cannot be cancelled. +message OptimizeRestoredDatabaseMetadata { + // Name of the restored database being optimized. + string name = 1 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + }]; + + // The progress of the post-restore optimizations. + OperationProgress progress = 2; +} + +// Indicates the type of the restore source. +enum RestoreSourceType { + // No restore associated. + TYPE_UNSPECIFIED = 0; + + // A backup was used as the source of the restore. + BACKUP = 1; +} + +// A Cloud Spanner database role. +message DatabaseRole { + option (google.api.resource) = { + type: "spanner.googleapis.com/DatabaseRole" + pattern: "projects/{project}/instances/{instance}/databases/{database}/databaseRoles/{role}" + }; + + // Required. The name of the database role. Values are of the form + // `projects//instances//databases//databaseRoles/ + // {role}`, where `` is as specified in the `CREATE ROLE` + // DDL statement. This name can be passed to Get/Set IAMPolicy methods to + // identify the database role. + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles]. +message ListDatabaseRolesRequest { + // Required. The database whose roles should be listed. + // Values are of the form + // `projects//instances//databases//databaseRoles`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; + + // Number of database roles to be returned in the response. If 0 or less, + // defaults to the server's maximum allowed page size. + int32 page_size = 2; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token] from a + // previous [ListDatabaseRolesResponse][google.spanner.admin.database.v1.ListDatabaseRolesResponse]. + string page_token = 3; +} + +// The response for [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles]. +message ListDatabaseRolesResponse { + // Database roles that matched the request. + repeated DatabaseRole database_roles = 1; + + // `next_page_token` can be sent in a subsequent + // [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles] + // call to fetch more of the matching roles. + string next_page_token = 2; +} diff --git a/owl-bot-staging/admin/database/v1/src/index.ts b/owl-bot-staging/admin/database/v1/src/index.ts new file mode 100644 index 000000000..8426cae7a --- /dev/null +++ b/owl-bot-staging/admin/database/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const DatabaseAdminClient = v1.DatabaseAdminClient; +type DatabaseAdminClient = v1.DatabaseAdminClient; +export {v1, DatabaseAdminClient}; +export default {v1, DatabaseAdminClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/admin/database/v1/src/v1/database_admin_client.ts b/owl-bot-staging/admin/database/v1/src/v1/database_admin_client.ts new file mode 100644 index 000000000..95fe0cb8b --- /dev/null +++ b/owl-bot-staging/admin/database/v1/src/v1/database_admin_client.ts @@ -0,0 +1,3557 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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/v1/database_admin_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './database_admin_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Spanner Database Admin API + * + * The Cloud Spanner Database Admin API can be used to: + * * create, drop, and list databases + * * update the schema of pre-existing databases + * * create, delete and list backups for a database + * * restore a database from an existing backup + * @class + * @memberof v1 + */ +export class DatabaseAdminClient { + 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; + databaseAdminStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DatabaseAdminClient. + * + * @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 DatabaseAdminClient({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 DatabaseAdminClient; + 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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 = { + backupPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instances/{instance}/backups/{backup}' + ), + cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' + ), + databasePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instances/{instance}/databases/{database}' + ), + databaseRolePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instances/{instance}/databases/{database}/databaseRoles/{role}' + ), + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instances/{instance}' + ), + }; + + // 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 = { + listDatabases: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'databases'), + listBackups: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backups'), + listDatabaseOperations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'operations'), + listBackupOperations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'operations'), + listDatabaseRoles: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'databaseRoles') + }; + + 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.CancelOperation',post: '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel',additional_bindings: [{post: '/v1/{name=projects/*/instances/*/operations/*}:cancel',},{post: '/v1/{name=projects/*/instances/*/backups/*/operations/*}:cancel',},{post: '/v1/{name=projects/*/instanceConfigs/*/operations/*}:cancel',}], + },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/instances/*/databases/*/operations/*}',additional_bindings: [{delete: '/v1/{name=projects/*/instances/*/operations/*}',},{delete: '/v1/{name=projects/*/instances/*/backups/*/operations/*}',},{delete: '/v1/{name=projects/*/instanceConfigs/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/instances/*/databases/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/instances/*/operations/*}',},{get: '/v1/{name=projects/*/instances/*/backups/*/operations/*}',},{get: '/v1/{name=projects/*/instanceConfigs/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/instances/*/databases/*/operations}',additional_bindings: [{get: '/v1/{name=projects/*/instances/*/operations}',},{get: '/v1/{name=projects/*/instances/*/backups/*/operations}',},{get: '/v1/{name=projects/*/instanceConfigs/*/operations}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createDatabaseResponse = protoFilesRoot.lookup( + '.google.spanner.admin.database.v1.Database') as gax.protobuf.Type; + const createDatabaseMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.database.v1.CreateDatabaseMetadata') as gax.protobuf.Type; + const updateDatabaseDdlResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const updateDatabaseDdlMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata') as gax.protobuf.Type; + const createBackupResponse = protoFilesRoot.lookup( + '.google.spanner.admin.database.v1.Backup') as gax.protobuf.Type; + const createBackupMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.database.v1.CreateBackupMetadata') as gax.protobuf.Type; + const copyBackupResponse = protoFilesRoot.lookup( + '.google.spanner.admin.database.v1.Backup') as gax.protobuf.Type; + const copyBackupMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.database.v1.CopyBackupMetadata') as gax.protobuf.Type; + const restoreDatabaseResponse = protoFilesRoot.lookup( + '.google.spanner.admin.database.v1.Database') as gax.protobuf.Type; + const restoreDatabaseMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.database.v1.RestoreDatabaseMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createDatabase: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createDatabaseResponse.decode.bind(createDatabaseResponse), + createDatabaseMetadata.decode.bind(createDatabaseMetadata)), + updateDatabaseDdl: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateDatabaseDdlResponse.decode.bind(updateDatabaseDdlResponse), + updateDatabaseDdlMetadata.decode.bind(updateDatabaseDdlMetadata)), + createBackup: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createBackupResponse.decode.bind(createBackupResponse), + createBackupMetadata.decode.bind(createBackupMetadata)), + copyBackup: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + copyBackupResponse.decode.bind(copyBackupResponse), + copyBackupMetadata.decode.bind(copyBackupMetadata)), + restoreDatabase: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + restoreDatabaseResponse.decode.bind(restoreDatabaseResponse), + restoreDatabaseMetadata.decode.bind(restoreDatabaseMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.spanner.admin.database.v1.DatabaseAdmin', 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.databaseAdminStub) { + return this.databaseAdminStub; + } + + // Put together the "service stub" for + // google.spanner.admin.database.v1.DatabaseAdmin. + this.databaseAdminStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.spanner.admin.database.v1.DatabaseAdmin') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.spanner.admin.database.v1.DatabaseAdmin, + 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 databaseAdminStubMethods = + ['listDatabases', 'createDatabase', 'getDatabase', 'updateDatabaseDdl', 'dropDatabase', 'getDatabaseDdl', 'setIamPolicy', 'getIamPolicy', 'testIamPermissions', 'createBackup', 'copyBackup', 'getBackup', 'updateBackup', 'deleteBackup', 'listBackups', 'restoreDatabase', 'listDatabaseOperations', 'listBackupOperations', 'listDatabaseRoles']; + for (const methodName of databaseAdminStubMethods) { + const callPromise = this.databaseAdminStub.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.databaseAdminStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'spanner.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 'spanner.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', + 'https://www.googleapis.com/auth/spanner.admin' + ]; + } + + 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 the state of a Cloud Spanner database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the requested database. Values are of the form + * `projects//instances//databases/`. + * @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 {@link google.spanner.admin.database.v1.Database | Database}. + * 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/v1/database_admin.get_database.js + * region_tag:spanner_v1_generated_DatabaseAdmin_GetDatabase_async + */ + getDatabase( + request?: protos.google.spanner.admin.database.v1.IGetDatabaseRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.database.v1.IDatabase, + protos.google.spanner.admin.database.v1.IGetDatabaseRequest|undefined, {}|undefined + ]>; + getDatabase( + request: protos.google.spanner.admin.database.v1.IGetDatabaseRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.admin.database.v1.IDatabase, + protos.google.spanner.admin.database.v1.IGetDatabaseRequest|null|undefined, + {}|null|undefined>): void; + getDatabase( + request: protos.google.spanner.admin.database.v1.IGetDatabaseRequest, + callback: Callback< + protos.google.spanner.admin.database.v1.IDatabase, + protos.google.spanner.admin.database.v1.IGetDatabaseRequest|null|undefined, + {}|null|undefined>): void; + getDatabase( + request?: protos.google.spanner.admin.database.v1.IGetDatabaseRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.admin.database.v1.IDatabase, + protos.google.spanner.admin.database.v1.IGetDatabaseRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.admin.database.v1.IDatabase, + protos.google.spanner.admin.database.v1.IGetDatabaseRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.admin.database.v1.IDatabase, + protos.google.spanner.admin.database.v1.IGetDatabaseRequest|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({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDatabase(request, options, callback); + } +/** + * Drops (aka deletes) a Cloud Spanner database. + * Completed backups for the database will be retained according to their + * `expire_time`. + * Note: Cloud Spanner might continue to accept requests for a few seconds + * after the database has been deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database to be dropped. + * @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 {@link google.protobuf.Empty | Empty}. + * 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/v1/database_admin.drop_database.js + * region_tag:spanner_v1_generated_DatabaseAdmin_DropDatabase_async + */ + dropDatabase( + request?: protos.google.spanner.admin.database.v1.IDropDatabaseRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDropDatabaseRequest|undefined, {}|undefined + ]>; + dropDatabase( + request: protos.google.spanner.admin.database.v1.IDropDatabaseRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDropDatabaseRequest|null|undefined, + {}|null|undefined>): void; + dropDatabase( + request: protos.google.spanner.admin.database.v1.IDropDatabaseRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDropDatabaseRequest|null|undefined, + {}|null|undefined>): void; + dropDatabase( + request?: protos.google.spanner.admin.database.v1.IDropDatabaseRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDropDatabaseRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDropDatabaseRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDropDatabaseRequest|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({ + 'database': request.database ?? '', + }); + this.initialize(); + return this.innerApiCalls.dropDatabase(request, options, callback); + } +/** + * Returns the schema of a Cloud Spanner database as a list of formatted + * DDL statements. This method does not show pending schema updates, those may + * be queried using the {@link google.longrunning.Operations|Operations} API. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database whose schema we wish to get. + * Values are of the form + * `projects//instances//databases/` + * @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 {@link google.spanner.admin.database.v1.GetDatabaseDdlResponse | GetDatabaseDdlResponse}. + * 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/v1/database_admin.get_database_ddl.js + * region_tag:spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_async + */ + getDatabaseDdl( + request?: protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, + protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|undefined, {}|undefined + ]>; + getDatabaseDdl( + request: protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, + protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|null|undefined, + {}|null|undefined>): void; + getDatabaseDdl( + request: protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest, + callback: Callback< + protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, + protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|null|undefined, + {}|null|undefined>): void; + getDatabaseDdl( + request?: protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, + protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, + protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, + protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|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({ + 'database': request.database ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDatabaseDdl(request, options, callback); + } +/** + * Sets the access control policy on a database or backup resource. + * Replaces any existing policy. + * + * Authorization requires `spanner.databases.setIamPolicy` + * permission on {@link google.iam.v1.SetIamPolicyRequest.resource|resource}. + * For backups, authorization requires `spanner.backups.setIamPolicy` + * permission on {@link google.iam.v1.SetIamPolicyRequest.resource|resource}. + * + * @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 {@link google.iam.v1.Policy | 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/v1/database_admin.set_iam_policy.js + * region_tag:spanner_v1_generated_DatabaseAdmin_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); + } +/** + * Gets the access control policy for a database or backup resource. + * Returns an empty policy if a database or backup exists but does not have a + * policy set. + * + * Authorization requires `spanner.databases.getIamPolicy` permission on + * {@link google.iam.v1.GetIamPolicyRequest.resource|resource}. + * For backups, authorization requires `spanner.backups.getIamPolicy` + * permission on {@link google.iam.v1.GetIamPolicyRequest.resource|resource}. + * + * @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 {@link google.iam.v1.Policy | 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/v1/database_admin.get_iam_policy.js + * region_tag:spanner_v1_generated_DatabaseAdmin_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); + } +/** + * Returns permissions that the caller has on the specified database or backup + * resource. + * + * Attempting this RPC on a non-existent Cloud Spanner database will + * result in a NOT_FOUND error if the user has + * `spanner.databases.list` permission on the containing Cloud + * Spanner instance. Otherwise returns an empty set of permissions. + * Calling this method on a backup that does not exist will + * result in a NOT_FOUND error if the user has + * `spanner.backups.list` permission on the containing instance. + * + * @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 {@link google.iam.v1.TestIamPermissionsResponse | 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/v1/database_admin.test_iam_permissions.js + * region_tag:spanner_v1_generated_DatabaseAdmin_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); + } +/** + * Gets metadata on a pending or completed {@link google.spanner.admin.database.v1.Backup|Backup}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the backup. + * Values are of the form + * `projects//instances//backups/`. + * @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 {@link google.spanner.admin.database.v1.Backup | Backup}. + * 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/v1/database_admin.get_backup.js + * region_tag:spanner_v1_generated_DatabaseAdmin_GetBackup_async + */ + getBackup( + request?: protos.google.spanner.admin.database.v1.IGetBackupRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IGetBackupRequest|undefined, {}|undefined + ]>; + getBackup( + request: protos.google.spanner.admin.database.v1.IGetBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IGetBackupRequest|null|undefined, + {}|null|undefined>): void; + getBackup( + request: protos.google.spanner.admin.database.v1.IGetBackupRequest, + callback: Callback< + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IGetBackupRequest|null|undefined, + {}|null|undefined>): void; + getBackup( + request?: protos.google.spanner.admin.database.v1.IGetBackupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IGetBackupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IGetBackupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IGetBackupRequest|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({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getBackup(request, options, callback); + } +/** + * Updates a pending or completed {@link google.spanner.admin.database.v1.Backup|Backup}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.spanner.admin.database.v1.Backup} request.backup + * Required. The backup to update. `backup.name`, and the fields to be updated + * as specified by `update_mask` are required. Other fields are ignored. + * Update is only supported for the following fields: + * * `backup.expire_time`. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A mask specifying which fields (e.g. `expire_time`) in the + * Backup resource should be updated. This mask is relative to the Backup + * resource, not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased accidentally + * by clients that do not know about them. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.spanner.admin.database.v1.Backup | Backup}. + * 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/v1/database_admin.update_backup.js + * region_tag:spanner_v1_generated_DatabaseAdmin_UpdateBackup_async + */ + updateBackup( + request?: protos.google.spanner.admin.database.v1.IUpdateBackupRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IUpdateBackupRequest|undefined, {}|undefined + ]>; + updateBackup( + request: protos.google.spanner.admin.database.v1.IUpdateBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IUpdateBackupRequest|null|undefined, + {}|null|undefined>): void; + updateBackup( + request: protos.google.spanner.admin.database.v1.IUpdateBackupRequest, + callback: Callback< + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IUpdateBackupRequest|null|undefined, + {}|null|undefined>): void; + updateBackup( + request?: protos.google.spanner.admin.database.v1.IUpdateBackupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IUpdateBackupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IUpdateBackupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.admin.database.v1.IBackup, + protos.google.spanner.admin.database.v1.IUpdateBackupRequest|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({ + 'backup.name': request.backup!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateBackup(request, options, callback); + } +/** + * Deletes a pending or completed {@link google.spanner.admin.database.v1.Backup|Backup}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the backup to delete. + * Values are of the form + * `projects//instances//backups/`. + * @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 {@link google.protobuf.Empty | Empty}. + * 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/v1/database_admin.delete_backup.js + * region_tag:spanner_v1_generated_DatabaseAdmin_DeleteBackup_async + */ + deleteBackup( + request?: protos.google.spanner.admin.database.v1.IDeleteBackupRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDeleteBackupRequest|undefined, {}|undefined + ]>; + deleteBackup( + request: protos.google.spanner.admin.database.v1.IDeleteBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDeleteBackupRequest|null|undefined, + {}|null|undefined>): void; + deleteBackup( + request: protos.google.spanner.admin.database.v1.IDeleteBackupRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDeleteBackupRequest|null|undefined, + {}|null|undefined>): void; + deleteBackup( + request?: protos.google.spanner.admin.database.v1.IDeleteBackupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDeleteBackupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDeleteBackupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.database.v1.IDeleteBackupRequest|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({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteBackup(request, options, callback); + } + +/** + * Creates a new Cloud Spanner database and starts to prepare it for serving. + * The returned {@link google.longrunning.Operation|long-running operation} will + * have a name of the format `/operations/` and + * can be used to track preparation of the database. The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.database.v1.CreateDatabaseMetadata|CreateDatabaseMetadata}. The + * {@link google.longrunning.Operation.response|response} field type is + * {@link google.spanner.admin.database.v1.Database|Database}, if successful. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the instance that will serve the new database. + * Values are of the form `projects//instances/`. + * @param {string} request.createStatement + * Required. A `CREATE DATABASE` statement, which specifies the ID of the + * new database. The database ID must conform to the regular expression + * `{@link a-z0-9_\-|a-z}*[a-z0-9]` and be between 2 and 30 characters in length. + * If the database ID is a reserved word or if it contains a hyphen, the + * database ID must be enclosed in backticks (`` ` ``). + * @param {string[]} [request.extraStatements] + * Optional. A list of DDL statements to run inside the newly created + * database. Statements can create tables, indexes, etc. These + * statements execute atomically with the creation of the database: + * if there is an error in any statement, the database is not created. + * @param {google.spanner.admin.database.v1.EncryptionConfig} [request.encryptionConfig] + * Optional. The encryption configuration for the database. If this field is not + * specified, Cloud Spanner will encrypt/decrypt all data at rest using + * Google default encryption. + * @param {google.spanner.admin.database.v1.DatabaseDialect} [request.databaseDialect] + * Optional. The dialect of the Cloud Spanner Database. + * @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/v1/database_admin.create_database.js + * region_tag:spanner_v1_generated_DatabaseAdmin_CreateDatabase_async + */ + createDatabase( + request?: protos.google.spanner.admin.database.v1.ICreateDatabaseRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createDatabase( + request: protos.google.spanner.admin.database.v1.ICreateDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createDatabase( + request: protos.google.spanner.admin.database.v1.ICreateDatabaseRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createDatabase( + request?: protos.google.spanner.admin.database.v1.ICreateDatabaseRequest, + 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 || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createDatabase(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createDatabase()`. + * @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/v1/database_admin.create_database.js + * region_tag:spanner_v1_generated_DatabaseAdmin_CreateDatabase_async + */ + async checkCreateDatabaseProgress(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.createDatabase, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the schema of a Cloud Spanner database by + * creating/altering/dropping tables, columns, indexes, etc. The returned + * {@link google.longrunning.Operation|long-running operation} will have a name of + * the format `/operations/` and can be used to + * track execution of the schema change(s). The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata|UpdateDatabaseDdlMetadata}. The operation has no response. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database to update. + * @param {string[]} request.statements + * Required. DDL statements to be applied to the database. + * @param {string} request.operationId + * If empty, the new update request is assigned an + * automatically-generated operation ID. Otherwise, `operation_id` + * is used to construct the name of the resulting + * {@link google.longrunning.Operation|Operation}. + * + * Specifying an explicit operation ID simplifies determining + * whether the statements were executed in the event that the + * {@link google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl|UpdateDatabaseDdl} call is replayed, + * or the return value is otherwise lost: the {@link google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database|database} and + * `operation_id` fields can be combined to form the + * {@link google.longrunning.Operation.name|name} of the resulting + * {@link google.longrunning.Operation|longrunning.Operation}: `/operations/`. + * + * `operation_id` should be unique within the database, and must be + * a valid identifier: `{@link a-z0-9_|a-z}*`. Note that + * automatically-generated operation IDs always begin with an + * underscore. If the named operation already exists, + * {@link google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl|UpdateDatabaseDdl} returns + * `ALREADY_EXISTS`. + * @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/v1/database_admin.update_database_ddl.js + * region_tag:spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_async + */ + updateDatabaseDdl( + request?: protos.google.spanner.admin.database.v1.IUpdateDatabaseDdlRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateDatabaseDdl( + request: protos.google.spanner.admin.database.v1.IUpdateDatabaseDdlRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateDatabaseDdl( + request: protos.google.spanner.admin.database.v1.IUpdateDatabaseDdlRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateDatabaseDdl( + request?: protos.google.spanner.admin.database.v1.IUpdateDatabaseDdlRequest, + 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 || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'database': request.database ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateDatabaseDdl(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateDatabaseDdl()`. + * @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/v1/database_admin.update_database_ddl.js + * region_tag:spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_async + */ + async checkUpdateDatabaseDdlProgress(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.updateDatabaseDdl, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts creating a new Cloud Spanner Backup. + * The returned backup {@link google.longrunning.Operation|long-running operation} + * will have a name of the format + * `projects//instances//backups//operations/` + * and can be used to track creation of the backup. The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. The + * {@link google.longrunning.Operation.response|response} field type is + * {@link google.spanner.admin.database.v1.Backup|Backup}, if successful. Cancelling the returned operation will stop the + * creation and delete the backup. + * There can be only one pending backup creation per database. Backup creation + * of different databases can run concurrently. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the instance in which the backup will be + * created. This must be the same instance that contains the database the + * backup will be created from. The backup will be stored in the + * location(s) specified in the instance configuration of this + * instance. Values are of the form + * `projects//instances/`. + * @param {string} request.backupId + * Required. The id of the backup to be created. The `backup_id` appended to + * `parent` forms the full backup name of the form + * `projects//instances//backups/`. + * @param {google.spanner.admin.database.v1.Backup} request.backup + * Required. The backup to create. + * @param {google.spanner.admin.database.v1.CreateBackupEncryptionConfig} [request.encryptionConfig] + * Optional. The encryption configuration used to encrypt the backup. If this field is + * not specified, the backup will use the same + * encryption configuration as the database by default, namely + * {@link google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type|encryption_type} = + * `USE_DATABASE_ENCRYPTION`. + * @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/v1/database_admin.create_backup.js + * region_tag:spanner_v1_generated_DatabaseAdmin_CreateBackup_async + */ + createBackup( + request?: protos.google.spanner.admin.database.v1.ICreateBackupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createBackup( + request: protos.google.spanner.admin.database.v1.ICreateBackupRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createBackup( + request: protos.google.spanner.admin.database.v1.ICreateBackupRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createBackup( + request?: protos.google.spanner.admin.database.v1.ICreateBackupRequest, + 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 || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createBackup(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createBackup()`. + * @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/v1/database_admin.create_backup.js + * region_tag:spanner_v1_generated_DatabaseAdmin_CreateBackup_async + */ + async checkCreateBackupProgress(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.createBackup, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts copying a Cloud Spanner Backup. + * The returned backup {@link google.longrunning.Operation|long-running operation} + * will have a name of the format + * `projects//instances//backups//operations/` + * and can be used to track copying of the backup. The operation is associated + * with the destination backup. + * The {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata}. + * The {@link google.longrunning.Operation.response|response} field type is + * {@link google.spanner.admin.database.v1.Backup|Backup}, if successful. Cancelling the returned operation will stop the + * copying and delete the backup. + * Concurrent CopyBackup requests can run on the same source backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the destination instance that will contain the backup copy. + * Values are of the form: `projects//instances/`. + * @param {string} request.backupId + * Required. The id of the backup copy. + * The `backup_id` appended to `parent` forms the full backup_uri of the form + * `projects//instances//backups/`. + * @param {string} request.sourceBackup + * Required. The source backup to be copied. + * The source backup needs to be in READY state for it to be copied. + * Once CopyBackup is in progress, the source backup cannot be deleted or + * cleaned up on expiration until CopyBackup is finished. + * Values are of the form: + * `projects//instances//backups/`. + * @param {google.protobuf.Timestamp} request.expireTime + * Required. The expiration time of the backup in microsecond granularity. + * The expiration time must be at least 6 hours and at most 366 days + * from the `create_time` of the source backup. Once the `expire_time` has + * passed, the backup is eligible to be automatically deleted by Cloud Spanner + * to free the resources used by the backup. + * @param {google.spanner.admin.database.v1.CopyBackupEncryptionConfig} [request.encryptionConfig] + * Optional. The encryption configuration used to encrypt the backup. If this field is + * not specified, the backup will use the same + * encryption configuration as the source backup by default, namely + * {@link google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type|encryption_type} = + * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * @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/v1/database_admin.copy_backup.js + * region_tag:spanner_v1_generated_DatabaseAdmin_CopyBackup_async + */ + copyBackup( + request?: protos.google.spanner.admin.database.v1.ICopyBackupRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + copyBackup( + request: protos.google.spanner.admin.database.v1.ICopyBackupRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + copyBackup( + request: protos.google.spanner.admin.database.v1.ICopyBackupRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + copyBackup( + request?: protos.google.spanner.admin.database.v1.ICopyBackupRequest, + 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 || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.copyBackup(request, options, callback); + } +/** + * Check the status of the long running operation returned by `copyBackup()`. + * @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/v1/database_admin.copy_backup.js + * region_tag:spanner_v1_generated_DatabaseAdmin_CopyBackup_async + */ + async checkCopyBackupProgress(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.copyBackup, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Create a new database by restoring from a completed backup. The new + * database must be in the same project and in an instance with the same + * instance configuration as the instance containing + * the backup. The returned database [long-running + * operation][google.longrunning.Operation] has a name of the format + * `projects//instances//databases//operations/`, + * and can be used to track the progress of the operation, and to cancel it. + * The {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata}. + * The {@link google.longrunning.Operation.response|response} type + * is {@link google.spanner.admin.database.v1.Database|Database}, if + * successful. Cancelling the returned operation will stop the restore and + * delete the database. + * There can be only one database being restored into an instance at a time. + * Once the restore operation completes, a new restore operation can be + * initiated, without waiting for the optimize operation associated with the + * first restore to complete. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the instance in which to create the + * restored database. This instance must be in the same project and + * have the same instance configuration as the instance containing + * the source backup. Values are of the form + * `projects//instances/`. + * @param {string} request.databaseId + * Required. The id of the database to create and restore to. This + * database must not already exist. The `database_id` appended to + * `parent` forms the full database name of the form + * `projects//instances//databases/`. + * @param {string} request.backup + * Name of the backup from which to restore. Values are of the form + * `projects//instances//backups/`. + * @param {google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig} [request.encryptionConfig] + * Optional. An encryption configuration describing the encryption type and key + * resources in Cloud KMS used to encrypt/decrypt the database to restore to. + * If this field is not specified, the restored database will use + * the same encryption configuration as the backup by default, namely + * {@link google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type|encryption_type} = + * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. + * @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/v1/database_admin.restore_database.js + * region_tag:spanner_v1_generated_DatabaseAdmin_RestoreDatabase_async + */ + restoreDatabase( + request?: protos.google.spanner.admin.database.v1.IRestoreDatabaseRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + restoreDatabase( + request: protos.google.spanner.admin.database.v1.IRestoreDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + restoreDatabase( + request: protos.google.spanner.admin.database.v1.IRestoreDatabaseRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + restoreDatabase( + request?: protos.google.spanner.admin.database.v1.IRestoreDatabaseRequest, + 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 || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.restoreDatabase(request, options, callback); + } +/** + * Check the status of the long running operation returned by `restoreDatabase()`. + * @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/v1/database_admin.restore_database.js + * region_tag:spanner_v1_generated_DatabaseAdmin_RestoreDatabase_async + */ + async checkRestoreDatabaseProgress(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.restoreDatabase, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists Cloud Spanner databases. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The instance whose databases should be listed. + * Values are of the form `projects//instances/`. + * @param {number} request.pageSize + * Number of databases to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token|next_page_token} from a + * previous {@link google.spanner.admin.database.v1.ListDatabasesResponse|ListDatabasesResponse}. + * @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 {@link google.spanner.admin.database.v1.Database | Database}. + * 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 `listDatabasesAsync()` + * 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. + */ + listDatabases( + request?: protos.google.spanner.admin.database.v1.IListDatabasesRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.database.v1.IDatabase[], + protos.google.spanner.admin.database.v1.IListDatabasesRequest|null, + protos.google.spanner.admin.database.v1.IListDatabasesResponse + ]>; + listDatabases( + request: protos.google.spanner.admin.database.v1.IListDatabasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabasesRequest, + protos.google.spanner.admin.database.v1.IListDatabasesResponse|null|undefined, + protos.google.spanner.admin.database.v1.IDatabase>): void; + listDatabases( + request: protos.google.spanner.admin.database.v1.IListDatabasesRequest, + callback: PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabasesRequest, + protos.google.spanner.admin.database.v1.IListDatabasesResponse|null|undefined, + protos.google.spanner.admin.database.v1.IDatabase>): void; + listDatabases( + request?: protos.google.spanner.admin.database.v1.IListDatabasesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabasesRequest, + protos.google.spanner.admin.database.v1.IListDatabasesResponse|null|undefined, + protos.google.spanner.admin.database.v1.IDatabase>, + callback?: PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabasesRequest, + protos.google.spanner.admin.database.v1.IListDatabasesResponse|null|undefined, + protos.google.spanner.admin.database.v1.IDatabase>): + Promise<[ + protos.google.spanner.admin.database.v1.IDatabase[], + protos.google.spanner.admin.database.v1.IListDatabasesRequest|null, + protos.google.spanner.admin.database.v1.IListDatabasesResponse + ]>|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({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listDatabases(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 instance whose databases should be listed. + * Values are of the form `projects//instances/`. + * @param {number} request.pageSize + * Number of databases to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token|next_page_token} from a + * previous {@link google.spanner.admin.database.v1.ListDatabasesResponse|ListDatabasesResponse}. + * @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 {@link google.spanner.admin.database.v1.Database | Database} 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 `listDatabasesAsync()` + * 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. + */ + listDatabasesStream( + request?: protos.google.spanner.admin.database.v1.IListDatabasesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDatabases']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDatabases.createStream( + this.innerApiCalls.listDatabases as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listDatabases`, 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 instance whose databases should be listed. + * Values are of the form `projects//instances/`. + * @param {number} request.pageSize + * Number of databases to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token|next_page_token} from a + * previous {@link google.spanner.admin.database.v1.ListDatabasesResponse|ListDatabasesResponse}. + * @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 + * {@link google.spanner.admin.database.v1.Database | Database}. 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/v1/database_admin.list_databases.js + * region_tag:spanner_v1_generated_DatabaseAdmin_ListDatabases_async + */ + listDatabasesAsync( + request?: protos.google.spanner.admin.database.v1.IListDatabasesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDatabases']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDatabases.asyncIterate( + this.innerApiCalls['listDatabases'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists completed and pending backups. + * Backups returned are ordered by `create_time` in descending order, + * starting from the most recent `create_time`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The instance to list backups from. Values are of the + * form `projects//instances/`. + * @param {string} request.filter + * An expression that filters the list of returned backups. + * + * A filter expression consists of a field name, a comparison operator, and a + * value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.spanner.admin.database.v1.Backup|Backup} are eligible for filtering: + * + * * `name` + * * `database` + * * `state` + * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `name:Howl` - The backup's name contains the string "howl". + * * `database:prod` + * - The database's name contains the string "prod". + * * `state:CREATING` - The backup is pending creation. + * * `state:READY` - The backup is fully created and ready for use. + * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` + * - The backup name contains the string "howl" and `create_time` + * of the backup is before 2018-03-28T14:50:00Z. + * * `expire_time < \"2018-03-28T14:50:00Z\"` + * - The backup `expire_time` is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` - The backup's size is greater than 10GB + * @param {number} request.pageSize + * Number of backups to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListBackupsResponse.next_page_token|next_page_token} from a + * previous {@link google.spanner.admin.database.v1.ListBackupsResponse|ListBackupsResponse} to the same `parent` and with the same + * `filter`. + * @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 {@link google.spanner.admin.database.v1.Backup | Backup}. + * 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 `listBackupsAsync()` + * 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. + */ + listBackups( + request?: protos.google.spanner.admin.database.v1.IListBackupsRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.database.v1.IBackup[], + protos.google.spanner.admin.database.v1.IListBackupsRequest|null, + protos.google.spanner.admin.database.v1.IListBackupsResponse + ]>; + listBackups( + request: protos.google.spanner.admin.database.v1.IListBackupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.spanner.admin.database.v1.IListBackupsRequest, + protos.google.spanner.admin.database.v1.IListBackupsResponse|null|undefined, + protos.google.spanner.admin.database.v1.IBackup>): void; + listBackups( + request: protos.google.spanner.admin.database.v1.IListBackupsRequest, + callback: PaginationCallback< + protos.google.spanner.admin.database.v1.IListBackupsRequest, + protos.google.spanner.admin.database.v1.IListBackupsResponse|null|undefined, + protos.google.spanner.admin.database.v1.IBackup>): void; + listBackups( + request?: protos.google.spanner.admin.database.v1.IListBackupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.spanner.admin.database.v1.IListBackupsRequest, + protos.google.spanner.admin.database.v1.IListBackupsResponse|null|undefined, + protos.google.spanner.admin.database.v1.IBackup>, + callback?: PaginationCallback< + protos.google.spanner.admin.database.v1.IListBackupsRequest, + protos.google.spanner.admin.database.v1.IListBackupsResponse|null|undefined, + protos.google.spanner.admin.database.v1.IBackup>): + Promise<[ + protos.google.spanner.admin.database.v1.IBackup[], + protos.google.spanner.admin.database.v1.IListBackupsRequest|null, + protos.google.spanner.admin.database.v1.IListBackupsResponse + ]>|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({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listBackups(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 instance to list backups from. Values are of the + * form `projects//instances/`. + * @param {string} request.filter + * An expression that filters the list of returned backups. + * + * A filter expression consists of a field name, a comparison operator, and a + * value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.spanner.admin.database.v1.Backup|Backup} are eligible for filtering: + * + * * `name` + * * `database` + * * `state` + * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `name:Howl` - The backup's name contains the string "howl". + * * `database:prod` + * - The database's name contains the string "prod". + * * `state:CREATING` - The backup is pending creation. + * * `state:READY` - The backup is fully created and ready for use. + * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` + * - The backup name contains the string "howl" and `create_time` + * of the backup is before 2018-03-28T14:50:00Z. + * * `expire_time < \"2018-03-28T14:50:00Z\"` + * - The backup `expire_time` is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` - The backup's size is greater than 10GB + * @param {number} request.pageSize + * Number of backups to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListBackupsResponse.next_page_token|next_page_token} from a + * previous {@link google.spanner.admin.database.v1.ListBackupsResponse|ListBackupsResponse} to the same `parent` and with the same + * `filter`. + * @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 {@link google.spanner.admin.database.v1.Backup | Backup} 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 `listBackupsAsync()` + * 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. + */ + listBackupsStream( + request?: protos.google.spanner.admin.database.v1.IListBackupsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listBackups']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listBackups.createStream( + this.innerApiCalls.listBackups as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listBackups`, 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 instance to list backups from. Values are of the + * form `projects//instances/`. + * @param {string} request.filter + * An expression that filters the list of returned backups. + * + * A filter expression consists of a field name, a comparison operator, and a + * value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.spanner.admin.database.v1.Backup|Backup} are eligible for filtering: + * + * * `name` + * * `database` + * * `state` + * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `name:Howl` - The backup's name contains the string "howl". + * * `database:prod` + * - The database's name contains the string "prod". + * * `state:CREATING` - The backup is pending creation. + * * `state:READY` - The backup is fully created and ready for use. + * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` + * - The backup name contains the string "howl" and `create_time` + * of the backup is before 2018-03-28T14:50:00Z. + * * `expire_time < \"2018-03-28T14:50:00Z\"` + * - The backup `expire_time` is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` - The backup's size is greater than 10GB + * @param {number} request.pageSize + * Number of backups to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListBackupsResponse.next_page_token|next_page_token} from a + * previous {@link google.spanner.admin.database.v1.ListBackupsResponse|ListBackupsResponse} to the same `parent` and with the same + * `filter`. + * @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 + * {@link google.spanner.admin.database.v1.Backup | Backup}. 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/v1/database_admin.list_backups.js + * region_tag:spanner_v1_generated_DatabaseAdmin_ListBackups_async + */ + listBackupsAsync( + request?: protos.google.spanner.admin.database.v1.IListBackupsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listBackups']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listBackups.asyncIterate( + this.innerApiCalls['listBackups'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists database {@link google.longrunning.Operation|longrunning-operations}. + * A database operation has a name of the form + * `projects//instances//databases//operations/`. + * The long-running operation + * {@link google.longrunning.Operation.metadata|metadata} field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The instance of the database operations. + * Values are of the form `projects//instances/`. + * @param {string} request.filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|Operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata} is + * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ + * `(metadata.source_type:BACKUP) AND` \ + * `(metadata.backup_info.backup:backup_howl) AND` \ + * `(metadata.name:restored_howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata}. + * * The database is restored from a backup. + * * The backup name contains "backup_howl". + * * The restored database's name contains "restored_howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token|next_page_token} + * from a previous {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse|ListDatabaseOperationsResponse} to the + * same `parent` and with the same `filter`. + * @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 {@link google.longrunning.Operation | Operation}. + * 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 `listDatabaseOperationsAsync()` + * 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. + */ + listDatabaseOperations( + request?: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, + options?: CallOptions): + Promise<[ + protos.google.longrunning.IOperation[], + protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest|null, + protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse + ]>; + listDatabaseOperations( + request: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, + protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>): void; + listDatabaseOperations( + request: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, + callback: PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, + protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>): void; + listDatabaseOperations( + request?: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, + protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>, + callback?: PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, + protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>): + Promise<[ + protos.google.longrunning.IOperation[], + protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest|null, + protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse + ]>|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({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listDatabaseOperations(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 instance of the database operations. + * Values are of the form `projects//instances/`. + * @param {string} request.filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|Operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata} is + * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ + * `(metadata.source_type:BACKUP) AND` \ + * `(metadata.backup_info.backup:backup_howl) AND` \ + * `(metadata.name:restored_howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata}. + * * The database is restored from a backup. + * * The backup name contains "backup_howl". + * * The restored database's name contains "restored_howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token|next_page_token} + * from a previous {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse|ListDatabaseOperationsResponse} to the + * same `parent` and with the same `filter`. + * @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 {@link google.longrunning.Operation | Operation} 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 `listDatabaseOperationsAsync()` + * 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. + */ + listDatabaseOperationsStream( + request?: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDatabaseOperations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDatabaseOperations.createStream( + this.innerApiCalls.listDatabaseOperations as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listDatabaseOperations`, 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 instance of the database operations. + * Values are of the form `projects//instances/`. + * @param {string} request.filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|Operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata} is + * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ + * `(metadata.source_type:BACKUP) AND` \ + * `(metadata.backup_info.backup:backup_howl) AND` \ + * `(metadata.name:restored_howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata}. + * * The database is restored from a backup. + * * The backup name contains "backup_howl". + * * The restored database's name contains "restored_howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token|next_page_token} + * from a previous {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse|ListDatabaseOperationsResponse} to the + * same `parent` and with the same `filter`. + * @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 + * {@link google.longrunning.Operation | Operation}. 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/v1/database_admin.list_database_operations.js + * region_tag:spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_async + */ + listDatabaseOperationsAsync( + request?: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDatabaseOperations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDatabaseOperations.asyncIterate( + this.innerApiCalls['listDatabaseOperations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the backup {@link google.longrunning.Operation|long-running operations} in + * the given instance. A backup operation has a name of the form + * `projects//instances//backups//operations/`. + * The long-running operation + * {@link google.longrunning.Operation.metadata|metadata} field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.progress.start_time` in descending order starting + * from the most recently started operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The instance of the backup operations. Values are of + * the form `projects//instances/`. + * @param {string} request.filter + * An expression that filters the list of returned backup operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} is + * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `metadata.database:prod` - Returns operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. + * * The database the backup was taken from has a name containing the + * string "prod". + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.name:howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. + * * The backup name contains the string "howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ + * `(metadata.source_backup:test) AND` \ + * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata}. + * * The source backup of the copied backup name contains the string + * "test". + * * The operation started before 2022-01-18T14:50:00Z. + * * The operation resulted in an error. + * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.database:test_db)) OR` \ + * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) + * AND` \ + * `(metadata.source_backup:test_bkp)) AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata matches either of criteria: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} AND the + * database the backup was taken from has name containing string + * "test_db" + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata} AND the + * backup the backup was copied from has name containing string + * "test_bkp" + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token|next_page_token} + * from a previous {@link google.spanner.admin.database.v1.ListBackupOperationsResponse|ListBackupOperationsResponse} to the + * same `parent` and with the same `filter`. + * @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 {@link google.longrunning.Operation | Operation}. + * 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 `listBackupOperationsAsync()` + * 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. + */ + listBackupOperations( + request?: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, + options?: CallOptions): + Promise<[ + protos.google.longrunning.IOperation[], + protos.google.spanner.admin.database.v1.IListBackupOperationsRequest|null, + protos.google.spanner.admin.database.v1.IListBackupOperationsResponse + ]>; + listBackupOperations( + request: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, + protos.google.spanner.admin.database.v1.IListBackupOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>): void; + listBackupOperations( + request: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, + callback: PaginationCallback< + protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, + protos.google.spanner.admin.database.v1.IListBackupOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>): void; + listBackupOperations( + request?: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, + protos.google.spanner.admin.database.v1.IListBackupOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>, + callback?: PaginationCallback< + protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, + protos.google.spanner.admin.database.v1.IListBackupOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>): + Promise<[ + protos.google.longrunning.IOperation[], + protos.google.spanner.admin.database.v1.IListBackupOperationsRequest|null, + protos.google.spanner.admin.database.v1.IListBackupOperationsResponse + ]>|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({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listBackupOperations(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 instance of the backup operations. Values are of + * the form `projects//instances/`. + * @param {string} request.filter + * An expression that filters the list of returned backup operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} is + * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `metadata.database:prod` - Returns operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. + * * The database the backup was taken from has a name containing the + * string "prod". + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.name:howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. + * * The backup name contains the string "howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ + * `(metadata.source_backup:test) AND` \ + * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata}. + * * The source backup of the copied backup name contains the string + * "test". + * * The operation started before 2022-01-18T14:50:00Z. + * * The operation resulted in an error. + * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.database:test_db)) OR` \ + * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) + * AND` \ + * `(metadata.source_backup:test_bkp)) AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata matches either of criteria: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} AND the + * database the backup was taken from has name containing string + * "test_db" + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata} AND the + * backup the backup was copied from has name containing string + * "test_bkp" + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token|next_page_token} + * from a previous {@link google.spanner.admin.database.v1.ListBackupOperationsResponse|ListBackupOperationsResponse} to the + * same `parent` and with the same `filter`. + * @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 {@link google.longrunning.Operation | Operation} 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 `listBackupOperationsAsync()` + * 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. + */ + listBackupOperationsStream( + request?: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listBackupOperations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listBackupOperations.createStream( + this.innerApiCalls.listBackupOperations as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listBackupOperations`, 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 instance of the backup operations. Values are of + * the form `projects//instances/`. + * @param {string} request.filter + * An expression that filters the list of returned backup operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} is + * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic, but + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `metadata.database:prod` - Returns operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. + * * The database the backup was taken from has a name containing the + * string "prod". + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.name:howl) AND` \ + * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. + * * The backup name contains the string "howl". + * * The operation started before 2018-03-28T14:50:00Z. + * * The operation resulted in an error. + * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ + * `(metadata.source_backup:test) AND` \ + * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata}. + * * The source backup of the copied backup name contains the string + * "test". + * * The operation started before 2022-01-18T14:50:00Z. + * * The operation resulted in an error. + * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ + * `(metadata.database:test_db)) OR` \ + * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) + * AND` \ + * `(metadata.source_backup:test_bkp)) AND` \ + * `(error:*)` - Returns operations where: + * * The operation's metadata matches either of criteria: + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} AND the + * database the backup was taken from has name containing string + * "test_db" + * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata} AND the + * backup the backup was copied from has name containing string + * "test_bkp" + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token|next_page_token} + * from a previous {@link google.spanner.admin.database.v1.ListBackupOperationsResponse|ListBackupOperationsResponse} to the + * same `parent` and with the same `filter`. + * @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 + * {@link google.longrunning.Operation | Operation}. 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/v1/database_admin.list_backup_operations.js + * region_tag:spanner_v1_generated_DatabaseAdmin_ListBackupOperations_async + */ + listBackupOperationsAsync( + request?: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listBackupOperations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listBackupOperations.asyncIterate( + this.innerApiCalls['listBackupOperations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists Cloud Spanner database roles. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The database whose roles should be listed. + * Values are of the form + * `projects//instances//databases//databaseRoles`. + * @param {number} request.pageSize + * Number of database roles to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token|next_page_token} from a + * previous {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse|ListDatabaseRolesResponse}. + * @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 {@link google.spanner.admin.database.v1.DatabaseRole | DatabaseRole}. + * 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 `listDatabaseRolesAsync()` + * 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. + */ + listDatabaseRoles( + request?: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.database.v1.IDatabaseRole[], + protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest|null, + protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse + ]>; + listDatabaseRoles( + request: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, + protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse|null|undefined, + protos.google.spanner.admin.database.v1.IDatabaseRole>): void; + listDatabaseRoles( + request: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, + callback: PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, + protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse|null|undefined, + protos.google.spanner.admin.database.v1.IDatabaseRole>): void; + listDatabaseRoles( + request?: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, + protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse|null|undefined, + protos.google.spanner.admin.database.v1.IDatabaseRole>, + callback?: PaginationCallback< + protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, + protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse|null|undefined, + protos.google.spanner.admin.database.v1.IDatabaseRole>): + Promise<[ + protos.google.spanner.admin.database.v1.IDatabaseRole[], + protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest|null, + protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse + ]>|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({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listDatabaseRoles(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 database whose roles should be listed. + * Values are of the form + * `projects//instances//databases//databaseRoles`. + * @param {number} request.pageSize + * Number of database roles to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token|next_page_token} from a + * previous {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse|ListDatabaseRolesResponse}. + * @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 {@link google.spanner.admin.database.v1.DatabaseRole | DatabaseRole} 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 `listDatabaseRolesAsync()` + * 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. + */ + listDatabaseRolesStream( + request?: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDatabaseRoles']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDatabaseRoles.createStream( + this.innerApiCalls.listDatabaseRoles as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listDatabaseRoles`, 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 database whose roles should be listed. + * Values are of the form + * `projects//instances//databases//databaseRoles`. + * @param {number} request.pageSize + * Number of database roles to be returned in the response. If 0 or less, + * defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token|next_page_token} from a + * previous {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse|ListDatabaseRolesResponse}. + * @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 + * {@link google.spanner.admin.database.v1.DatabaseRole | DatabaseRole}. 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/v1/database_admin.list_database_roles.js + * region_tag:spanner_v1_generated_DatabaseAdmin_ListDatabaseRoles_async + */ + listDatabaseRolesAsync( + request?: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDatabaseRoles']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDatabaseRoles.asyncIterate( + this.innerApiCalls['listDatabaseRoles'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified backup resource name string. + * + * @param {string} project + * @param {string} instance + * @param {string} backup + * @returns {string} Resource name string. + */ + backupPath(project:string,instance:string,backup:string) { + return this.pathTemplates.backupPathTemplate.render({ + project: project, + instance: instance, + backup: backup, + }); + } + + /** + * Parse the project from Backup resource. + * + * @param {string} backupName + * A fully-qualified path representing Backup resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBackupName(backupName: string) { + return this.pathTemplates.backupPathTemplate.match(backupName).project; + } + + /** + * Parse the instance from Backup resource. + * + * @param {string} backupName + * A fully-qualified path representing Backup resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromBackupName(backupName: string) { + return this.pathTemplates.backupPathTemplate.match(backupName).instance; + } + + /** + * Parse the backup from Backup resource. + * + * @param {string} backupName + * A fully-qualified path representing Backup resource. + * @returns {string} A string representing the backup. + */ + matchBackupFromBackupName(backupName: string) { + return this.pathTemplates.backupPathTemplate.match(backupName).backup; + } + + /** + * 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 database resource name string. + * + * @param {string} project + * @param {string} instance + * @param {string} database + * @returns {string} Resource name string. + */ + databasePath(project:string,instance:string,database:string) { + return this.pathTemplates.databasePathTemplate.render({ + project: project, + instance: instance, + database: database, + }); + } + + /** + * Parse the project from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDatabaseName(databaseName: string) { + return this.pathTemplates.databasePathTemplate.match(databaseName).project; + } + + /** + * Parse the instance from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromDatabaseName(databaseName: string) { + return this.pathTemplates.databasePathTemplate.match(databaseName).instance; + } + + /** + * Parse the database from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromDatabaseName(databaseName: string) { + return this.pathTemplates.databasePathTemplate.match(databaseName).database; + } + + /** + * Return a fully-qualified databaseRole resource name string. + * + * @param {string} project + * @param {string} instance + * @param {string} database + * @param {string} role + * @returns {string} Resource name string. + */ + databaseRolePath(project:string,instance:string,database:string,role:string) { + return this.pathTemplates.databaseRolePathTemplate.render({ + project: project, + instance: instance, + database: database, + role: role, + }); + } + + /** + * Parse the project from DatabaseRole resource. + * + * @param {string} databaseRoleName + * A fully-qualified path representing DatabaseRole resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDatabaseRoleName(databaseRoleName: string) { + return this.pathTemplates.databaseRolePathTemplate.match(databaseRoleName).project; + } + + /** + * Parse the instance from DatabaseRole resource. + * + * @param {string} databaseRoleName + * A fully-qualified path representing DatabaseRole resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromDatabaseRoleName(databaseRoleName: string) { + return this.pathTemplates.databaseRolePathTemplate.match(databaseRoleName).instance; + } + + /** + * Parse the database from DatabaseRole resource. + * + * @param {string} databaseRoleName + * A fully-qualified path representing DatabaseRole resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromDatabaseRoleName(databaseRoleName: string) { + return this.pathTemplates.databaseRolePathTemplate.match(databaseRoleName).database; + } + + /** + * Parse the role from DatabaseRole resource. + * + * @param {string} databaseRoleName + * A fully-qualified path representing DatabaseRole resource. + * @returns {string} A string representing the role. + */ + matchRoleFromDatabaseRoleName(databaseRoleName: string) { + return this.pathTemplates.databaseRolePathTemplate.match(databaseRoleName).role; + } + + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + + /** + * 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.databaseAdminStub && !this._terminated) { + return this.databaseAdminStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/admin/database/v1/src/v1/database_admin_client_config.json b/owl-bot-staging/admin/database/v1/src/v1/database_admin_client_config.json new file mode 100644 index 000000000..035f43bc8 --- /dev/null +++ b/owl-bot-staging/admin/database/v1/src/v1/database_admin_client_config.json @@ -0,0 +1,130 @@ +{ + "interfaces": { + "google.spanner.admin.database.v1.DatabaseAdmin": { + "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 + }, + "e9fafda332ce8a1702dc1575de3ca81c4feb4799": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 32000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListDatabases": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "CreateDatabase": { + "timeout_millis": 3600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetDatabase": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "UpdateDatabaseDdl": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "DropDatabase": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "GetDatabaseDdl": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "SetIamPolicy": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "TestIamPermissions": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateBackup": { + "timeout_millis": 3600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CopyBackup": { + "timeout_millis": 3600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetBackup": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "UpdateBackup": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "DeleteBackup": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "ListBackups": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "RestoreDatabase": { + "timeout_millis": 3600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListDatabaseOperations": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "ListBackupOperations": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "ListDatabaseRoles": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + } + } + } + } +} diff --git a/owl-bot-staging/admin/database/v1/src/v1/database_admin_proto_list.json b/owl-bot-staging/admin/database/v1/src/v1/database_admin_proto_list.json new file mode 100644 index 000000000..c20bcc2fc --- /dev/null +++ b/owl-bot-staging/admin/database/v1/src/v1/database_admin_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/spanner/admin/database/v1/backup.proto", + "../../protos/google/spanner/admin/database/v1/common.proto", + "../../protos/google/spanner/admin/database/v1/spanner_database_admin.proto" +] diff --git a/owl-bot-staging/admin/database/v1/src/v1/gapic_metadata.json b/owl-bot-staging/admin/database/v1/src/v1/gapic_metadata.json new file mode 100644 index 000000000..95da9430f --- /dev/null +++ b/owl-bot-staging/admin/database/v1/src/v1/gapic_metadata.json @@ -0,0 +1,233 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.spanner.admin.database.v1", + "libraryPackage": "@google-cloud/spanner", + "services": { + "DatabaseAdmin": { + "clients": { + "grpc": { + "libraryClient": "DatabaseAdminClient", + "rpcs": { + "GetDatabase": { + "methods": [ + "getDatabase" + ] + }, + "DropDatabase": { + "methods": [ + "dropDatabase" + ] + }, + "GetDatabaseDdl": { + "methods": [ + "getDatabaseDdl" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "GetBackup": { + "methods": [ + "getBackup" + ] + }, + "UpdateBackup": { + "methods": [ + "updateBackup" + ] + }, + "DeleteBackup": { + "methods": [ + "deleteBackup" + ] + }, + "CreateDatabase": { + "methods": [ + "createDatabase" + ] + }, + "UpdateDatabaseDdl": { + "methods": [ + "updateDatabaseDdl" + ] + }, + "CreateBackup": { + "methods": [ + "createBackup" + ] + }, + "CopyBackup": { + "methods": [ + "copyBackup" + ] + }, + "RestoreDatabase": { + "methods": [ + "restoreDatabase" + ] + }, + "ListDatabases": { + "methods": [ + "listDatabases", + "listDatabasesStream", + "listDatabasesAsync" + ] + }, + "ListBackups": { + "methods": [ + "listBackups", + "listBackupsStream", + "listBackupsAsync" + ] + }, + "ListDatabaseOperations": { + "methods": [ + "listDatabaseOperations", + "listDatabaseOperationsStream", + "listDatabaseOperationsAsync" + ] + }, + "ListBackupOperations": { + "methods": [ + "listBackupOperations", + "listBackupOperationsStream", + "listBackupOperationsAsync" + ] + }, + "ListDatabaseRoles": { + "methods": [ + "listDatabaseRoles", + "listDatabaseRolesStream", + "listDatabaseRolesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DatabaseAdminClient", + "rpcs": { + "GetDatabase": { + "methods": [ + "getDatabase" + ] + }, + "DropDatabase": { + "methods": [ + "dropDatabase" + ] + }, + "GetDatabaseDdl": { + "methods": [ + "getDatabaseDdl" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "GetBackup": { + "methods": [ + "getBackup" + ] + }, + "UpdateBackup": { + "methods": [ + "updateBackup" + ] + }, + "DeleteBackup": { + "methods": [ + "deleteBackup" + ] + }, + "CreateDatabase": { + "methods": [ + "createDatabase" + ] + }, + "UpdateDatabaseDdl": { + "methods": [ + "updateDatabaseDdl" + ] + }, + "CreateBackup": { + "methods": [ + "createBackup" + ] + }, + "CopyBackup": { + "methods": [ + "copyBackup" + ] + }, + "RestoreDatabase": { + "methods": [ + "restoreDatabase" + ] + }, + "ListDatabases": { + "methods": [ + "listDatabases", + "listDatabasesStream", + "listDatabasesAsync" + ] + }, + "ListBackups": { + "methods": [ + "listBackups", + "listBackupsStream", + "listBackupsAsync" + ] + }, + "ListDatabaseOperations": { + "methods": [ + "listDatabaseOperations", + "listDatabaseOperationsStream", + "listDatabaseOperationsAsync" + ] + }, + "ListBackupOperations": { + "methods": [ + "listBackupOperations", + "listBackupOperationsStream", + "listBackupOperationsAsync" + ] + }, + "ListDatabaseRoles": { + "methods": [ + "listDatabaseRoles", + "listDatabaseRolesStream", + "listDatabaseRolesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/admin/database/v1/src/v1/index.ts b/owl-bot-staging/admin/database/v1/src/v1/index.ts new file mode 100644 index 000000000..09d882a27 --- /dev/null +++ b/owl-bot-staging/admin/database/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 {DatabaseAdminClient} from './database_admin_client'; diff --git a/owl-bot-staging/admin/database/v1/test/gapic_database_admin_v1.ts b/owl-bot-staging/admin/database/v1/test/gapic_database_admin_v1.ts new file mode 100644 index 000000000..0e6b3f948 --- /dev/null +++ b/owl-bot-staging/admin/database/v1/test/gapic_database_admin_v1.ts @@ -0,0 +1,3680 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 databaseadminModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +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('v1.DatabaseAdminClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = databaseadminModule.v1.DatabaseAdminClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = databaseadminModule.v1.DatabaseAdminClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = databaseadminModule.v1.DatabaseAdminClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new databaseadminModule.v1.DatabaseAdminClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.databaseAdminStub, undefined); + await client.initialize(); + assert(client.databaseAdminStub); + }); + + it('has close method for the initialized client', done => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.databaseAdminStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.databaseAdminStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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 databaseadminModule.v1.DatabaseAdminClient({ + 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('getDatabase', () => { + it('invokes getDatabase without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.database.v1.Database() + ); + client.innerApiCalls.getDatabase = stubSimpleCall(expectedResponse); + const [response] = await client.getDatabase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDatabase without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.database.v1.Database() + ); + client.innerApiCalls.getDatabase = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDatabase( + request, + (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IDatabase|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDatabase with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDatabase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDatabase(request), expectedError); + const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDatabase with closed client', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDatabase(request), expectedError); + }); + }); + + describe('dropDatabase', () => { + it('invokes dropDatabase without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.DropDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.DropDatabaseRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.dropDatabase = stubSimpleCall(expectedResponse); + const [response] = await client.dropDatabase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.dropDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.dropDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes dropDatabase without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.DropDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.DropDatabaseRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.dropDatabase = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.dropDatabase( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.dropDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.dropDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes dropDatabase with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.DropDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.DropDatabaseRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.dropDatabase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.dropDatabase(request), expectedError); + const actualRequest = (client.innerApiCalls.dropDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.dropDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes dropDatabase with closed client', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.DropDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.DropDatabaseRequest', ['database']); + request.database = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.dropDatabase(request), expectedError); + }); + }); + + describe('getDatabaseDdl', () => { + it('invokes getDatabaseDdl without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseDdlRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetDatabaseDdlResponse() + ); + client.innerApiCalls.getDatabaseDdl = stubSimpleCall(expectedResponse); + const [response] = await client.getDatabaseDdl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDatabaseDdl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabaseDdl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDatabaseDdl without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseDdlRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetDatabaseDdlResponse() + ); + client.innerApiCalls.getDatabaseDdl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDatabaseDdl( + request, + (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDatabaseDdl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabaseDdl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDatabaseDdl with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseDdlRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDatabaseDdl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDatabaseDdl(request), expectedError); + const actualRequest = (client.innerApiCalls.getDatabaseDdl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabaseDdl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDatabaseDdl with closed client', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseDdlRequest', ['database']); + request.database = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDatabaseDdl(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('getBackup', () => { + it('invokes getBackup without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetBackupRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.database.v1.Backup() + ); + client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); + const [response] = await client.getBackup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getBackup without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetBackupRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.database.v1.Backup() + ); + client.innerApiCalls.getBackup = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackup( + request, + (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IBackup|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getBackup with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetBackupRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getBackup(request), expectedError); + const actualRequest = (client.innerApiCalls.getBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getBackup with closed client', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.GetBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.GetBackupRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getBackup(request), expectedError); + }); + }); + + describe('updateBackup', () => { + it('invokes updateBackup without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.UpdateBackupRequest() + ); + request.backup ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateBackupRequest', ['backup', 'name']); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.database.v1.Backup() + ); + client.innerApiCalls.updateBackup = stubSimpleCall(expectedResponse); + const [response] = await client.updateBackup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateBackup without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.UpdateBackupRequest() + ); + request.backup ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateBackupRequest', ['backup', 'name']); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.database.v1.Backup() + ); + client.innerApiCalls.updateBackup = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateBackup( + request, + (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IBackup|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateBackup with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.UpdateBackupRequest() + ); + request.backup ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateBackupRequest', ['backup', 'name']); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBackup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateBackup(request), expectedError); + const actualRequest = (client.innerApiCalls.updateBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateBackup with closed client', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.UpdateBackupRequest() + ); + request.backup ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateBackupRequest', ['backup', 'name']); + request.backup.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateBackup(request), expectedError); + }); + }); + + describe('deleteBackup', () => { + it('invokes deleteBackup without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.DeleteBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.DeleteBackupRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteBackup = stubSimpleCall(expectedResponse); + const [response] = await client.deleteBackup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteBackup without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.DeleteBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.DeleteBackupRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteBackup = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackup( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteBackup with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.DeleteBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.DeleteBackupRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteBackup(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteBackup with closed client', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.DeleteBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.DeleteBackupRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteBackup(request), expectedError); + }); + }); + + describe('createDatabase', () => { + it('invokes createDatabase without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createDatabase = stubLongRunningCall(expectedResponse); + const [operation] = await client.createDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDatabase without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createDatabase = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDatabase( + 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); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDatabase with call error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createDatabase(request), expectedError); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDatabase with LRO error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateDatabaseProgress without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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.checkCreateDatabaseProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateDatabaseProgress with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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.checkCreateDatabaseProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateDatabaseDdl', () => { + it('invokes updateDatabaseDdl without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateDatabaseDdl = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateDatabaseDdl(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDatabaseDdl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabaseDdl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDatabaseDdl without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateDatabaseDdl = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDatabaseDdl( + 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); + const actualRequest = (client.innerApiCalls.updateDatabaseDdl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabaseDdl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDatabaseDdl with call error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDatabaseDdl = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateDatabaseDdl(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDatabaseDdl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabaseDdl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDatabaseDdl with LRO error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDatabaseDdl = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateDatabaseDdl(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateDatabaseDdl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabaseDdl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateDatabaseDdlProgress without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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.checkUpdateDatabaseDdlProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateDatabaseDdlProgress with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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.checkUpdateDatabaseDdlProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createBackup', () => { + it('invokes createBackup without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CreateBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CreateBackupRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.createBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createBackup without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CreateBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CreateBackupRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createBackup = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBackup( + 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); + const actualRequest = (client.innerApiCalls.createBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createBackup with call error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CreateBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CreateBackupRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createBackup(request), expectedError); + const actualRequest = (client.innerApiCalls.createBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createBackup with LRO error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CreateBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CreateBackupRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateBackupProgress without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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.checkCreateBackupProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateBackupProgress with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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.checkCreateBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('copyBackup', () => { + it('invokes copyBackup without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CopyBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CopyBackupRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.copyBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.copyBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes copyBackup without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CopyBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CopyBackupRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.copyBackup = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.copyBackup( + 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); + const actualRequest = (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes copyBackup with call error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CopyBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CopyBackupRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.copyBackup = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.copyBackup(request), expectedError); + const actualRequest = (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes copyBackup with LRO error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.CopyBackupRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.CopyBackupRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.copyBackup = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.copyBackup(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCopyBackupProgress without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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.checkCopyBackupProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCopyBackupProgress with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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.checkCopyBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('restoreDatabase', () => { + it('invokes restoreDatabase without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.RestoreDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.restoreDatabase = stubLongRunningCall(expectedResponse); + const [operation] = await client.restoreDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.restoreDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.restoreDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restoreDatabase without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.RestoreDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.restoreDatabase = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restoreDatabase( + 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); + const actualRequest = (client.innerApiCalls.restoreDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.restoreDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restoreDatabase with call error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.RestoreDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreDatabase = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.restoreDatabase(request), expectedError); + const actualRequest = (client.innerApiCalls.restoreDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.restoreDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restoreDatabase with LRO error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.RestoreDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreDatabase = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.restoreDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.restoreDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.restoreDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRestoreDatabaseProgress without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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.checkRestoreDatabaseProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRestoreDatabaseProgress with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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.checkRestoreDatabaseProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listDatabases', () => { + it('invokes listDatabases without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabasesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + ]; + client.innerApiCalls.listDatabases = stubSimpleCall(expectedResponse); + const [response] = await client.listDatabases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDatabases without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabasesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + ]; + client.innerApiCalls.listDatabases = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDatabases( + request, + (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IDatabase[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDatabases with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabasesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDatabases = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDatabases(request), expectedError); + const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDatabasesStream without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabasesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + ]; + client.descriptors.page.listDatabases.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listDatabasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.admin.database.v1.Database[] = []; + stream.on('data', (response: protos.google.spanner.admin.database.v1.Database) => { + 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.listDatabases.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDatabases, request)); + assert( + (client.descriptors.page.listDatabases.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listDatabasesStream with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabasesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatabases.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listDatabasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.admin.database.v1.Database[] = []; + stream.on('data', (response: protos.google.spanner.admin.database.v1.Database) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listDatabases.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDatabases, request)); + assert( + (client.descriptors.page.listDatabases.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDatabases without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabasesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), + ]; + client.descriptors.page.listDatabases.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.spanner.admin.database.v1.IDatabase[] = []; + const iterable = client.listDatabasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDatabases.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDatabases.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDatabases with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabasesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatabases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDatabasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.spanner.admin.database.v1.IDatabase[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDatabases.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDatabases.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listBackups', () => { + it('invokes listBackups without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + ]; + client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); + const [response] = await client.listBackups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listBackups as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listBackups without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + ]; + client.innerApiCalls.listBackups = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackups( + request, + (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IBackup[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listBackups as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listBackups with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackups = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listBackups(request), expectedError); + const actualRequest = (client.innerApiCalls.listBackups as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listBackupsStream without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + ]; + client.descriptors.page.listBackups.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.admin.database.v1.Backup[] = []; + stream.on('data', (response: protos.google.spanner.admin.database.v1.Backup) => { + 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.listBackups.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listBackupsStream with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.admin.database.v1.Backup[] = []; + stream.on('data', (response: protos.google.spanner.admin.database.v1.Backup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listBackups without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), + ]; + client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.spanner.admin.database.v1.IBackup[] = []; + const iterable = client.listBackupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listBackups with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBackupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.spanner.admin.database.v1.IBackup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listBackups.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listDatabaseOperations', () => { + it('invokes listDatabaseOperations without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.innerApiCalls.listDatabaseOperations = stubSimpleCall(expectedResponse); + const [response] = await client.listDatabaseOperations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDatabaseOperations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseOperations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDatabaseOperations without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.innerApiCalls.listDatabaseOperations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDatabaseOperations( + request, + (err?: Error|null, result?: protos.google.longrunning.IOperation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDatabaseOperations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseOperations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDatabaseOperations with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDatabaseOperations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDatabaseOperations(request), expectedError); + const actualRequest = (client.innerApiCalls.listDatabaseOperations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseOperations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDatabaseOperationsStream without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.descriptors.page.listDatabaseOperations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listDatabaseOperationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.longrunning.Operation[] = []; + stream.on('data', (response: protos.google.longrunning.Operation) => { + 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.listDatabaseOperations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDatabaseOperations, request)); + assert( + (client.descriptors.page.listDatabaseOperations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listDatabaseOperationsStream with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatabaseOperations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listDatabaseOperationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.longrunning.Operation[] = []; + stream.on('data', (response: protos.google.longrunning.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listDatabaseOperations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDatabaseOperations, request)); + assert( + (client.descriptors.page.listDatabaseOperations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDatabaseOperations without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.descriptors.page.listDatabaseOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.longrunning.IOperation[] = []; + const iterable = client.listDatabaseOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDatabaseOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDatabaseOperations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDatabaseOperations with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatabaseOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDatabaseOperationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDatabaseOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDatabaseOperations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listBackupOperations', () => { + it('invokes listBackupOperations without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.innerApiCalls.listBackupOperations = stubSimpleCall(expectedResponse); + const [response] = await client.listBackupOperations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listBackupOperations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listBackupOperations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listBackupOperations without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.innerApiCalls.listBackupOperations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackupOperations( + request, + (err?: Error|null, result?: protos.google.longrunning.IOperation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listBackupOperations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listBackupOperations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listBackupOperations with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackupOperations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listBackupOperations(request), expectedError); + const actualRequest = (client.innerApiCalls.listBackupOperations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listBackupOperations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listBackupOperationsStream without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.descriptors.page.listBackupOperations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listBackupOperationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.longrunning.Operation[] = []; + stream.on('data', (response: protos.google.longrunning.Operation) => { + 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.listBackupOperations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listBackupOperations, request)); + assert( + (client.descriptors.page.listBackupOperations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listBackupOperationsStream with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackupOperations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listBackupOperationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.longrunning.Operation[] = []; + stream.on('data', (response: protos.google.longrunning.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listBackupOperations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listBackupOperations, request)); + assert( + (client.descriptors.page.listBackupOperations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listBackupOperations without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.descriptors.page.listBackupOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.longrunning.IOperation[] = []; + const iterable = client.listBackupOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBackupOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listBackupOperations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listBackupOperations with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBackupOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBackupOperationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBackupOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listBackupOperations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listDatabaseRoles', () => { + it('invokes listDatabaseRoles without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + ]; + client.innerApiCalls.listDatabaseRoles = stubSimpleCall(expectedResponse); + const [response] = await client.listDatabaseRoles(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDatabaseRoles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseRoles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDatabaseRoles without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + ]; + client.innerApiCalls.listDatabaseRoles = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDatabaseRoles( + request, + (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IDatabaseRole[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDatabaseRoles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseRoles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDatabaseRoles with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDatabaseRoles = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDatabaseRoles(request), expectedError); + const actualRequest = (client.innerApiCalls.listDatabaseRoles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseRoles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDatabaseRolesStream without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + ]; + client.descriptors.page.listDatabaseRoles.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listDatabaseRolesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.admin.database.v1.DatabaseRole[] = []; + stream.on('data', (response: protos.google.spanner.admin.database.v1.DatabaseRole) => { + 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.listDatabaseRoles.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDatabaseRoles, request)); + assert( + (client.descriptors.page.listDatabaseRoles.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listDatabaseRolesStream with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatabaseRoles.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listDatabaseRolesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.admin.database.v1.DatabaseRole[] = []; + stream.on('data', (response: protos.google.spanner.admin.database.v1.DatabaseRole) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listDatabaseRoles.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDatabaseRoles, request)); + assert( + (client.descriptors.page.listDatabaseRoles.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDatabaseRoles without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), + ]; + client.descriptors.page.listDatabaseRoles.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.spanner.admin.database.v1.IDatabaseRole[] = []; + const iterable = client.listDatabaseRolesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDatabaseRoles with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatabaseRoles.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDatabaseRolesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.spanner.admin.database.v1.IDatabaseRole[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('backup', () => { + const fakePath = "/rendered/path/backup"; + const expectedParameters = { + project: "projectValue", + instance: "instanceValue", + backup: "backupValue", + }; + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.backupPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.backupPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath("projectValue", "instanceValue", "backupValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromBackupName', () => { + const result = client.matchInstanceFromBackupName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, "backupValue"); + assert((client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('cryptoKey', () => { + const fakePath = "/rendered/path/cryptoKey"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + key_ring: "keyRingValue", + crypto_key: "cryptoKeyValue", + }; + const client = new databaseadminModule.v1.DatabaseAdminClient({ + 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('database', () => { + const fakePath = "/rendered/path/database"; + const expectedParameters = { + project: "projectValue", + instance: "instanceValue", + database: "databaseValue", + }; + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.databasePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.databasePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('databasePath', () => { + const result = client.databasePath("projectValue", "instanceValue", "databaseValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.databasePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDatabaseName', () => { + const result = client.matchProjectFromDatabaseName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromDatabaseName', () => { + const result = client.matchInstanceFromDatabaseName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDatabaseFromDatabaseName', () => { + const result = client.matchDatabaseFromDatabaseName(fakePath); + assert.strictEqual(result, "databaseValue"); + assert((client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('databaseRole', () => { + const fakePath = "/rendered/path/databaseRole"; + const expectedParameters = { + project: "projectValue", + instance: "instanceValue", + database: "databaseValue", + role: "roleValue", + }; + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.databaseRolePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.databaseRolePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('databaseRolePath', () => { + const result = client.databaseRolePath("projectValue", "instanceValue", "databaseValue", "roleValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.databaseRolePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDatabaseRoleName', () => { + const result = client.matchProjectFromDatabaseRoleName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.databaseRolePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromDatabaseRoleName', () => { + const result = client.matchInstanceFromDatabaseRoleName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.databaseRolePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDatabaseFromDatabaseRoleName', () => { + const result = client.matchDatabaseFromDatabaseRoleName(fakePath); + assert.strictEqual(result, "databaseValue"); + assert((client.pathTemplates.databaseRolePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRoleFromDatabaseRoleName', () => { + const result = client.matchRoleFromDatabaseRoleName(fakePath); + assert.strictEqual(result, "roleValue"); + assert((client.pathTemplates.databaseRolePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('instance', () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + instance: "instanceValue", + }; + const client = new databaseadminModule.v1.DatabaseAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/admin/database/v1/tsconfig.json b/owl-bot-staging/admin/database/v1/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/admin/database/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/admin/database/v1/webpack.config.js b/owl-bot-staging/admin/database/v1/webpack.config.js new file mode 100644 index 000000000..ef04209ca --- /dev/null +++ b/owl-bot-staging/admin/database/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'DatabaseAdmin', + filename: './database-admin.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/admin/instance/v1/.eslintignore b/owl-bot-staging/admin/instance/v1/.eslintignore new file mode 100644 index 000000000..cfc348ec4 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/admin/instance/v1/.eslintrc.json b/owl-bot-staging/admin/instance/v1/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/admin/instance/v1/.gitignore b/owl-bot-staging/admin/instance/v1/.gitignore new file mode 100644 index 000000000..d4f03a0df --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/admin/instance/v1/.jsdoc.js b/owl-bot-staging/admin/instance/v1/.jsdoc.js new file mode 100644 index 000000000..e37e0473a --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/spanner', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/admin/instance/v1/.mocharc.js b/owl-bot-staging/admin/instance/v1/.mocharc.js new file mode 100644 index 000000000..1a38f257d --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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/admin/instance/v1/.prettierrc.js b/owl-bot-staging/admin/instance/v1/.prettierrc.js new file mode 100644 index 000000000..55639e70f --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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/admin/instance/v1/README.md b/owl-bot-staging/admin/instance/v1/README.md new file mode 100644 index 000000000..91e6e9efe --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/README.md @@ -0,0 +1 @@ +Instance: Nodejs Client diff --git a/owl-bot-staging/admin/instance/v1/linkinator.config.json b/owl-bot-staging/admin/instance/v1/linkinator.config.json new file mode 100644 index 000000000..befd23c86 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/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/admin/instance/v1/package.json b/owl-bot-staging/admin/instance/v1/package.json new file mode 100644 index 000000000..8425e4680 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/spanner", + "version": "0.1.0", + "description": "Instance client for Node.js", + "repository": "googleapis/nodejs-instance", + "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 instance", + "instance", + "instance admin" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "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.5.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/common.proto b/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/common.proto new file mode 100644 index 000000000..e93b33476 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/common.proto @@ -0,0 +1,42 @@ +// 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.spanner.admin.instance.v1; + +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.Admin.Instance.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/admin/instance/v1;instance"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.spanner.admin.instance.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Instance\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Instance::V1"; + +// Encapsulates progress related information for a Cloud Spanner long +// running instance operations. +message OperationProgress { + // Percent completion of the operation. + // Values are between 0 and 100 inclusive. + int32 progress_percent = 1; + + // Time the request was received. + google.protobuf.Timestamp start_time = 2; + + // If set, the time at which this operation failed or was completed + // successfully. + google.protobuf.Timestamp end_time = 3; +} diff --git a/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto b/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto new file mode 100644 index 000000000..85b041134 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -0,0 +1,1081 @@ +// 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.spanner.admin.instance.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/spanner/admin/instance/v1/common.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.Admin.Instance.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/admin/instance/v1;instance"; +option java_multiple_files = true; +option java_outer_classname = "SpannerInstanceAdminProto"; +option java_package = "com.google.spanner.admin.instance.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Instance\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Instance::V1"; + +// Cloud Spanner Instance Admin API +// +// The Cloud Spanner Instance Admin API can be used to create, delete, +// modify and list instances. Instances are dedicated Cloud Spanner serving +// and storage resources to be used by Cloud Spanner databases. +// +// Each instance has a "configuration", which dictates where the +// serving resources for the Cloud Spanner instance are located (e.g., +// US-central, Europe). Configurations are created by Google based on +// resource availability. +// +// Cloud Spanner billing is based on the instances that exist and their +// sizes. After an instance exists, there are no additional +// per-database or per-operation charges for use of the instance +// (though there may be additional network bandwidth charges). +// Instances offer isolation: problems with databases in one instance +// will not affect other instances. However, within an instance +// databases can affect each other. For example, if one database in an +// instance receives a lot of requests and consumes most of the +// instance resources, fewer resources are available for other +// databases in that instance, and their performance may suffer. +service InstanceAdmin { + option (google.api.default_host) = "spanner.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/spanner.admin"; + + // Lists the supported instance configurations for a given project. + rpc ListInstanceConfigs(ListInstanceConfigsRequest) + returns (ListInstanceConfigsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/instanceConfigs" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information about a particular instance configuration. + rpc GetInstanceConfig(GetInstanceConfigRequest) returns (InstanceConfig) { + option (google.api.http) = { + get: "/v1/{name=projects/*/instanceConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates an instance config and begins preparing it to be used. The + // returned [long-running operation][google.longrunning.Operation] + // can be used to track the progress of preparing the new + // instance config. The instance config name is assigned by the caller. If the + // named instance config already exists, `CreateInstanceConfig` returns + // `ALREADY_EXISTS`. + // + // Immediately after the request returns: + // + // * The instance config is readable via the API, with all requested + // attributes. The instance config's + // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + // field is set to true. Its state is `CREATING`. + // + // While the operation is pending: + // + // * Cancelling the operation renders the instance config immediately + // unreadable via the API. + // * Except for deleting the creating resource, all other attempts to modify + // the instance config are rejected. + // + // Upon completion of the returned operation: + // + // * Instances can be created using the instance configuration. + // * The instance config's + // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + // field becomes false. Its state becomes `READY`. + // + // The returned [long-running operation][google.longrunning.Operation] will + // have a name of the format + // `/operations/` and can be used to track + // creation of the instance config. The + // [metadata][google.longrunning.Operation.metadata] field type is + // [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + // The [response][google.longrunning.Operation.response] field type is + // [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + // successful. + // + // Authorization requires `spanner.instanceConfigs.create` permission on + // the resource + // [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent]. + rpc CreateInstanceConfig(CreateInstanceConfigRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/instanceConfigs" + body: "*" + }; + option (google.api.method_signature) = + "parent,instance_config,instance_config_id"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.instance.v1.InstanceConfig" + metadata_type: "google.spanner.admin.instance.v1.CreateInstanceConfigMetadata" + }; + } + + // Updates an instance config. The returned + // [long-running operation][google.longrunning.Operation] can be used to track + // the progress of updating the instance. If the named instance config does + // not exist, returns `NOT_FOUND`. + // + // Only user managed configurations can be updated. + // + // Immediately after the request returns: + // + // * The instance config's + // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + // field is set to true. + // + // While the operation is pending: + // + // * Cancelling the operation sets its metadata's + // [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time]. + // The operation is guaranteed to succeed at undoing all changes, after + // which point it terminates with a `CANCELLED` status. + // * All other attempts to modify the instance config are rejected. + // * Reading the instance config via the API continues to give the + // pre-request values. + // + // Upon completion of the returned operation: + // + // * Creating instances using the instance configuration uses the new + // values. + // * The instance config's new values are readable via the API. + // * The instance config's + // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + // field becomes false. + // + // The returned [long-running operation][google.longrunning.Operation] will + // have a name of the format + // `/operations/` and can be used to track + // the instance config modification. The + // [metadata][google.longrunning.Operation.metadata] field type is + // [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata]. + // The [response][google.longrunning.Operation.response] field type is + // [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + // successful. + // + // Authorization requires `spanner.instanceConfigs.update` permission on + // the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + rpc UpdateInstanceConfig(UpdateInstanceConfigRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{instance_config.name=projects/*/instanceConfigs/*}" + body: "*" + }; + option (google.api.method_signature) = "instance_config,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.instance.v1.InstanceConfig" + metadata_type: "google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata" + }; + } + + // Deletes the instance config. Deletion is only allowed when no + // instances are using the configuration. If any instances are using + // the config, returns `FAILED_PRECONDITION`. + // + // Only user managed configurations can be deleted. + // + // Authorization requires `spanner.instanceConfigs.delete` permission on + // the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + rpc DeleteInstanceConfig(DeleteInstanceConfigRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/instanceConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists the user-managed instance config [long-running + // operations][google.longrunning.Operation] in the given project. An instance + // config operation has a name of the form + // `projects//instanceConfigs//operations/`. + // The long-running operation + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. Operations returned + // include those that have completed/failed/canceled within the last 7 days, + // and pending operations. Operations returned are ordered by + // `operation.metadata.value.start_time` in descending order starting + // from the most recently started operation. + rpc ListInstanceConfigOperations(ListInstanceConfigOperationsRequest) + returns (ListInstanceConfigOperationsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/instanceConfigOperations" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists all instances in the given project. + rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/instances" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information about a particular instance. + rpc GetInstance(GetInstanceRequest) returns (Instance) { + option (google.api.http) = { + get: "/v1/{name=projects/*/instances/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates an instance and begins preparing it to begin serving. The + // returned [long-running operation][google.longrunning.Operation] + // can be used to track the progress of preparing the new + // instance. The instance name is assigned by the caller. If the + // named instance already exists, `CreateInstance` returns + // `ALREADY_EXISTS`. + // + // Immediately upon completion of this request: + // + // * The instance is readable via the API, with all requested attributes + // but no allocated resources. Its state is `CREATING`. + // + // Until completion of the returned operation: + // + // * Cancelling the operation renders the instance immediately unreadable + // via the API. + // * The instance can be deleted. + // * All other attempts to modify the instance are rejected. + // + // Upon completion of the returned operation: + // + // * Billing for all successfully-allocated resources begins (some types + // may have lower than the requested levels). + // * Databases can be created in the instance. + // * The instance's allocated resource levels are readable via the API. + // * The instance's state becomes `READY`. + // + // The returned [long-running operation][google.longrunning.Operation] will + // have a name of the format `/operations/` and + // can be used to track creation of the instance. The + // [metadata][google.longrunning.Operation.metadata] field type is + // [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. + // The [response][google.longrunning.Operation.response] field type is + // [Instance][google.spanner.admin.instance.v1.Instance], if successful. + rpc CreateInstance(CreateInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/instances" + body: "*" + }; + option (google.api.method_signature) = "parent,instance_id,instance"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.instance.v1.Instance" + metadata_type: "google.spanner.admin.instance.v1.CreateInstanceMetadata" + }; + } + + // Updates an instance, and begins allocating or releasing resources + // as requested. The returned [long-running + // operation][google.longrunning.Operation] can be used to track the + // progress of updating the instance. If the named instance does not + // exist, returns `NOT_FOUND`. + // + // Immediately upon completion of this request: + // + // * For resource types for which a decrease in the instance's allocation + // has been requested, billing is based on the newly-requested level. + // + // Until completion of the returned operation: + // + // * Cancelling the operation sets its metadata's + // [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], + // and begins restoring resources to their pre-request values. The + // operation is guaranteed to succeed at undoing all resource changes, + // after which point it terminates with a `CANCELLED` status. + // * All other attempts to modify the instance are rejected. + // * Reading the instance via the API continues to give the pre-request + // resource levels. + // + // Upon completion of the returned operation: + // + // * Billing begins for all successfully-allocated resources (some types + // may have lower than the requested levels). + // * All newly-reserved resources are available for serving the instance's + // tables. + // * The instance's new resource levels are readable via the API. + // + // The returned [long-running operation][google.longrunning.Operation] will + // have a name of the format `/operations/` and + // can be used to track the instance modification. The + // [metadata][google.longrunning.Operation.metadata] field type is + // [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. + // The [response][google.longrunning.Operation.response] field type is + // [Instance][google.spanner.admin.instance.v1.Instance], if successful. + // + // Authorization requires `spanner.instances.update` permission on + // the resource [name][google.spanner.admin.instance.v1.Instance.name]. + rpc UpdateInstance(UpdateInstanceRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{instance.name=projects/*/instances/*}" + body: "*" + }; + option (google.api.method_signature) = "instance,field_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.instance.v1.Instance" + metadata_type: "google.spanner.admin.instance.v1.UpdateInstanceMetadata" + }; + } + + // Deletes an instance. + // + // Immediately upon completion of the request: + // + // * Billing ceases for all of the instance's reserved resources. + // + // Soon afterward: + // + // * The instance and *all of its databases* immediately and + // irrevocably disappear from the API. All data in the databases + // is permanently deleted. + rpc DeleteInstance(DeleteInstanceRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/instances/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Sets the access control policy on an instance resource. Replaces any + // existing policy. + // + // Authorization requires `spanner.instances.setIamPolicy` on + // [resource][google.iam.v1.SetIamPolicyRequest.resource]. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/instances/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Gets the access control policy for an instance resource. Returns an empty + // policy if an instance exists but does not have a policy set. + // + // Authorization requires `spanner.instances.getIamPolicy` on + // [resource][google.iam.v1.GetIamPolicyRequest.resource]. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/instances/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Returns permissions that the caller has on the specified instance resource. + // + // Attempting this RPC on a non-existent Cloud Spanner instance resource will + // result in a NOT_FOUND error if the user has `spanner.instances.list` + // permission on the containing Google Cloud Project. Otherwise returns an + // empty set of permissions. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/instances/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +message ReplicaInfo { + // Indicates the type of replica. See the [replica types + // documentation](https://cloud.google.com/spanner/docs/replication#replica_types) + // for more details. + enum ReplicaType { + // Not specified. + TYPE_UNSPECIFIED = 0; + + // Read-write replicas support both reads and writes. These replicas: + // + // * Maintain a full copy of your data. + // * Serve reads. + // * Can vote whether to commit a write. + // * Participate in leadership election. + // * Are eligible to become a leader. + READ_WRITE = 1; + + // Read-only replicas only support reads (not writes). Read-only replicas: + // + // * Maintain a full copy of your data. + // * Serve reads. + // * Do not participate in voting to commit writes. + // * Are not eligible to become a leader. + READ_ONLY = 2; + + // Witness replicas don't support reads but do participate in voting to + // commit writes. Witness replicas: + // + // * Do not maintain a full copy of data. + // * Do not serve reads. + // * Vote whether to commit writes. + // * Participate in leader election but are not eligible to become leader. + WITNESS = 3; + } + + // The location of the serving resources, e.g. "us-central1". + string location = 1; + + // The type of replica. + ReplicaType type = 2; + + // If true, this location is designated as the default leader location where + // leader replicas are placed. See the [region types + // documentation](https://cloud.google.com/spanner/docs/instances#region_types) + // for more details. + bool default_leader_location = 3; +} + +// A possible configuration for a Cloud Spanner instance. Configurations +// define the geographic placement of nodes and their replication. +message InstanceConfig { + option (google.api.resource) = { + type: "spanner.googleapis.com/InstanceConfig" + pattern: "projects/{project}/instanceConfigs/{instance_config}" + }; + + // The type of this configuration. + enum Type { + // Unspecified. + TYPE_UNSPECIFIED = 0; + + // Google managed configuration. + GOOGLE_MANAGED = 1; + + // User managed configuration. + USER_MANAGED = 2; + } + + // Indicates the current state of the instance config. + enum State { + // Not specified. + STATE_UNSPECIFIED = 0; + + // The instance config is still being created. + CREATING = 1; + + // The instance config is fully created and ready to be used to create + // instances. + READY = 2; + } + + // A unique identifier for the instance configuration. Values + // are of the form + // `projects//instanceConfigs/[a-z][-a-z0-9]*`. + string name = 1; + + // The name of this instance configuration as it appears in UIs. + string display_name = 2; + + // Output only. Whether this instance config is a Google or User Managed + // Configuration. + Type config_type = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The geographic placement of nodes in this instance configuration and their + // replication properties. + repeated ReplicaInfo replicas = 3; + + // Output only. The available optional replicas to choose from for user + // managed configurations. Populated for Google managed configurations. + repeated ReplicaInfo optional_replicas = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Base configuration name, e.g. projects//instanceConfigs/nam3, + // based on which this configuration is created. Only set for user managed + // configurations. `base_config` must refer to a configuration of type + // GOOGLE_MANAGED in the same project as this configuration. + string base_config = 7 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/InstanceConfig" + }]; + + // Cloud Labels are a flexible and lightweight mechanism for organizing cloud + // resources into groups that reflect a customer's organizational needs and + // deployment strategies. Cloud Labels can be used to filter collections of + // resources. They can be used to control how resource metrics are aggregated. + // And they can be used as arguments to policy management rules (e.g. route, + // firewall, load balancing, etc.). + // + // * Label keys must be between 1 and 63 characters long and must conform to + // the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + // * Label values must be between 0 and 63 characters long and must conform + // to the regular expression `[a-z0-9_-]{0,63}`. + // * No more than 64 labels can be associated with a given resource. + // + // See https://goo.gl/xmQnxf for more information on and examples of labels. + // + // If you plan to use labels in your own code, please note that additional + // characters may be allowed in the future. Therefore, you are advised to use + // an internal label representation, such as JSON, which doesn't rely upon + // specific characters being disallowed. For example, representing labels + // as the string: name + "_" + value would prove problematic if we were to + // allow "_" in a future release. + map labels = 8; + + // etag is used for optimistic concurrency control as a way + // to help prevent simultaneous updates of a instance config from overwriting + // each other. It is strongly suggested that systems make use of the etag in + // the read-modify-write cycle to perform instance config updates in order to + // avoid race conditions: An etag is returned in the response which contains + // instance configs, and systems are expected to put that etag in the request + // to update instance config to ensure that their change will be applied to + // the same version of the instance config. + // If no etag is provided in the call to update instance config, then the + // existing instance config is overwritten blindly. + string etag = 9; + + // Allowed values of the "default_leader" schema option for databases in + // instances that use this instance configuration. + repeated string leader_options = 4; + + // Output only. If true, the instance config is being created or updated. If + // false, there are no ongoing operations for the instance config. + bool reconciling = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current instance config state. + State state = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// An isolated set of Cloud Spanner resources on which databases can be hosted. +message Instance { + option (google.api.resource) = { + type: "spanner.googleapis.com/Instance" + pattern: "projects/{project}/instances/{instance}" + }; + + // Indicates the current state of the instance. + enum State { + // Not specified. + STATE_UNSPECIFIED = 0; + + // The instance is still being created. Resources may not be + // available yet, and operations such as database creation may not + // work. + CREATING = 1; + + // The instance is fully created and ready to do work such as + // creating databases. + READY = 2; + } + + // Required. A unique identifier for the instance, which cannot be changed + // after the instance is created. Values are of the form + // `projects//instances/[a-z][-a-z0-9]*[a-z0-9]`. The final + // segment of the name must be between 2 and 64 characters in length. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The name of the instance's configuration. Values are of the form + // `projects//instanceConfigs/`. See + // also [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and + // [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. + string config = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/InstanceConfig" + } + ]; + + // Required. The descriptive name for this instance as it appears in UIs. + // Must be unique per project and between 4 and 30 characters in length. + string display_name = 3 [(google.api.field_behavior) = REQUIRED]; + + // The number of nodes allocated to this instance. At most one of either + // node_count or processing_units should be present in the message. This + // may be zero in API responses for instances that are not yet in state + // `READY`. + // + // See [the + // documentation](https://cloud.google.com/spanner/docs/compute-capacity) + // for more information about nodes and processing units. + int32 node_count = 5; + + // The number of processing units allocated to this instance. At most one of + // processing_units or node_count should be present in the message. This may + // be zero in API responses for instances that are not yet in state `READY`. + // + // See [the + // documentation](https://cloud.google.com/spanner/docs/compute-capacity) + // for more information about nodes and processing units. + int32 processing_units = 9; + + // Output only. The current instance state. For + // [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], + // the state must be either omitted or set to `CREATING`. For + // [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance], + // the state must be either omitted or set to `READY`. + State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Cloud Labels are a flexible and lightweight mechanism for organizing cloud + // resources into groups that reflect a customer's organizational needs and + // deployment strategies. Cloud Labels can be used to filter collections of + // resources. They can be used to control how resource metrics are aggregated. + // And they can be used as arguments to policy management rules (e.g. route, + // firewall, load balancing, etc.). + // + // * Label keys must be between 1 and 63 characters long and must conform to + // the following regular expression: `[a-z][a-z0-9_-]{0,62}`. + // * Label values must be between 0 and 63 characters long and must conform + // to the regular expression `[a-z0-9_-]{0,63}`. + // * No more than 64 labels can be associated with a given resource. + // + // See https://goo.gl/xmQnxf for more information on and examples of labels. + // + // If you plan to use labels in your own code, please note that additional + // characters may be allowed in the future. And so you are advised to use an + // internal label representation, such as JSON, which doesn't rely upon + // specific characters being disallowed. For example, representing labels + // as the string: name + "_" + value would prove problematic if we were to + // allow "_" in a future release. + map labels = 7; + + // Deprecated. This field is not populated. + repeated string endpoint_uris = 8; + + // Output only. The time at which the instance was created. + google.protobuf.Timestamp create_time = 11 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which the instance was most recently updated. + google.protobuf.Timestamp update_time = 12 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The request for +// [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. +message ListInstanceConfigsRequest { + // Required. The name of the project for which a list of supported instance + // configurations is requested. Values are of the form + // `projects/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Number of instance configurations to be returned in the response. If 0 or + // less, defaults to the server's maximum allowed page size. + int32 page_size = 2; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token] + // from a previous + // [ListInstanceConfigsResponse][google.spanner.admin.instance.v1.ListInstanceConfigsResponse]. + string page_token = 3; +} + +// The response for +// [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. +message ListInstanceConfigsResponse { + // The list of requested instance configurations. + repeated InstanceConfig instance_configs = 1; + + // `next_page_token` can be sent in a subsequent + // [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs] + // call to fetch more of the matching instance configurations. + string next_page_token = 2; +} + +// The request for +// [GetInstanceConfigRequest][google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceConfig]. +message GetInstanceConfigRequest { + // Required. The name of the requested instance configuration. Values are of + // the form `projects//instanceConfigs/`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/InstanceConfig" + } + ]; +} + +// The request for +// [CreateInstanceConfigRequest][InstanceAdmin.CreateInstanceConfigRequest]. +message CreateInstanceConfigRequest { + // Required. The name of the project in which to create the instance config. + // Values are of the form `projects/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The ID of the instance config to create. Valid identifiers are + // of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + // characters in length. The `custom-` prefix is required to avoid name + // conflicts with Google managed configurations. + string instance_config_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The InstanceConfig proto of the configuration to create. + // instance_config.name must be + // `/instanceConfigs/`. + // instance_config.base_config must be a Google managed configuration name, + // e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. + InstanceConfig instance_config = 3 [(google.api.field_behavior) = REQUIRED]; + + // An option to validate, but not actually execute, a request, + // and provide the same response. + bool validate_only = 4; +} + +// The request for +// [UpdateInstanceConfigRequest][InstanceAdmin.UpdateInstanceConfigRequest]. +message UpdateInstanceConfigRequest { + // Required. The user instance config to update, which must always include the + // instance config name. Otherwise, only fields mentioned in + // [update_mask][google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask] + // need be included. To prevent conflicts of concurrent updates, + // [etag][google.spanner.admin.instance.v1.InstanceConfig.reconciling] can + // be used. + InstanceConfig instance_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A mask specifying which fields in + // [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] should be + // updated. The field mask must always be specified; this prevents any future + // fields in [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] + // from being erased accidentally by clients that do not know about them. Only + // display_name and labels can be updated. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = REQUIRED]; + + // An option to validate, but not actually execute, a request, + // and provide the same response. + bool validate_only = 3; +} + +// The request for +// [DeleteInstanceConfigRequest][InstanceAdmin.DeleteInstanceConfigRequest]. +message DeleteInstanceConfigRequest { + // Required. The name of the instance configuration to be deleted. + // Values are of the form + // `projects//instanceConfigs/` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/InstanceConfig" + } + ]; + + // Used for optimistic concurrency control as a way to help prevent + // simultaneous deletes of an instance config from overwriting each + // other. If not empty, the API + // only deletes the instance config when the etag provided matches the current + // status of the requested instance config. Otherwise, deletes the instance + // config without checking the current status of the requested instance + // config. + string etag = 2; + + // An option to validate, but not actually execute, a request, + // and provide the same response. + bool validate_only = 3; +} + +// The request for +// [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations]. +message ListInstanceConfigOperationsRequest { + // Required. The project of the instance config operations. + // Values are of the form `projects/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // An expression that filters the list of returned operations. + // + // A filter expression consists of a field name, a + // comparison operator, and a value for filtering. + // The value must be a string, a number, or a boolean. The comparison operator + // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + // Colon `:` is the contains operator. Filter rules are not case sensitive. + // + // The following fields in the [Operation][google.longrunning.Operation] + // are eligible for filtering: + // + // * `name` - The name of the long-running operation + // * `done` - False if the operation is in progress, else true. + // * `metadata.@type` - the type of metadata. For example, the type string + // for + // [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata] + // is + // `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + // * `metadata.` - any field in metadata.value. + // `metadata.@type` must be specified first, if filtering on metadata + // fields. + // * `error` - Error associated with the long-running operation. + // * `response.@type` - the type of response. + // * `response.` - any field in response.value. + // + // You can combine multiple expressions by enclosing each expression in + // parentheses. By default, expressions are combined with AND logic. However, + // you can specify AND, OR, and NOT logic explicitly. + // + // Here are a few examples: + // + // * `done:true` - The operation is complete. + // * `(metadata.@type=` \ + // `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + // AND` \ + // `(metadata.instance_config.name:custom-config) AND` \ + // `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + // `(error:*)` - Return operations where: + // * The operation's metadata type is + // [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + // * The instance config name contains "custom-config". + // * The operation started before 2021-03-28T14:50:00Z. + // * The operation resulted in an error. + string filter = 2; + + // Number of operations to be returned in the response. If 0 or + // less, defaults to the server's maximum allowed page size. + int32 page_size = 3; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token] + // from a previous + // [ListInstanceConfigOperationsResponse][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse] + // to the same `parent` and with the same `filter`. + string page_token = 4; +} + +// The response for +// [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations]. +message ListInstanceConfigOperationsResponse { + // The list of matching instance config [long-running + // operations][google.longrunning.Operation]. Each operation's name will be + // prefixed by the instance config's name. The operation's + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. + repeated google.longrunning.Operation operations = 1; + + // `next_page_token` can be sent in a subsequent + // [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations] + // call to fetch more of the matching metadata. + string next_page_token = 2; +} + +// The request for +// [GetInstance][google.spanner.admin.instance.v1.InstanceAdmin.GetInstance]. +message GetInstanceRequest { + // Required. The name of the requested instance. Values are of the form + // `projects//instances/`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // If field_mask is present, specifies the subset of + // [Instance][google.spanner.admin.instance.v1.Instance] fields that should be + // returned. If absent, all + // [Instance][google.spanner.admin.instance.v1.Instance] fields are returned. + google.protobuf.FieldMask field_mask = 2; +} + +// The request for +// [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance]. +message CreateInstanceRequest { + // Required. The name of the project in which to create the instance. Values + // are of the form `projects/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The ID of the instance to create. Valid identifiers are of the + // form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in + // length. + string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The instance to create. The name may be omitted, but if + // specified must be `/instances/`. + Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for +// [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances]. +message ListInstancesRequest { + // Required. The name of the project for which a list of instances is + // requested. Values are of the form `projects/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Number of instances to be returned in the response. If 0 or less, defaults + // to the server's maximum allowed page size. + int32 page_size = 2; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token] + // from a previous + // [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. + string page_token = 3; + + // An expression for filtering the results of the request. Filter rules are + // case insensitive. The fields eligible for filtering are: + // + // * `name` + // * `display_name` + // * `labels.key` where key is the name of a label + // + // Some examples of using filters are: + // + // * `name:*` --> The instance has a name. + // * `name:Howl` --> The instance's name contains the string "howl". + // * `name:HOWL` --> Equivalent to above. + // * `NAME:howl` --> Equivalent to above. + // * `labels.env:*` --> The instance has the label "env". + // * `labels.env:dev` --> The instance has the label "env" and the value of + // the label contains the string "dev". + // * `name:howl labels.env:dev` --> The instance's name contains "howl" and + // it has the label "env" with its value + // containing "dev". + string filter = 4; +} + +// The response for +// [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances]. +message ListInstancesResponse { + // The list of requested instances. + repeated Instance instances = 1; + + // `next_page_token` can be sent in a subsequent + // [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances] + // call to fetch more of the matching instances. + string next_page_token = 2; +} + +// The request for +// [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance]. +message UpdateInstanceRequest { + // Required. The instance to update, which must always include the instance + // name. Otherwise, only fields mentioned in + // [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] + // need be included. + Instance instance = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A mask specifying which fields in + // [Instance][google.spanner.admin.instance.v1.Instance] should be updated. + // The field mask must always be specified; this prevents any future fields in + // [Instance][google.spanner.admin.instance.v1.Instance] from being erased + // accidentally by clients that do not know about them. + google.protobuf.FieldMask field_mask = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// The request for +// [DeleteInstance][google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance]. +message DeleteInstanceRequest { + // Required. The name of the instance to be deleted. Values are of the form + // `projects//instances/` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; +} + +// Metadata type for the operation returned by +// [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance]. +message CreateInstanceMetadata { + // The instance being created. + Instance instance = 1; + + // The time at which the + // [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance] + // request was received. + google.protobuf.Timestamp start_time = 2; + + // The time at which this operation was cancelled. If set, this operation is + // in the process of undoing itself (which is guaranteed to succeed) and + // cannot be cancelled again. + google.protobuf.Timestamp cancel_time = 3; + + // The time at which this operation failed or was completed successfully. + google.protobuf.Timestamp end_time = 4; +} + +// Metadata type for the operation returned by +// [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance]. +message UpdateInstanceMetadata { + // The desired end state of the update. + Instance instance = 1; + + // The time at which + // [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance] + // request was received. + google.protobuf.Timestamp start_time = 2; + + // The time at which this operation was cancelled. If set, this operation is + // in the process of undoing itself (which is guaranteed to succeed) and + // cannot be cancelled again. + google.protobuf.Timestamp cancel_time = 3; + + // The time at which this operation failed or was completed successfully. + google.protobuf.Timestamp end_time = 4; +} + +// Metadata type for the operation returned by +// [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig]. +message CreateInstanceConfigMetadata { + // The target instance config end state. + InstanceConfig instance_config = 1; + + // The progress of the + // [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig] + // operation. + OperationProgress progress = 2; + + // The time at which this operation was cancelled. + google.protobuf.Timestamp cancel_time = 3; +} + +// Metadata type for the operation returned by +// [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig]. +message UpdateInstanceConfigMetadata { + // The desired instance config after updating. + InstanceConfig instance_config = 1; + + // The progress of the + // [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig] + // operation. + OperationProgress progress = 2; + + // The time at which this operation was cancelled. + google.protobuf.Timestamp cancel_time = 3; +} diff --git a/owl-bot-staging/admin/instance/v1/src/index.ts b/owl-bot-staging/admin/instance/v1/src/index.ts new file mode 100644 index 000000000..f535f33cd --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const InstanceAdminClient = v1.InstanceAdminClient; +type InstanceAdminClient = v1.InstanceAdminClient; +export {v1, InstanceAdminClient}; +export default {v1, InstanceAdminClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/admin/instance/v1/src/v1/gapic_metadata.json b/owl-bot-staging/admin/instance/v1/src/v1/gapic_metadata.json new file mode 100644 index 000000000..4a890f403 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/src/v1/gapic_metadata.json @@ -0,0 +1,175 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.spanner.admin.instance.v1", + "libraryPackage": "@google-cloud/spanner", + "services": { + "InstanceAdmin": { + "clients": { + "grpc": { + "libraryClient": "InstanceAdminClient", + "rpcs": { + "GetInstanceConfig": { + "methods": [ + "getInstanceConfig" + ] + }, + "DeleteInstanceConfig": { + "methods": [ + "deleteInstanceConfig" + ] + }, + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateInstanceConfig": { + "methods": [ + "createInstanceConfig" + ] + }, + "UpdateInstanceConfig": { + "methods": [ + "updateInstanceConfig" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "UpdateInstance": { + "methods": [ + "updateInstance" + ] + }, + "ListInstanceConfigs": { + "methods": [ + "listInstanceConfigs", + "listInstanceConfigsStream", + "listInstanceConfigsAsync" + ] + }, + "ListInstanceConfigOperations": { + "methods": [ + "listInstanceConfigOperations", + "listInstanceConfigOperationsStream", + "listInstanceConfigOperationsAsync" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "InstanceAdminClient", + "rpcs": { + "GetInstanceConfig": { + "methods": [ + "getInstanceConfig" + ] + }, + "DeleteInstanceConfig": { + "methods": [ + "deleteInstanceConfig" + ] + }, + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateInstanceConfig": { + "methods": [ + "createInstanceConfig" + ] + }, + "UpdateInstanceConfig": { + "methods": [ + "updateInstanceConfig" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "UpdateInstance": { + "methods": [ + "updateInstance" + ] + }, + "ListInstanceConfigs": { + "methods": [ + "listInstanceConfigs", + "listInstanceConfigsStream", + "listInstanceConfigsAsync" + ] + }, + "ListInstanceConfigOperations": { + "methods": [ + "listInstanceConfigOperations", + "listInstanceConfigOperationsStream", + "listInstanceConfigOperationsAsync" + ] + }, + "ListInstances": { + "methods": [ + "listInstances", + "listInstancesStream", + "listInstancesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/admin/instance/v1/src/v1/index.ts b/owl-bot-staging/admin/instance/v1/src/v1/index.ts new file mode 100644 index 000000000..172b60cb1 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 {InstanceAdminClient} from './instance_admin_client'; diff --git a/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client.ts b/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client.ts new file mode 100644 index 000000000..df33d5075 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client.ts @@ -0,0 +1,2419 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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/v1/instance_admin_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './instance_admin_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Spanner Instance Admin API + * + * The Cloud Spanner Instance Admin API can be used to create, delete, + * modify and list instances. Instances are dedicated Cloud Spanner serving + * and storage resources to be used by Cloud Spanner databases. + * + * Each instance has a "configuration", which dictates where the + * serving resources for the Cloud Spanner instance are located (e.g., + * US-central, Europe). Configurations are created by Google based on + * resource availability. + * + * Cloud Spanner billing is based on the instances that exist and their + * sizes. After an instance exists, there are no additional + * per-database or per-operation charges for use of the instance + * (though there may be additional network bandwidth charges). + * Instances offer isolation: problems with databases in one instance + * will not affect other instances. However, within an instance + * databases can affect each other. For example, if one database in an + * instance receives a lot of requests and consumes most of the + * instance resources, fewer resources are available for other + * databases in that instance, and their performance may suffer. + * @class + * @memberof v1 + */ +export class InstanceAdminClient { + 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; + instanceAdminStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of InstanceAdminClient. + * + * @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 InstanceAdminClient({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 InstanceAdminClient; + 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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 = { + instancePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instances/{instance}' + ), + instanceConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instanceConfigs/{instance_config}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listInstanceConfigs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instanceConfigs'), + listInstanceConfigOperations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'operations'), + listInstances: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') + }; + + 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.GetOperation',get: '/v1/{name=projects/*/instances/*/databases/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/instances/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/instances/*/databases/*/operations}',additional_bindings: [{get: '/v1/{name=projects/*/instances/*/operations}',}], + },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel',additional_bindings: [{post: '/v1/{name=projects/*/instances/*/operations/*}:cancel',}], + },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/instances/*/databases/*/operations/*}',additional_bindings: [{delete: '/v1/{name=projects/*/instances/*/operations/*}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createInstanceConfigResponse = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.InstanceConfig') as gax.protobuf.Type; + const createInstanceConfigMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.CreateInstanceConfigMetadata') as gax.protobuf.Type; + const updateInstanceConfigResponse = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.InstanceConfig') as gax.protobuf.Type; + const updateInstanceConfigMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata') as gax.protobuf.Type; + const createInstanceResponse = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.Instance') as gax.protobuf.Type; + const createInstanceMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.CreateInstanceMetadata') as gax.protobuf.Type; + const updateInstanceResponse = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.Instance') as gax.protobuf.Type; + const updateInstanceMetadata = protoFilesRoot.lookup( + '.google.spanner.admin.instance.v1.UpdateInstanceMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createInstanceConfig: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createInstanceConfigResponse.decode.bind(createInstanceConfigResponse), + createInstanceConfigMetadata.decode.bind(createInstanceConfigMetadata)), + updateInstanceConfig: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateInstanceConfigResponse.decode.bind(updateInstanceConfigResponse), + updateInstanceConfigMetadata.decode.bind(updateInstanceConfigMetadata)), + createInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createInstanceResponse.decode.bind(createInstanceResponse), + createInstanceMetadata.decode.bind(createInstanceMetadata)), + updateInstance: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateInstanceResponse.decode.bind(updateInstanceResponse), + updateInstanceMetadata.decode.bind(updateInstanceMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.spanner.admin.instance.v1.InstanceAdmin', 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.instanceAdminStub) { + return this.instanceAdminStub; + } + + // Put together the "service stub" for + // google.spanner.admin.instance.v1.InstanceAdmin. + this.instanceAdminStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.spanner.admin.instance.v1.InstanceAdmin') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.spanner.admin.instance.v1.InstanceAdmin, + 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 instanceAdminStubMethods = + ['listInstanceConfigs', 'getInstanceConfig', 'createInstanceConfig', 'updateInstanceConfig', 'deleteInstanceConfig', 'listInstanceConfigOperations', 'listInstances', 'getInstance', 'createInstance', 'updateInstance', 'deleteInstance', 'setIamPolicy', 'getIamPolicy', 'testIamPermissions']; + for (const methodName of instanceAdminStubMethods) { + const callPromise = this.instanceAdminStub.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.instanceAdminStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'spanner.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 'spanner.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', + 'https://www.googleapis.com/auth/spanner.admin' + ]; + } + + 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 particular instance configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the requested instance configuration. Values are of + * the form `projects//instanceConfigs/`. + * @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 {@link google.spanner.admin.instance.v1.InstanceConfig | InstanceConfig}. + * 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/v1/instance_admin.get_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_GetInstanceConfig_async + */ + getInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|undefined, {}|undefined + ]>; + getInstanceConfig( + request: protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|null|undefined, + {}|null|undefined>): void; + getInstanceConfig( + request: protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest, + callback: Callback< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|null|undefined, + {}|null|undefined>): void; + getInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.admin.instance.v1.IInstanceConfig, + protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|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({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInstanceConfig(request, options, callback); + } +/** + * Deletes the instance config. Deletion is only allowed when no + * instances are using the configuration. If any instances are using + * the config, returns `FAILED_PRECONDITION`. + * + * Only user managed configurations can be deleted. + * + * Authorization requires `spanner.instanceConfigs.delete` permission on + * the resource {@link google.spanner.admin.instance.v1.InstanceConfig.name|name}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the instance configuration to be deleted. + * Values are of the form + * `projects//instanceConfigs/` + * @param {string} request.etag + * Used for optimistic concurrency control as a way to help prevent + * simultaneous deletes of an instance config from overwriting each + * other. If not empty, the API + * only deletes the instance config when the etag provided matches the current + * status of the requested instance config. Otherwise, deletes the instance + * config without checking the current status of the requested instance + * config. + * @param {boolean} request.validateOnly + * An option to validate, but not actually execute, a request, + * and provide the same response. + * @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 {@link google.protobuf.Empty | Empty}. + * 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/v1/instance_admin.delete_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_DeleteInstanceConfig_async + */ + deleteInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|undefined, {}|undefined + ]>; + deleteInstanceConfig( + request: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteInstanceConfig( + request: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|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({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteInstanceConfig(request, options, callback); + } +/** + * Gets information about a particular instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the requested instance. Values are of the form + * `projects//instances/`. + * @param {google.protobuf.FieldMask} request.fieldMask + * If field_mask is present, specifies the subset of + * {@link google.spanner.admin.instance.v1.Instance|Instance} fields that should be + * returned. If absent, all + * {@link google.spanner.admin.instance.v1.Instance|Instance} fields are returned. + * @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 {@link google.spanner.admin.instance.v1.Instance | Instance}. + * 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/v1/instance_admin.get_instance.js + * region_tag:spanner_v1_generated_InstanceAdmin_GetInstance_async + */ + getInstance( + request?: protos.google.spanner.admin.instance.v1.IGetInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.instance.v1.IInstance, + protos.google.spanner.admin.instance.v1.IGetInstanceRequest|undefined, {}|undefined + ]>; + getInstance( + request: protos.google.spanner.admin.instance.v1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.admin.instance.v1.IInstance, + protos.google.spanner.admin.instance.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request: protos.google.spanner.admin.instance.v1.IGetInstanceRequest, + callback: Callback< + protos.google.spanner.admin.instance.v1.IInstance, + protos.google.spanner.admin.instance.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; + getInstance( + request?: protos.google.spanner.admin.instance.v1.IGetInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.admin.instance.v1.IInstance, + protos.google.spanner.admin.instance.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.admin.instance.v1.IInstance, + protos.google.spanner.admin.instance.v1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.admin.instance.v1.IInstance, + protos.google.spanner.admin.instance.v1.IGetInstanceRequest|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({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getInstance(request, options, callback); + } +/** + * Deletes an instance. + * + * Immediately upon completion of the request: + * + * * Billing ceases for all of the instance's reserved resources. + * + * Soon afterward: + * + * * The instance and *all of its databases* immediately and + * irrevocably disappear from the API. All data in the databases + * is permanently deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the instance to be deleted. Values are of the form + * `projects//instances/` + * @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 {@link google.protobuf.Empty | Empty}. + * 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/v1/instance_admin.delete_instance.js + * region_tag:spanner_v1_generated_InstanceAdmin_DeleteInstance_async + */ + deleteInstance( + request?: protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|undefined, {}|undefined + ]>; + deleteInstance( + request: protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request: protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|null|undefined, + {}|null|undefined>): void; + deleteInstance( + request?: protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|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({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteInstance(request, options, callback); + } +/** + * Sets the access control policy on an instance resource. Replaces any + * existing policy. + * + * Authorization requires `spanner.instances.setIamPolicy` on + * {@link google.iam.v1.SetIamPolicyRequest.resource|resource}. + * + * @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 {@link google.iam.v1.Policy | 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/v1/instance_admin.set_iam_policy.js + * region_tag:spanner_v1_generated_InstanceAdmin_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); + } +/** + * Gets the access control policy for an instance resource. Returns an empty + * policy if an instance exists but does not have a policy set. + * + * Authorization requires `spanner.instances.getIamPolicy` on + * {@link google.iam.v1.GetIamPolicyRequest.resource|resource}. + * + * @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 {@link google.iam.v1.Policy | 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/v1/instance_admin.get_iam_policy.js + * region_tag:spanner_v1_generated_InstanceAdmin_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); + } +/** + * Returns permissions that the caller has on the specified instance resource. + * + * Attempting this RPC on a non-existent Cloud Spanner instance resource will + * result in a NOT_FOUND error if the user has `spanner.instances.list` + * permission on the containing Google Cloud Project. Otherwise returns an + * empty set of permissions. + * + * @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 {@link google.iam.v1.TestIamPermissionsResponse | 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/v1/instance_admin.test_iam_permissions.js + * region_tag:spanner_v1_generated_InstanceAdmin_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 an instance config and begins preparing it to be used. The + * returned {@link google.longrunning.Operation|long-running operation} + * can be used to track the progress of preparing the new + * instance config. The instance config name is assigned by the caller. If the + * named instance config already exists, `CreateInstanceConfig` returns + * `ALREADY_EXISTS`. + * + * Immediately after the request returns: + * + * * The instance config is readable via the API, with all requested + * attributes. The instance config's + * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} + * field is set to true. Its state is `CREATING`. + * + * While the operation is pending: + * + * * Cancelling the operation renders the instance config immediately + * unreadable via the API. + * * Except for deleting the creating resource, all other attempts to modify + * the instance config are rejected. + * + * Upon completion of the returned operation: + * + * * Instances can be created using the instance configuration. + * * The instance config's + * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} + * field becomes false. Its state becomes `READY`. + * + * The returned {@link google.longrunning.Operation|long-running operation} will + * have a name of the format + * `/operations/` and can be used to track + * creation of the instance config. The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. + * The {@link google.longrunning.Operation.response|response} field type is + * {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig}, if + * successful. + * + * Authorization requires `spanner.instanceConfigs.create` permission on + * the resource + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent|parent}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which to create the instance config. + * Values are of the form `projects/`. + * @param {string} request.instanceConfigId + * Required. The ID of the instance config to create. Valid identifiers are + * of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 + * characters in length. The `custom-` prefix is required to avoid name + * conflicts with Google managed configurations. + * @param {google.spanner.admin.instance.v1.InstanceConfig} request.instanceConfig + * Required. The InstanceConfig proto of the configuration to create. + * instance_config.name must be + * `/instanceConfigs/`. + * instance_config.base_config must be a Google managed configuration name, + * e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. + * @param {boolean} request.validateOnly + * An option to validate, but not actually execute, a request, + * and provide the same response. + * @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/v1/instance_admin.create_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_CreateInstanceConfig_async + */ + createInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createInstanceConfig( + request: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstanceConfig( + request: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, + 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 || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createInstanceConfig(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createInstanceConfig()`. + * @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/v1/instance_admin.create_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_CreateInstanceConfig_async + */ + async checkCreateInstanceConfigProgress(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.createInstanceConfig, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates an instance config. The returned + * {@link google.longrunning.Operation|long-running operation} can be used to track + * the progress of updating the instance. If the named instance config does + * not exist, returns `NOT_FOUND`. + * + * Only user managed configurations can be updated. + * + * Immediately after the request returns: + * + * * The instance config's + * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} + * field is set to true. + * + * While the operation is pending: + * + * * Cancelling the operation sets its metadata's + * {@link google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time|cancel_time}. + * The operation is guaranteed to succeed at undoing all changes, after + * which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance config are rejected. + * * Reading the instance config via the API continues to give the + * pre-request values. + * + * Upon completion of the returned operation: + * + * * Creating instances using the instance configuration uses the new + * values. + * * The instance config's new values are readable via the API. + * * The instance config's + * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} + * field becomes false. + * + * The returned {@link google.longrunning.Operation|long-running operation} will + * have a name of the format + * `/operations/` and can be used to track + * the instance config modification. The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata|UpdateInstanceConfigMetadata}. + * The {@link google.longrunning.Operation.response|response} field type is + * {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig}, if + * successful. + * + * Authorization requires `spanner.instanceConfigs.update` permission on + * the resource {@link google.spanner.admin.instance.v1.InstanceConfig.name|name}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.spanner.admin.instance.v1.InstanceConfig} request.instanceConfig + * Required. The user instance config to update, which must always include the + * instance config name. Otherwise, only fields mentioned in + * {@link google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask|update_mask} + * need be included. To prevent conflicts of concurrent updates, + * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|etag} can + * be used. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A mask specifying which fields in + * {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig} should be + * updated. The field mask must always be specified; this prevents any future + * fields in {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig} + * from being erased accidentally by clients that do not know about them. Only + * display_name and labels can be updated. + * @param {boolean} request.validateOnly + * An option to validate, but not actually execute, a request, + * and provide the same response. + * @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/v1/instance_admin.update_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_UpdateInstanceConfig_async + */ + updateInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateInstanceConfig( + request: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstanceConfig( + request: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstanceConfig( + request?: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, + 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 || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'instance_config.name': request.instanceConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateInstanceConfig(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateInstanceConfig()`. + * @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/v1/instance_admin.update_instance_config.js + * region_tag:spanner_v1_generated_InstanceAdmin_UpdateInstanceConfig_async + */ + async checkUpdateInstanceConfigProgress(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.updateInstanceConfig, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates an instance and begins preparing it to begin serving. The + * returned {@link google.longrunning.Operation|long-running operation} + * can be used to track the progress of preparing the new + * instance. The instance name is assigned by the caller. If the + * named instance already exists, `CreateInstance` returns + * `ALREADY_EXISTS`. + * + * Immediately upon completion of this request: + * + * * The instance is readable via the API, with all requested attributes + * but no allocated resources. Its state is `CREATING`. + * + * Until completion of the returned operation: + * + * * Cancelling the operation renders the instance immediately unreadable + * via the API. + * * The instance can be deleted. + * * All other attempts to modify the instance are rejected. + * + * Upon completion of the returned operation: + * + * * Billing for all successfully-allocated resources begins (some types + * may have lower than the requested levels). + * * Databases can be created in the instance. + * * The instance's allocated resource levels are readable via the API. + * * The instance's state becomes `READY`. + * + * The returned {@link google.longrunning.Operation|long-running operation} will + * have a name of the format `/operations/` and + * can be used to track creation of the instance. The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.instance.v1.CreateInstanceMetadata|CreateInstanceMetadata}. + * The {@link google.longrunning.Operation.response|response} field type is + * {@link google.spanner.admin.instance.v1.Instance|Instance}, if successful. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which to create the instance. Values + * are of the form `projects/`. + * @param {string} request.instanceId + * Required. The ID of the instance to create. Valid identifiers are of the + * form `{@link -a-z0-9|a-z}*[a-z0-9]` and must be between 2 and 64 characters in + * length. + * @param {google.spanner.admin.instance.v1.Instance} request.instance + * Required. The instance to create. The name may be omitted, but if + * specified must be `/instances/`. + * @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/v1/instance_admin.create_instance.js + * region_tag:spanner_v1_generated_InstanceAdmin_CreateInstance_async + */ + createInstance( + request?: protos.google.spanner.admin.instance.v1.ICreateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createInstance( + request: protos.google.spanner.admin.instance.v1.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request: protos.google.spanner.admin.instance.v1.ICreateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createInstance( + request?: protos.google.spanner.admin.instance.v1.ICreateInstanceRequest, + 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 || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createInstance()`. + * @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/v1/instance_admin.create_instance.js + * region_tag:spanner_v1_generated_InstanceAdmin_CreateInstance_async + */ + async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates an instance, and begins allocating or releasing resources + * as requested. The returned [long-running + * operation][google.longrunning.Operation] can be used to track the + * progress of updating the instance. If the named instance does not + * exist, returns `NOT_FOUND`. + * + * Immediately upon completion of this request: + * + * * For resource types for which a decrease in the instance's allocation + * has been requested, billing is based on the newly-requested level. + * + * Until completion of the returned operation: + * + * * Cancelling the operation sets its metadata's + * {@link google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time|cancel_time}, + * and begins restoring resources to their pre-request values. The + * operation is guaranteed to succeed at undoing all resource changes, + * after which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance are rejected. + * * Reading the instance via the API continues to give the pre-request + * resource levels. + * + * Upon completion of the returned operation: + * + * * Billing begins for all successfully-allocated resources (some types + * may have lower than the requested levels). + * * All newly-reserved resources are available for serving the instance's + * tables. + * * The instance's new resource levels are readable via the API. + * + * The returned {@link google.longrunning.Operation|long-running operation} will + * have a name of the format `/operations/` and + * can be used to track the instance modification. The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.spanner.admin.instance.v1.UpdateInstanceMetadata|UpdateInstanceMetadata}. + * The {@link google.longrunning.Operation.response|response} field type is + * {@link google.spanner.admin.instance.v1.Instance|Instance}, if successful. + * + * Authorization requires `spanner.instances.update` permission on + * the resource {@link google.spanner.admin.instance.v1.Instance.name|name}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.spanner.admin.instance.v1.Instance} request.instance + * Required. The instance to update, which must always include the instance + * name. Otherwise, only fields mentioned in + * {@link google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask|field_mask} + * need be included. + * @param {google.protobuf.FieldMask} request.fieldMask + * Required. A mask specifying which fields in + * {@link google.spanner.admin.instance.v1.Instance|Instance} should be updated. + * The field mask must always be specified; this prevents any future fields in + * {@link google.spanner.admin.instance.v1.Instance|Instance} from being erased + * accidentally by clients that do not know about them. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1/instance_admin.update_instance.js + * region_tag:spanner_v1_generated_InstanceAdmin_UpdateInstance_async + */ + updateInstance( + request?: protos.google.spanner.admin.instance.v1.IUpdateInstanceRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateInstance( + request: protos.google.spanner.admin.instance.v1.IUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstance( + request: protos.google.spanner.admin.instance.v1.IUpdateInstanceRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateInstance( + request?: protos.google.spanner.admin.instance.v1.IUpdateInstanceRequest, + 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 || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'instance.name': request.instance!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateInstance(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateInstance()`. + * @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/v1/instance_admin.update_instance.js + * region_tag:spanner_v1_generated_InstanceAdmin_UpdateInstance_async + */ + async checkUpdateInstanceProgress(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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists the supported instance configurations for a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form + * `projects/`. + * @param {number} request.pageSize + * Number of instance configurations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. + * @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 {@link google.spanner.admin.instance.v1.InstanceConfig | InstanceConfig}. + * 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 `listInstanceConfigsAsync()` + * 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. + */ + listInstanceConfigs( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.instance.v1.IInstanceConfig[], + protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest|null, + protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse + ]>; + listInstanceConfigs( + request: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, + protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse|null|undefined, + protos.google.spanner.admin.instance.v1.IInstanceConfig>): void; + listInstanceConfigs( + request: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, + callback: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, + protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse|null|undefined, + protos.google.spanner.admin.instance.v1.IInstanceConfig>): void; + listInstanceConfigs( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, + protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse|null|undefined, + protos.google.spanner.admin.instance.v1.IInstanceConfig>, + callback?: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, + protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse|null|undefined, + protos.google.spanner.admin.instance.v1.IInstanceConfig>): + Promise<[ + protos.google.spanner.admin.instance.v1.IInstanceConfig[], + protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest|null, + protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse + ]>|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({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstanceConfigs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form + * `projects/`. + * @param {number} request.pageSize + * Number of instance configurations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. + * @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 {@link google.spanner.admin.instance.v1.InstanceConfig | InstanceConfig} 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 `listInstanceConfigsAsync()` + * 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. + */ + listInstanceConfigsStream( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listInstanceConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstanceConfigs.createStream( + this.innerApiCalls.listInstanceConfigs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInstanceConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project for which a list of supported instance + * configurations is requested. Values are of the form + * `projects/`. + * @param {number} request.pageSize + * Number of instance configurations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. + * @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 + * {@link google.spanner.admin.instance.v1.InstanceConfig | InstanceConfig}. 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/v1/instance_admin.list_instance_configs.js + * region_tag:spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_async + */ + listInstanceConfigsAsync( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listInstanceConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstanceConfigs.asyncIterate( + this.innerApiCalls['listInstanceConfigs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the user-managed instance config [long-running + * operations][google.longrunning.Operation] in the given project. An instance + * config operation has a name of the form + * `projects//instanceConfigs//operations/`. + * The long-running operation + * {@link google.longrunning.Operation.metadata|metadata} field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.start_time` in descending order starting + * from the most recently started operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project of the instance config operations. + * Values are of the form `projects/`. + * @param {string} request.filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|Operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata} + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. + * * The instance config name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse|ListInstanceConfigOperationsResponse} + * to the same `parent` and with the same `filter`. + * @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 {@link google.longrunning.Operation | Operation}. + * 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 `listInstanceConfigOperationsAsync()` + * 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. + */ + listInstanceConfigOperations( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + options?: CallOptions): + Promise<[ + protos.google.longrunning.IOperation[], + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest|null, + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse + ]>; + listInstanceConfigOperations( + request: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>): void; + listInstanceConfigOperations( + request: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + callback: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>): void; + listInstanceConfigOperations( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>, + callback?: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse|null|undefined, + protos.google.longrunning.IOperation>): + Promise<[ + protos.google.longrunning.IOperation[], + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest|null, + protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse + ]>|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({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstanceConfigOperations(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 project of the instance config operations. + * Values are of the form `projects/`. + * @param {string} request.filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|Operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata} + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. + * * The instance config name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse|ListInstanceConfigOperationsResponse} + * to the same `parent` and with the same `filter`. + * @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 {@link google.longrunning.Operation | Operation} 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 `listInstanceConfigOperationsAsync()` + * 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. + */ + listInstanceConfigOperationsStream( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listInstanceConfigOperations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstanceConfigOperations.createStream( + this.innerApiCalls.listInstanceConfigOperations as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInstanceConfigOperations`, 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 project of the instance config operations. + * Values are of the form `projects/`. + * @param {string} request.filter + * An expression that filters the list of returned operations. + * + * A filter expression consists of a field name, a + * comparison operator, and a value for filtering. + * The value must be a string, a number, or a boolean. The comparison operator + * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + * Colon `:` is the contains operator. Filter rules are not case sensitive. + * + * The following fields in the {@link google.longrunning.Operation|Operation} + * are eligible for filtering: + * + * * `name` - The name of the long-running operation + * * `done` - False if the operation is in progress, else true. + * * `metadata.@type` - the type of metadata. For example, the type string + * for + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata} + * is + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. + * * `metadata.` - any field in metadata.value. + * `metadata.@type` must be specified first, if filtering on metadata + * fields. + * * `error` - Error associated with the long-running operation. + * * `response.@type` - the type of response. + * * `response.` - any field in response.value. + * + * You can combine multiple expressions by enclosing each expression in + * parentheses. By default, expressions are combined with AND logic. However, + * you can specify AND, OR, and NOT logic explicitly. + * + * Here are a few examples: + * + * * `done:true` - The operation is complete. + * * `(metadata.@type=` \ + * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) + * AND` \ + * `(metadata.instance_config.name:custom-config) AND` \ + * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ + * `(error:*)` - Return operations where: + * * The operation's metadata type is + * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. + * * The instance config name contains "custom-config". + * * The operation started before 2021-03-28T14:50:00Z. + * * The operation resulted in an error. + * @param {number} request.pageSize + * Number of operations to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse|ListInstanceConfigOperationsResponse} + * to the same `parent` and with the same `filter`. + * @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 + * {@link google.longrunning.Operation | Operation}. 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/v1/instance_admin.list_instance_config_operations.js + * region_tag:spanner_v1_generated_InstanceAdmin_ListInstanceConfigOperations_async + */ + listInstanceConfigOperationsAsync( + request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listInstanceConfigOperations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstanceConfigOperations.asyncIterate( + this.innerApiCalls['listInstanceConfigOperations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all instances in the given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project for which a list of instances is + * requested. Values are of the form `projects/`. + * @param {number} request.pageSize + * Number of instances to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. + * @param {string} request.filter + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * + * * `name` + * * `display_name` + * * `labels.key` where key is the name of a label + * + * Some examples of using filters are: + * + * * `name:*` --> The instance has a name. + * * `name:Howl` --> The instance's name contains the string "howl". + * * `name:HOWL` --> Equivalent to above. + * * `NAME:howl` --> Equivalent to above. + * * `labels.env:*` --> The instance has the label "env". + * * `labels.env:dev` --> The instance has the label "env" and the value of + * the label contains the string "dev". + * * `name:howl labels.env:dev` --> The instance's name contains "howl" and + * it has the label "env" with its value + * containing "dev". + * @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 {@link google.spanner.admin.instance.v1.Instance | Instance}. + * 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 `listInstancesAsync()` + * 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. + */ + listInstances( + request?: protos.google.spanner.admin.instance.v1.IListInstancesRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.admin.instance.v1.IInstance[], + protos.google.spanner.admin.instance.v1.IListInstancesRequest|null, + protos.google.spanner.admin.instance.v1.IListInstancesResponse + ]>; + listInstances( + request: protos.google.spanner.admin.instance.v1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstancesRequest, + protos.google.spanner.admin.instance.v1.IListInstancesResponse|null|undefined, + protos.google.spanner.admin.instance.v1.IInstance>): void; + listInstances( + request: protos.google.spanner.admin.instance.v1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstancesRequest, + protos.google.spanner.admin.instance.v1.IListInstancesResponse|null|undefined, + protos.google.spanner.admin.instance.v1.IInstance>): void; + listInstances( + request?: protos.google.spanner.admin.instance.v1.IListInstancesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstancesRequest, + protos.google.spanner.admin.instance.v1.IListInstancesResponse|null|undefined, + protos.google.spanner.admin.instance.v1.IInstance>, + callback?: PaginationCallback< + protos.google.spanner.admin.instance.v1.IListInstancesRequest, + protos.google.spanner.admin.instance.v1.IListInstancesResponse|null|undefined, + protos.google.spanner.admin.instance.v1.IInstance>): + Promise<[ + protos.google.spanner.admin.instance.v1.IInstance[], + protos.google.spanner.admin.instance.v1.IListInstancesRequest|null, + protos.google.spanner.admin.instance.v1.IListInstancesResponse + ]>|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({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listInstances(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project for which a list of instances is + * requested. Values are of the form `projects/`. + * @param {number} request.pageSize + * Number of instances to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. + * @param {string} request.filter + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * + * * `name` + * * `display_name` + * * `labels.key` where key is the name of a label + * + * Some examples of using filters are: + * + * * `name:*` --> The instance has a name. + * * `name:Howl` --> The instance's name contains the string "howl". + * * `name:HOWL` --> Equivalent to above. + * * `NAME:howl` --> Equivalent to above. + * * `labels.env:*` --> The instance has the label "env". + * * `labels.env:dev` --> The instance has the label "env" and the value of + * the label contains the string "dev". + * * `name:howl labels.env:dev` --> The instance's name contains "howl" and + * it has the label "env" with its value + * containing "dev". + * @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 {@link google.spanner.admin.instance.v1.Instance | Instance} 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 `listInstancesAsync()` + * 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. + */ + listInstancesStream( + request?: protos.google.spanner.admin.instance.v1.IListInstancesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.createStream( + this.innerApiCalls.listInstances as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project for which a list of instances is + * requested. Values are of the form `projects/`. + * @param {number} request.pageSize + * Number of instances to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} + * from a previous + * {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. + * @param {string} request.filter + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * + * * `name` + * * `display_name` + * * `labels.key` where key is the name of a label + * + * Some examples of using filters are: + * + * * `name:*` --> The instance has a name. + * * `name:Howl` --> The instance's name contains the string "howl". + * * `name:HOWL` --> Equivalent to above. + * * `NAME:howl` --> Equivalent to above. + * * `labels.env:*` --> The instance has the label "env". + * * `labels.env:dev` --> The instance has the label "env" and the value of + * the label contains the string "dev". + * * `name:howl labels.env:dev` --> The instance's name contains "howl" and + * it has the label "env" with its value + * containing "dev". + * @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 + * {@link google.spanner.admin.instance.v1.Instance | Instance}. 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/v1/instance_admin.list_instances.js + * region_tag:spanner_v1_generated_InstanceAdmin_ListInstances_async + */ + listInstancesAsync( + request?: protos.google.spanner.admin.instance.v1.IListInstancesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listInstances']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listInstances.asyncIterate( + this.innerApiCalls['listInstances'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified instance resource name string. + * + * @param {string} project + * @param {string} instance + * @returns {string} Resource name string. + */ + instancePath(project:string,instance:string) { + return this.pathTemplates.instancePathTemplate.render({ + project: project, + instance: instance, + }); + } + + /** + * Parse the project from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).project; + } + + /** + * Parse the instance from Instance resource. + * + * @param {string} instanceName + * A fully-qualified path representing Instance resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromInstanceName(instanceName: string) { + return this.pathTemplates.instancePathTemplate.match(instanceName).instance; + } + + /** + * Return a fully-qualified instanceConfig resource name string. + * + * @param {string} project + * @param {string} instance_config + * @returns {string} Resource name string. + */ + instanceConfigPath(project:string,instanceConfig:string) { + return this.pathTemplates.instanceConfigPathTemplate.render({ + project: project, + instance_config: instanceConfig, + }); + } + + /** + * Parse the project from InstanceConfig resource. + * + * @param {string} instanceConfigName + * A fully-qualified path representing InstanceConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromInstanceConfigName(instanceConfigName: string) { + return this.pathTemplates.instanceConfigPathTemplate.match(instanceConfigName).project; + } + + /** + * Parse the instance_config from InstanceConfig resource. + * + * @param {string} instanceConfigName + * A fully-qualified path representing InstanceConfig resource. + * @returns {string} A string representing the instance_config. + */ + matchInstanceConfigFromInstanceConfigName(instanceConfigName: string) { + return this.pathTemplates.instanceConfigPathTemplate.match(instanceConfigName).instance_config; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.instanceAdminStub && !this._terminated) { + return this.instanceAdminStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client_config.json b/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client_config.json new file mode 100644 index 000000000..3f41e629d --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client_config.json @@ -0,0 +1,101 @@ +{ + "interfaces": { + "google.spanner.admin.instance.v1.InstanceAdmin": { + "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 + }, + "e9fafda332ce8a1702dc1575de3ca81c4feb4799": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 32000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListInstanceConfigs": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "GetInstanceConfig": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "CreateInstanceConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateInstanceConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteInstanceConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListInstanceConfigOperations": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListInstances": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "GetInstance": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "CreateInstance": { + "timeout_millis": 3600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateInstance": { + "timeout_millis": 3600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteInstance": { + "timeout_millis": 3600000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "SetIamPolicy": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" + }, + "TestIamPermissions": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_proto_list.json b/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_proto_list.json new file mode 100644 index 000000000..ce2400d42 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/spanner/admin/instance/v1/common.proto", + "../../protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto" +] diff --git a/owl-bot-staging/admin/instance/v1/test/gapic_instance_admin_v1.ts b/owl-bot-staging/admin/instance/v1/test/gapic_instance_admin_v1.ts new file mode 100644 index 000000000..677ffbc81 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/test/gapic_instance_admin_v1.ts @@ -0,0 +1,2437 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 instanceadminModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +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('v1.InstanceAdminClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = instanceadminModule.v1.InstanceAdminClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = instanceadminModule.v1.InstanceAdminClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = instanceadminModule.v1.InstanceAdminClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new instanceadminModule.v1.InstanceAdminClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.instanceAdminStub, undefined); + await client.initialize(); + assert(client.instanceAdminStub); + }); + + it('has close method for the initialized client', done => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.instanceAdminStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.instanceAdminStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new instanceadminModule.v1.InstanceAdminClient({ + 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 instanceadminModule.v1.InstanceAdminClient({ + 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('getInstanceConfig', () => { + it('invokes getInstanceConfig without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.InstanceConfig() + ); + client.innerApiCalls.getInstanceConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getInstanceConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceConfig without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.InstanceConfig() + ); + client.innerApiCalls.getInstanceConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstanceConfig( + request, + (err?: Error|null, result?: protos.google.spanner.admin.instance.v1.IInstanceConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceConfig with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstanceConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstanceConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstanceConfig with closed client', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstanceConfig(request), expectedError); + }); + }); + + describe('deleteInstanceConfig', () => { + it('invokes deleteInstanceConfig without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteInstanceConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteInstanceConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstanceConfig without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteInstanceConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstanceConfig( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstanceConfig with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstanceConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteInstanceConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstanceConfig with closed client', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteInstanceConfig(request), expectedError); + }); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + (err?: Error|null, result?: protos.google.spanner.admin.instance.v1.IInstance|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getInstance with closed client', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.GetInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteInstance = stubSimpleCall(expectedResponse); + const [response] = await client.deleteInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteInstance = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteInstance with closed client', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteInstance(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createInstanceConfig', () => { + it('invokes createInstanceConfig without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstanceConfig = stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstanceConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstanceConfig without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstanceConfig( + 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); + const actualRequest = (client.innerApiCalls.createInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstanceConfig with call error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstanceConfig = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createInstanceConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.createInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstanceConfig with LRO error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstanceConfig = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createInstanceConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateInstanceConfigProgress without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + 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.checkCreateInstanceConfigProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateInstanceConfigProgress with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + 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.checkCreateInstanceConfigProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateInstanceConfig', () => { + it('invokes updateInstanceConfig without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() + ); + request.instanceConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest', ['instanceConfig', 'name']); + request.instanceConfig.name = defaultValue1; + const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstanceConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstanceConfig without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() + ); + request.instanceConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest', ['instanceConfig', 'name']); + request.instanceConfig.name = defaultValue1; + const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstanceConfig( + 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); + const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstanceConfig with call error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() + ); + request.instanceConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest', ['instanceConfig', 'name']); + request.instanceConfig.name = defaultValue1; + const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateInstanceConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstanceConfig with LRO error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() + ); + request.instanceConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest', ['instanceConfig', 'name']); + request.instanceConfig.name = defaultValue1; + const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateInstanceConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateInstanceConfigProgress without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + 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.checkUpdateInstanceConfigProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateInstanceConfigProgress with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + 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.checkUpdateInstanceConfigProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + 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); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with call error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createInstance with LRO error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateInstanceProgress without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + 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.checkCreateInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateInstanceProgress with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + 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.checkCreateInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + 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); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance with call error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateInstance(request), expectedError); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateInstance with LRO error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() + ); + request.instance ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceRequest', ['instance', 'name']); + request.instance.name = defaultValue1; + const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateInstanceProgress without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + 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.checkUpdateInstanceProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateInstanceProgress with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + 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.checkUpdateInstanceProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listInstanceConfigs', () => { + it('invokes listInstanceConfigs without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + ]; + client.innerApiCalls.listInstanceConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listInstanceConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceConfigs without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + ]; + client.innerApiCalls.listInstanceConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstanceConfigs( + request, + (err?: Error|null, result?: protos.google.spanner.admin.instance.v1.IInstanceConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceConfigs with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstanceConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInstanceConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.listInstanceConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceConfigsStream without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + ]; + client.descriptors.page.listInstanceConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstanceConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.admin.instance.v1.InstanceConfig[] = []; + stream.on('data', (response: protos.google.spanner.admin.instance.v1.InstanceConfig) => { + 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.listInstanceConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstanceConfigs, request)); + assert( + (client.descriptors.page.listInstanceConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstanceConfigsStream with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstanceConfigs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstanceConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.admin.instance.v1.InstanceConfig[] = []; + stream.on('data', (response: protos.google.spanner.admin.instance.v1.InstanceConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInstanceConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstanceConfigs, request)); + assert( + (client.descriptors.page.listInstanceConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstanceConfigs without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), + ]; + client.descriptors.page.listInstanceConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.spanner.admin.instance.v1.IInstanceConfig[] = []; + const iterable = client.listInstanceConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstanceConfigs with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstanceConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstanceConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.spanner.admin.instance.v1.IInstanceConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listInstanceConfigOperations', () => { + it('invokes listInstanceConfigOperations without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.innerApiCalls.listInstanceConfigOperations = stubSimpleCall(expectedResponse); + const [response] = await client.listInstanceConfigOperations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceConfigOperations without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.innerApiCalls.listInstanceConfigOperations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstanceConfigOperations( + request, + (err?: Error|null, result?: protos.google.longrunning.IOperation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceConfigOperations with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstanceConfigOperations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInstanceConfigOperations(request), expectedError); + const actualRequest = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstanceConfigOperationsStream without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.descriptors.page.listInstanceConfigOperations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstanceConfigOperationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.longrunning.Operation[] = []; + stream.on('data', (response: protos.google.longrunning.Operation) => { + 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.listInstanceConfigOperations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstanceConfigOperations, request)); + assert( + (client.descriptors.page.listInstanceConfigOperations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstanceConfigOperationsStream with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstanceConfigOperations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstanceConfigOperationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.longrunning.Operation[] = []; + stream.on('data', (response: protos.google.longrunning.Operation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInstanceConfigOperations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstanceConfigOperations, request)); + assert( + (client.descriptors.page.listInstanceConfigOperations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstanceConfigOperations without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + generateSampleMessage(new protos.google.longrunning.Operation()), + ]; + client.descriptors.page.listInstanceConfigOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.longrunning.IOperation[] = []; + const iterable = client.listInstanceConfigOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstanceConfigOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstanceConfigOperations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstanceConfigOperations with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstanceConfigOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstanceConfigOperationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInstanceConfigOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstanceConfigOperations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances without error using callback', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + ]; + client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + (err?: Error|null, result?: protos.google.spanner.admin.instance.v1.IInstance[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstances with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listInstancesStream without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + ]; + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.admin.instance.v1.Instance[] = []; + stream.on('data', (response: protos.google.spanner.admin.instance.v1.Instance) => { + 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.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listInstancesStream with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.admin.instance.v1.Instance[] = []; + stream.on('data', (response: protos.google.spanner.admin.instance.v1.Instance) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances without error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.spanner.admin.instance.v1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listInstances with error', async () => { + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.admin.instance.v1.ListInstancesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.spanner.admin.instance.v1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('instance', () => { + const fakePath = "/rendered/path/instance"; + const expectedParameters = { + project: "projectValue", + instance: "instanceValue", + }; + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instancePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instancePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath("projectValue", "instanceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('instanceConfig', () => { + const fakePath = "/rendered/path/instanceConfig"; + const expectedParameters = { + project: "projectValue", + instance_config: "instanceConfigValue", + }; + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instanceConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.instanceConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('instanceConfigPath', () => { + const result = client.instanceConfigPath("projectValue", "instanceConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.instanceConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromInstanceConfigName', () => { + const result = client.matchProjectFromInstanceConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.instanceConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceConfigFromInstanceConfigName', () => { + const result = client.matchInstanceConfigFromInstanceConfigName(fakePath); + assert.strictEqual(result, "instanceConfigValue"); + assert((client.pathTemplates.instanceConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new instanceadminModule.v1.InstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/admin/instance/v1/tsconfig.json b/owl-bot-staging/admin/instance/v1/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/admin/instance/v1/webpack.config.js b/owl-bot-staging/admin/instance/v1/webpack.config.js new file mode 100644 index 000000000..9d3569000 --- /dev/null +++ b/owl-bot-staging/admin/instance/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'InstanceAdmin', + filename: './instance-admin.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 000000000..cfc348ec4 --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 000000000..d4f03a0df --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 000000000..e37e0473a --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/spanner', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 000000000..1a38f257d --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 000000000..55639e70f --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 000000000..f6214cb02 --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Spanner: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 000000000..befd23c86 --- /dev/null +++ b/owl-bot-staging/v1/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/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 000000000..02afe451f --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/spanner", + "version": "0.1.0", + "description": "Spanner client for Node.js", + "repository": "googleapis/nodejs-spanner", + "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 spanner", + "spanner", + "spanner" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "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.5.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/commit_response.proto b/owl-bot-staging/v1/protos/google/spanner/v1/commit_response.proto new file mode 100644 index 000000000..69e073092 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/spanner/v1/commit_response.proto @@ -0,0 +1,50 @@ +// 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.spanner.v1; + +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; +option java_multiple_files = true; +option java_outer_classname = "CommitResponseProto"; +option java_package = "com.google.spanner.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\V1"; +option ruby_package = "Google::Cloud::Spanner::V1"; + +// The response for [Commit][google.spanner.v1.Spanner.Commit]. +message CommitResponse { + // Additional statistics about a commit. + message CommitStats { + // The total number of mutations for the transaction. Knowing the + // `mutation_count` value can help you maximize the number of mutations + // in a transaction and minimize the number of API round trips. You can + // also monitor this value to prevent transactions from exceeding the system + // [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data). + // If the number of mutations exceeds the limit, the server returns + // [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT). + int64 mutation_count = 1; + } + + // The Cloud Spanner timestamp at which the transaction committed. + google.protobuf.Timestamp commit_timestamp = 1; + + // The statistics about this Commit. Not returned by default. + // For more information, see + // [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats]. + CommitStats commit_stats = 2; +} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/keys.proto b/owl-bot-staging/v1/protos/google/spanner/v1/keys.proto new file mode 100644 index 000000000..df3607aa4 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/spanner/v1/keys.proto @@ -0,0 +1,163 @@ +// 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.spanner.v1; + +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; +option java_multiple_files = true; +option java_outer_classname = "KeysProto"; +option java_package = "com.google.spanner.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\V1"; +option ruby_package = "Google::Cloud::Spanner::V1"; + +// KeyRange represents a range of rows in a table or index. +// +// A range has a start key and an end key. These keys can be open or +// closed, indicating if the range includes rows with that key. +// +// Keys are represented by lists, where the ith value in the list +// corresponds to the ith component of the table or index primary key. +// Individual values are encoded as described +// [here][google.spanner.v1.TypeCode]. +// +// For example, consider the following table definition: +// +// CREATE TABLE UserEvents ( +// UserName STRING(MAX), +// EventDate STRING(10) +// ) PRIMARY KEY(UserName, EventDate); +// +// The following keys name rows in this table: +// +// ["Bob", "2014-09-23"] +// ["Alfred", "2015-06-12"] +// +// Since the `UserEvents` table's `PRIMARY KEY` clause names two +// columns, each `UserEvents` key has two elements; the first is the +// `UserName`, and the second is the `EventDate`. +// +// Key ranges with multiple components are interpreted +// lexicographically by component using the table or index key's declared +// sort order. For example, the following range returns all events for +// user `"Bob"` that occurred in the year 2015: +// +// "start_closed": ["Bob", "2015-01-01"] +// "end_closed": ["Bob", "2015-12-31"] +// +// Start and end keys can omit trailing key components. This affects the +// inclusion and exclusion of rows that exactly match the provided key +// components: if the key is closed, then rows that exactly match the +// provided components are included; if the key is open, then rows +// that exactly match are not included. +// +// For example, the following range includes all events for `"Bob"` that +// occurred during and after the year 2000: +// +// "start_closed": ["Bob", "2000-01-01"] +// "end_closed": ["Bob"] +// +// The next example retrieves all events for `"Bob"`: +// +// "start_closed": ["Bob"] +// "end_closed": ["Bob"] +// +// To retrieve events before the year 2000: +// +// "start_closed": ["Bob"] +// "end_open": ["Bob", "2000-01-01"] +// +// The following range includes all rows in the table: +// +// "start_closed": [] +// "end_closed": [] +// +// This range returns all users whose `UserName` begins with any +// character from A to C: +// +// "start_closed": ["A"] +// "end_open": ["D"] +// +// This range returns all users whose `UserName` begins with B: +// +// "start_closed": ["B"] +// "end_open": ["C"] +// +// Key ranges honor column sort order. For example, suppose a table is +// defined as follows: +// +// CREATE TABLE DescendingSortedTable { +// Key INT64, +// ... +// ) PRIMARY KEY(Key DESC); +// +// The following range retrieves all rows with key values between 1 +// and 100 inclusive: +// +// "start_closed": ["100"] +// "end_closed": ["1"] +// +// Note that 100 is passed as the start, and 1 is passed as the end, +// because `Key` is a descending column in the schema. +message KeyRange { + // The start key must be provided. It can be either closed or open. + oneof start_key_type { + // If the start is closed, then the range includes all rows whose + // first `len(start_closed)` key columns exactly match `start_closed`. + google.protobuf.ListValue start_closed = 1; + + // If the start is open, then the range excludes rows whose first + // `len(start_open)` key columns exactly match `start_open`. + google.protobuf.ListValue start_open = 2; + } + + // The end key must be provided. It can be either closed or open. + oneof end_key_type { + // If the end is closed, then the range includes all rows whose + // first `len(end_closed)` key columns exactly match `end_closed`. + google.protobuf.ListValue end_closed = 3; + + // If the end is open, then the range excludes rows whose first + // `len(end_open)` key columns exactly match `end_open`. + google.protobuf.ListValue end_open = 4; + } +} + +// `KeySet` defines a collection of Cloud Spanner keys and/or key ranges. All +// the keys are expected to be in the same table or index. The keys need +// not be sorted in any particular way. +// +// If the same key is specified multiple times in the set (for example +// if two ranges, two keys, or a key and a range overlap), Cloud Spanner +// behaves as if the key were only specified once. +message KeySet { + // A list of specific keys. Entries in `keys` should have exactly as + // many elements as there are columns in the primary or index key + // with which this `KeySet` is used. Individual key values are + // encoded as described [here][google.spanner.v1.TypeCode]. + repeated google.protobuf.ListValue keys = 1; + + // A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about + // key range specifications. + repeated KeyRange ranges = 2; + + // For convenience `all` can be set to `true` to indicate that this + // `KeySet` matches all keys in the table or index. Note that any keys + // specified in `keys` or `ranges` are only yielded once. + bool all = 3; +} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/mutation.proto b/owl-bot-staging/v1/protos/google/spanner/v1/mutation.proto new file mode 100644 index 000000000..eae0af72d --- /dev/null +++ b/owl-bot-staging/v1/protos/google/spanner/v1/mutation.proto @@ -0,0 +1,107 @@ +// 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.spanner.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/struct.proto"; +import "google/spanner/v1/keys.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; +option java_multiple_files = true; +option java_outer_classname = "MutationProto"; +option java_package = "com.google.spanner.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\V1"; +option ruby_package = "Google::Cloud::Spanner::V1"; + +// A modification to one or more Cloud Spanner rows. Mutations can be +// applied to a Cloud Spanner database by sending them in a +// [Commit][google.spanner.v1.Spanner.Commit] call. +message Mutation { + // Arguments to [insert][google.spanner.v1.Mutation.insert], [update][google.spanner.v1.Mutation.update], [insert_or_update][google.spanner.v1.Mutation.insert_or_update], and + // [replace][google.spanner.v1.Mutation.replace] operations. + message Write { + // Required. The table whose rows will be written. + string table = 1 [(google.api.field_behavior) = REQUIRED]; + + // The names of the columns in [table][google.spanner.v1.Mutation.Write.table] to be written. + // + // The list of columns must contain enough columns to allow + // Cloud Spanner to derive values for all primary key columns in the + // row(s) to be modified. + repeated string columns = 2; + + // The values to be written. `values` can contain more than one + // list of values. If it does, then multiple rows are written, one + // for each entry in `values`. Each list in `values` must have + // exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] + // above. Sending multiple lists is equivalent to sending multiple + // `Mutation`s, each containing one `values` entry and repeating + // [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are + // encoded as described [here][google.spanner.v1.TypeCode]. + repeated google.protobuf.ListValue values = 3; + } + + // Arguments to [delete][google.spanner.v1.Mutation.delete] operations. + message Delete { + // Required. The table whose rows will be deleted. + string table = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. The + // primary keys must be specified in the order in which they appear in the + // `PRIMARY KEY()` clause of the table's equivalent DDL statement (the DDL + // statement used to create the table). + // Delete is idempotent. The transaction will succeed even if some or all + // rows do not exist. + KeySet key_set = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // Required. The operation to perform. + oneof operation { + // Insert new rows in a table. If any of the rows already exist, + // the write or transaction fails with error `ALREADY_EXISTS`. + Write insert = 1; + + // Update existing rows in a table. If any of the rows does not + // already exist, the transaction fails with error `NOT_FOUND`. + Write update = 2; + + // Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, then + // its column values are overwritten with the ones provided. Any + // column values not explicitly written are preserved. + // + // When using [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as when using [insert][google.spanner.v1.Mutation.insert], all `NOT + // NULL` columns in the table must be given a value. This holds true + // even when the row already exists and will therefore actually be updated. + Write insert_or_update = 3; + + // Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is + // deleted, and the column values provided are inserted + // instead. Unlike [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this means any values not + // explicitly written become `NULL`. + // + // In an interleaved table, if you create the child table with the + // `ON DELETE CASCADE` annotation, then replacing a parent row + // also deletes the child rows. Otherwise, you must delete the + // child rows before you replace the parent row. + Write replace = 4; + + // Delete rows from a table. Succeeds whether or not the named + // rows were present. + Delete delete = 5; + } +} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/query_plan.proto b/owl-bot-staging/v1/protos/google/spanner/v1/query_plan.proto new file mode 100644 index 000000000..9ea40fe4a --- /dev/null +++ b/owl-bot-staging/v1/protos/google/spanner/v1/query_plan.proto @@ -0,0 +1,128 @@ +// 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.spanner.v1; + +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; +option java_multiple_files = true; +option java_outer_classname = "QueryPlanProto"; +option java_package = "com.google.spanner.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\V1"; +option ruby_package = "Google::Cloud::Spanner::V1"; + +// Node information for nodes appearing in a [QueryPlan.plan_nodes][google.spanner.v1.QueryPlan.plan_nodes]. +message PlanNode { + // The kind of [PlanNode][google.spanner.v1.PlanNode]. Distinguishes between the two different kinds of + // nodes that can appear in a query plan. + enum Kind { + // Not specified. + KIND_UNSPECIFIED = 0; + + // Denotes a Relational operator node in the expression tree. Relational + // operators represent iterative processing of rows during query execution. + // For example, a `TableScan` operation that reads rows from a table. + RELATIONAL = 1; + + // Denotes a Scalar node in the expression tree. Scalar nodes represent + // non-iterable entities in the query plan. For example, constants or + // arithmetic operators appearing inside predicate expressions or references + // to column names. + SCALAR = 2; + } + + // Metadata associated with a parent-child relationship appearing in a + // [PlanNode][google.spanner.v1.PlanNode]. + message ChildLink { + // The node to which the link points. + int32 child_index = 1; + + // The type of the link. For example, in Hash Joins this could be used to + // distinguish between the build child and the probe child, or in the case + // of the child being an output variable, to represent the tag associated + // with the output variable. + string type = 2; + + // Only present if the child node is [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds + // to an output variable of the parent node. The field carries the name of + // the output variable. + // For example, a `TableScan` operator that reads rows from a table will + // have child links to the `SCALAR` nodes representing the output variables + // created for each column that is read by the operator. The corresponding + // `variable` fields will be set to the variable names assigned to the + // columns. + string variable = 3; + } + + // Condensed representation of a node and its subtree. Only present for + // `SCALAR` [PlanNode(s)][google.spanner.v1.PlanNode]. + message ShortRepresentation { + // A string representation of the expression subtree rooted at this node. + string description = 1; + + // A mapping of (subquery variable name) -> (subquery node id) for cases + // where the `description` string of this node references a `SCALAR` + // subquery contained in the expression subtree rooted at this node. The + // referenced `SCALAR` subquery may not necessarily be a direct child of + // this node. + map subqueries = 2; + } + + // The `PlanNode`'s index in [node list][google.spanner.v1.QueryPlan.plan_nodes]. + int32 index = 1; + + // Used to determine the type of node. May be needed for visualizing + // different kinds of nodes differently. For example, If the node is a + // [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a condensed representation + // which can be used to directly embed a description of the node in its + // parent. + Kind kind = 2; + + // The display name for the node. + string display_name = 3; + + // List of child node `index`es and their relationship to this parent. + repeated ChildLink child_links = 4; + + // Condensed representation for [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes. + ShortRepresentation short_representation = 5; + + // Attributes relevant to the node contained in a group of key-value pairs. + // For example, a Parameter Reference node could have the following + // information in its metadata: + // + // { + // "parameter_reference": "param1", + // "parameter_type": "array" + // } + google.protobuf.Struct metadata = 6; + + // The execution statistics associated with the node, contained in a group of + // key-value pairs. Only present if the plan was returned as a result of a + // profile query. For example, number of executions, number of rows/time per + // execution etc. + google.protobuf.Struct execution_stats = 7; +} + +// Contains an ordered list of nodes appearing in the query plan. +message QueryPlan { + // The nodes in the query plan. Plan nodes are returned in pre-order starting + // with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id` corresponds to its index in + // `plan_nodes`. + repeated PlanNode plan_nodes = 1; +} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/result_set.proto b/owl-bot-staging/v1/protos/google/spanner/v1/result_set.proto new file mode 100644 index 000000000..36df232bc --- /dev/null +++ b/owl-bot-staging/v1/protos/google/spanner/v1/result_set.proto @@ -0,0 +1,216 @@ +// 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.spanner.v1; + +import "google/protobuf/struct.proto"; +import "google/spanner/v1/query_plan.proto"; +import "google/spanner/v1/transaction.proto"; +import "google/spanner/v1/type.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Spanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; +option java_multiple_files = true; +option java_outer_classname = "ResultSetProto"; +option java_package = "com.google.spanner.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\V1"; +option ruby_package = "Google::Cloud::Spanner::V1"; + +// Results from [Read][google.spanner.v1.Spanner.Read] or +// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. +message ResultSet { + // Metadata about the result set, such as row type information. + ResultSetMetadata metadata = 1; + + // Each element in `rows` is a row whose format is defined by + // [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith element + // in each row matches the ith field in + // [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements are + // encoded based on type as described + // [here][google.spanner.v1.TypeCode]. + repeated google.protobuf.ListValue rows = 2; + + // Query plan and execution statistics for the SQL statement that + // produced this result set. These can be requested by setting + // [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + // DML statements always produce stats containing the number of rows + // modified, unless executed using the + // [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN] [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + // Other fields may or may not be populated, based on the + // [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. + ResultSetStats stats = 3; +} + +// Partial results from a streaming read or SQL query. Streaming reads and +// SQL queries better tolerate large result sets, large rows, and large +// values, but are a little trickier to consume. +message PartialResultSet { + // Metadata about the result set, such as row type information. + // Only present in the first response. + ResultSetMetadata metadata = 1; + + // A streamed result set consists of a stream of values, which might + // be split into many `PartialResultSet` messages to accommodate + // large rows and/or large values. Every N complete values defines a + // row, where N is equal to the number of entries in + // [metadata.row_type.fields][google.spanner.v1.StructType.fields]. + // + // Most values are encoded based on type as described + // [here][google.spanner.v1.TypeCode]. + // + // It is possible that the last value in values is "chunked", + // meaning that the rest of the value is sent in subsequent + // `PartialResultSet`(s). This is denoted by the [chunked_value][google.spanner.v1.PartialResultSet.chunked_value] + // field. Two or more chunked values can be merged to form a + // complete value as follows: + // + // * `bool/number/null`: cannot be chunked + // * `string`: concatenate the strings + // * `list`: concatenate the lists. If the last element in a list is a + // `string`, `list`, or `object`, merge it with the first element in + // the next list by applying these rules recursively. + // * `object`: concatenate the (field name, field value) pairs. If a + // field name is duplicated, then apply these rules recursively + // to merge the field values. + // + // Some examples of merging: + // + // # Strings are concatenated. + // "foo", "bar" => "foobar" + // + // # Lists of non-strings are concatenated. + // [2, 3], [4] => [2, 3, 4] + // + // # Lists are concatenated, but the last and first elements are merged + // # because they are strings. + // ["a", "b"], ["c", "d"] => ["a", "bc", "d"] + // + // # Lists are concatenated, but the last and first elements are merged + // # because they are lists. Recursively, the last and first elements + // # of the inner lists are merged because they are strings. + // ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"] + // + // # Non-overlapping object fields are combined. + // {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"} + // + // # Overlapping object fields are merged. + // {"a": "1"}, {"a": "2"} => {"a": "12"} + // + // # Examples of merging objects containing lists of strings. + // {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]} + // + // For a more complete example, suppose a streaming SQL query is + // yielding a result set whose rows contain a single string + // field. The following `PartialResultSet`s might be yielded: + // + // { + // "metadata": { ... } + // "values": ["Hello", "W"] + // "chunked_value": true + // "resume_token": "Af65..." + // } + // { + // "values": ["orl"] + // "chunked_value": true + // "resume_token": "Bqp2..." + // } + // { + // "values": ["d"] + // "resume_token": "Zx1B..." + // } + // + // This sequence of `PartialResultSet`s encodes two rows, one + // containing the field value `"Hello"`, and a second containing the + // field value `"World" = "W" + "orl" + "d"`. + repeated google.protobuf.Value values = 2; + + // If true, then the final value in [values][google.spanner.v1.PartialResultSet.values] is chunked, and must + // be combined with more values from subsequent `PartialResultSet`s + // to obtain a complete field value. + bool chunked_value = 3; + + // Streaming calls might be interrupted for a variety of reasons, such + // as TCP connection loss. If this occurs, the stream of results can + // be resumed by re-sending the original request and including + // `resume_token`. Note that executing any other transaction in the + // same session invalidates the token. + bytes resume_token = 4; + + // Query plan and execution statistics for the statement that produced this + // streaming result set. These can be requested by setting + // [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] and are sent + // only once with the last response in the stream. + // This field will also be present in the last response for DML + // statements. + ResultSetStats stats = 5; +} + +// Metadata about a [ResultSet][google.spanner.v1.ResultSet] or [PartialResultSet][google.spanner.v1.PartialResultSet]. +message ResultSetMetadata { + // Indicates the field names and types for the rows in the result + // set. For example, a SQL query like `"SELECT UserId, UserName FROM + // Users"` could return a `row_type` value like: + // + // "fields": [ + // { "name": "UserId", "type": { "code": "INT64" } }, + // { "name": "UserName", "type": { "code": "STRING" } }, + // ] + StructType row_type = 1; + + // If the read or SQL query began a transaction as a side-effect, the + // information about the new transaction is yielded here. + Transaction transaction = 2; + + // A SQL query can be parameterized. In PLAN mode, these parameters can be + // undeclared. This indicates the field names and types for those undeclared + // parameters in the SQL query. For example, a SQL query like `"SELECT * FROM + // Users where UserId = @userId and UserName = @userName "` could return a + // `undeclared_parameters` value like: + // + // "fields": [ + // { "name": "UserId", "type": { "code": "INT64" } }, + // { "name": "UserName", "type": { "code": "STRING" } }, + // ] + StructType undeclared_parameters = 3; +} + +// Additional statistics about a [ResultSet][google.spanner.v1.ResultSet] or [PartialResultSet][google.spanner.v1.PartialResultSet]. +message ResultSetStats { + // [QueryPlan][google.spanner.v1.QueryPlan] for the query associated with this result. + QueryPlan query_plan = 1; + + // Aggregated statistics from the execution of the query. Only present when + // the query is profiled. For example, a query could return the statistics as + // follows: + // + // { + // "rows_returned": "3", + // "elapsed_time": "1.22 secs", + // "cpu_time": "1.19 secs" + // } + google.protobuf.Struct query_stats = 2; + + // The number of rows modified by the DML statement. + oneof row_count { + // Standard DML returns an exact count of rows that were modified. + int64 row_count_exact = 3; + + // Partitioned DML does not offer exactly-once semantics, so it + // returns a lower bound of the rows modified. + int64 row_count_lower_bound = 4; + } +} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/spanner.proto b/owl-bot-staging/v1/protos/google/spanner/v1/spanner.proto new file mode 100644 index 000000000..77a1f0e47 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/spanner/v1/spanner.proto @@ -0,0 +1,1042 @@ +// 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.spanner.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import public "google/spanner/v1/commit_response.proto"; +import "google/spanner/v1/keys.proto"; +import "google/spanner/v1/mutation.proto"; +import "google/spanner/v1/result_set.proto"; +import "google/spanner/v1/transaction.proto"; +import "google/spanner/v1/type.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; +option java_multiple_files = true; +option java_outer_classname = "SpannerProto"; +option java_package = "com.google.spanner.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\V1"; +option ruby_package = "Google::Cloud::Spanner::V1"; +option (google.api.resource_definition) = { + type: "spanner.googleapis.com/Database" + pattern: "projects/{project}/instances/{instance}/databases/{database}" +}; + +// Cloud Spanner API +// +// The Cloud Spanner API can be used to manage sessions and execute +// transactions on data stored in Cloud Spanner databases. +service Spanner { + option (google.api.default_host) = "spanner.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/spanner.data"; + + // Creates a new session. A session can be used to perform + // transactions that read and/or modify data in a Cloud Spanner database. + // Sessions are meant to be reused for many consecutive + // transactions. + // + // Sessions can only execute one transaction at a time. To execute + // multiple concurrent read-write/write-only transactions, create + // multiple sessions. Note that standalone reads and queries use a + // transaction internally, and count toward the one transaction + // limit. + // + // Active sessions use additional server resources, so it is a good idea to + // delete idle and unneeded sessions. + // Aside from explicit deletes, Cloud Spanner may delete sessions for which no + // operations are sent for more than an hour. If a session is deleted, + // requests to it return `NOT_FOUND`. + // + // Idle sessions can be kept alive by sending a trivial SQL query + // periodically, e.g., `"SELECT 1"`. + rpc CreateSession(CreateSessionRequest) returns (Session) { + option (google.api.http) = { + post: "/v1/{database=projects/*/instances/*/databases/*}/sessions" + body: "*" + }; + option (google.api.method_signature) = "database"; + } + + // Creates multiple new sessions. + // + // This API can be used to initialize a session cache on the clients. + // See https://goo.gl/TgSFN2 for best practices on session cache management. + rpc BatchCreateSessions(BatchCreateSessionsRequest) returns (BatchCreateSessionsResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate" + body: "*" + }; + option (google.api.method_signature) = "database,session_count"; + } + + // Gets a session. Returns `NOT_FOUND` if the session does not exist. + // This is mainly useful for determining whether a session is still + // alive. + rpc GetSession(GetSessionRequest) returns (Session) { + option (google.api.http) = { + get: "/v1/{name=projects/*/instances/*/databases/*/sessions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all sessions in a given database. + rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse) { + option (google.api.http) = { + get: "/v1/{database=projects/*/instances/*/databases/*}/sessions" + }; + option (google.api.method_signature) = "database"; + } + + // Ends a session, releasing server resources associated with it. This will + // asynchronously trigger cancellation of any operations that are running with + // this session. + rpc DeleteSession(DeleteSessionRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/instances/*/databases/*/sessions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Executes an SQL statement, returning all results in a single reply. This + // method cannot be used to return a result set larger than 10 MiB; + // if the query yields more data than that, the query fails with + // a `FAILED_PRECONDITION` error. + // + // Operations inside read-write transactions might return `ABORTED`. If + // this occurs, the application should restart the transaction from + // the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. + // + // Larger result sets can be fetched in streaming fashion by calling + // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. + rpc ExecuteSql(ExecuteSqlRequest) returns (ResultSet) { + option (google.api.http) = { + post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql" + body: "*" + }; + } + + // Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the result + // set as a stream. Unlike [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there + // is no limit on the size of the returned result set. However, no + // individual row in the result set can exceed 100 MiB, and no + // column value can exceed 10 MiB. + rpc ExecuteStreamingSql(ExecuteSqlRequest) returns (stream PartialResultSet) { + option (google.api.http) = { + post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql" + body: "*" + }; + } + + // Executes a batch of SQL DML statements. This method allows many statements + // to be run with lower latency than submitting them sequentially with + // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. + // + // Statements are executed in sequential order. A request can succeed even if + // a statement fails. The [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] field in the + // response provides information about the statement that failed. Clients must + // inspect this field to determine whether an error occurred. + // + // Execution stops after the first failed statement; the remaining statements + // are not executed. + rpc ExecuteBatchDml(ExecuteBatchDmlRequest) returns (ExecuteBatchDmlResponse) { + option (google.api.http) = { + post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml" + body: "*" + }; + } + + // Reads rows from the database using key lookups and scans, as a + // simple key/value style alternative to + // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be used to + // return a result set larger than 10 MiB; if the read matches more + // data than that, the read fails with a `FAILED_PRECONDITION` + // error. + // + // Reads inside read-write transactions might return `ABORTED`. If + // this occurs, the application should restart the transaction from + // the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. + // + // Larger result sets can be yielded in streaming fashion by calling + // [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. + rpc Read(ReadRequest) returns (ResultSet) { + option (google.api.http) = { + post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read" + body: "*" + }; + } + + // Like [Read][google.spanner.v1.Spanner.Read], except returns the result set as a + // stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no limit on the + // size of the returned result set. However, no individual row in + // the result set can exceed 100 MiB, and no column value can exceed + // 10 MiB. + rpc StreamingRead(ReadRequest) returns (stream PartialResultSet) { + option (google.api.http) = { + post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead" + body: "*" + }; + } + + // Begins a new transaction. This step can often be skipped: + // [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and + // [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a + // side-effect. + rpc BeginTransaction(BeginTransactionRequest) returns (Transaction) { + option (google.api.http) = { + post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction" + body: "*" + }; + option (google.api.method_signature) = "session,options"; + } + + // Commits a transaction. The request includes the mutations to be + // applied to rows in the database. + // + // `Commit` might return an `ABORTED` error. This can occur at any time; + // commonly, the cause is conflicts with concurrent + // transactions. However, it can also happen for a variety of other + // reasons. If `Commit` returns `ABORTED`, the caller should re-attempt + // the transaction from the beginning, re-using the same session. + // + // On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, + // for example, if the client job experiences a 1+ hour networking failure. + // At that point, Cloud Spanner has lost track of the transaction outcome and + // we recommend that you perform another read from the database to see the + // state of things as they are now. + rpc Commit(CommitRequest) returns (CommitResponse) { + option (google.api.http) = { + post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit" + body: "*" + }; + option (google.api.method_signature) = "session,transaction_id,mutations"; + option (google.api.method_signature) = "session,single_use_transaction,mutations"; + } + + // Rolls back a transaction, releasing any locks it holds. It is a good + // idea to call this for any transaction that includes one or more + // [Read][google.spanner.v1.Spanner.Read] or [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and + // ultimately decides not to commit. + // + // `Rollback` returns `OK` if it successfully aborts the transaction, the + // transaction was already aborted, or the transaction is not + // found. `Rollback` never returns `ABORTED`. + rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback" + body: "*" + }; + option (google.api.method_signature) = "session,transaction_id"; + } + + // Creates a set of partition tokens that can be used to execute a query + // operation in parallel. Each of the returned partition tokens can be used + // by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to specify a subset + // of the query result to read. The same session and read-only transaction + // must be used by the PartitionQueryRequest used to create the + // partition tokens and the ExecuteSqlRequests that use the partition tokens. + // + // Partition tokens become invalid when the session used to create them + // is deleted, is idle for too long, begins a new transaction, or becomes too + // old. When any of these happen, it is not possible to resume the query, and + // the whole operation must be restarted from the beginning. + rpc PartitionQuery(PartitionQueryRequest) returns (PartitionResponse) { + option (google.api.http) = { + post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery" + body: "*" + }; + } + + // Creates a set of partition tokens that can be used to execute a read + // operation in parallel. Each of the returned partition tokens can be used + // by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a subset of the read + // result to read. The same session and read-only transaction must be used by + // the PartitionReadRequest used to create the partition tokens and the + // ReadRequests that use the partition tokens. There are no ordering + // guarantees on rows returned among the returned partition tokens, or even + // within each individual StreamingRead call issued with a partition_token. + // + // Partition tokens become invalid when the session used to create them + // is deleted, is idle for too long, begins a new transaction, or becomes too + // old. When any of these happen, it is not possible to resume the read, and + // the whole operation must be restarted from the beginning. + rpc PartitionRead(PartitionReadRequest) returns (PartitionResponse) { + option (google.api.http) = { + post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionRead" + body: "*" + }; + } +} + +// The request for [CreateSession][google.spanner.v1.Spanner.CreateSession]. +message CreateSessionRequest { + // Required. The database in which the new session is created. + string database = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; + + // Required. The session to create. + Session session = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. +message BatchCreateSessionsRequest { + // Required. The database in which the new sessions are created. + string database = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; + + // Parameters to be applied to each created session. + Session session_template = 2; + + // Required. The number of sessions to be created in this batch call. + // The API may return fewer than the requested number of sessions. If a + // specific number of sessions are desired, the client can make additional + // calls to BatchCreateSessions (adjusting + // [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary). + int32 session_count = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The response for [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. +message BatchCreateSessionsResponse { + // The freshly created sessions. + repeated Session session = 1; +} + +// A session in the Cloud Spanner API. +message Session { + option (google.api.resource) = { + type: "spanner.googleapis.com/Session" + pattern: "projects/{project}/instances/{instance}/databases/{database}/sessions/{session}" + }; + + // Output only. The name of the session. This is always system-assigned. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The labels for the session. + // + // * Label keys must be between 1 and 63 characters long and must conform to + // the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`. + // * Label values must be between 0 and 63 characters long and must conform + // to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. + // * No more than 64 labels can be associated with a given session. + // + // See https://goo.gl/xmQnxf for more information on and examples of labels. + map labels = 2; + + // Output only. The timestamp when the session is created. + google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The approximate timestamp when the session is last used. It is + // typically earlier than the actual last use time. + google.protobuf.Timestamp approximate_last_use_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The database role which created this session. + string creator_role = 5; +} + +// The request for [GetSession][google.spanner.v1.Spanner.GetSession]. +message GetSessionRequest { + // Required. The name of the session to retrieve. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } + ]; +} + +// The request for [ListSessions][google.spanner.v1.Spanner.ListSessions]. +message ListSessionsRequest { + // Required. The database in which to list sessions. + string database = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; + + // Number of sessions to be returned in the response. If 0 or less, defaults + // to the server's maximum allowed page size. + int32 page_size = 2; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token] from a previous + // [ListSessionsResponse][google.spanner.v1.ListSessionsResponse]. + string page_token = 3; + + // An expression for filtering the results of the request. Filter rules are + // case insensitive. The fields eligible for filtering are: + // + // * `labels.key` where key is the name of a label + // + // Some examples of using filters are: + // + // * `labels.env:*` --> The session has the label "env". + // * `labels.env:dev` --> The session has the label "env" and the value of + // the label contains the string "dev". + string filter = 4; +} + +// The response for [ListSessions][google.spanner.v1.Spanner.ListSessions]. +message ListSessionsResponse { + // The list of requested sessions. + repeated Session sessions = 1; + + // `next_page_token` can be sent in a subsequent + // [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more of the matching + // sessions. + string next_page_token = 2; +} + +// The request for [DeleteSession][google.spanner.v1.Spanner.DeleteSession]. +message DeleteSessionRequest { + // Required. The name of the session to delete. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } + ]; +} + +// Common request options for various APIs. +message RequestOptions { + // The relative priority for requests. Note that priority is not applicable + // for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction]. + // + // The priority acts as a hint to the Cloud Spanner scheduler and does not + // guarantee priority or order of execution. For example: + // + // * Some parts of a write operation always execute at `PRIORITY_HIGH`, + // regardless of the specified priority. This may cause you to see an + // increase in high priority workload even when executing a low priority + // request. This can also potentially cause a priority inversion where a + // lower priority request will be fulfilled ahead of a higher priority + // request. + // * If a transaction contains multiple operations with different priorities, + // Cloud Spanner does not guarantee to process the higher priority + // operations first. There may be other constraints to satisfy, such as + // order of operations. + enum Priority { + // `PRIORITY_UNSPECIFIED` is equivalent to `PRIORITY_HIGH`. + PRIORITY_UNSPECIFIED = 0; + + // This specifies that the request is low priority. + PRIORITY_LOW = 1; + + // This specifies that the request is medium priority. + PRIORITY_MEDIUM = 2; + + // This specifies that the request is high priority. + PRIORITY_HIGH = 3; + } + + // Priority for the request. + Priority priority = 1; + + // A per-request tag which can be applied to queries or reads, used for + // statistics collection. + // Both request_tag and transaction_tag can be specified for a read or query + // that belongs to a transaction. + // This field is ignored for requests where it's not applicable (e.g. + // CommitRequest). + // Legal characters for `request_tag` values are all printable characters + // (ASCII 32 - 126) and the length of a request_tag is limited to 50 + // characters. Values that exceed this limit are truncated. + // Any leading underscore (_) characters will be removed from the string. + string request_tag = 2; + + // A tag used for statistics collection about this transaction. + // Both request_tag and transaction_tag can be specified for a read or query + // that belongs to a transaction. + // The value of transaction_tag should be the same for all requests belonging + // to the same transaction. + // If this request doesn't belong to any transaction, transaction_tag will be + // ignored. + // Legal characters for `transaction_tag` values are all printable characters + // (ASCII 32 - 126) and the length of a transaction_tag is limited to 50 + // characters. Values that exceed this limit are truncated. + // Any leading underscore (_) characters will be removed from the string. + string transaction_tag = 3; +} + +// The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and +// [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql]. +message ExecuteSqlRequest { + // Mode in which the statement must be processed. + enum QueryMode { + // The default mode. Only the statement results are returned. + NORMAL = 0; + + // This mode returns only the query plan, without any results or + // execution statistics information. + PLAN = 1; + + // This mode returns both the query plan and the execution statistics along + // with the results. + PROFILE = 2; + } + + // Query optimizer configuration. + message QueryOptions { + // An option to control the selection of optimizer version. + // + // This parameter allows individual queries to pick different query + // optimizer versions. + // + // Specifying `latest` as a value instructs Cloud Spanner to use the + // latest supported query optimizer version. If not specified, Cloud Spanner + // uses the optimizer version set at the database level options. Any other + // positive integer (from the list of supported optimizer versions) + // overrides the default optimizer version for query execution. + // + // The list of supported optimizer versions can be queried from + // SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS. + // + // Executing a SQL statement with an invalid optimizer version fails with + // an `INVALID_ARGUMENT` error. + // + // See + // https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer + // for more information on managing the query optimizer. + // + // The `optimizer_version` statement hint has precedence over this setting. + string optimizer_version = 1; + + // An option to control the selection of optimizer statistics package. + // + // This parameter allows individual queries to use a different query + // optimizer statistics package. + // + // Specifying `latest` as a value instructs Cloud Spanner to use the latest + // generated statistics package. If not specified, Cloud Spanner uses + // the statistics package set at the database level options, or the latest + // package if the database option is not set. + // + // The statistics package requested by the query has to be exempt from + // garbage collection. This can be achieved with the following DDL + // statement: + // + // ``` + // ALTER STATISTICS SET OPTIONS (allow_gc=false) + // ``` + // + // The list of available statistics packages can be queried from + // `INFORMATION_SCHEMA.SPANNER_STATISTICS`. + // + // Executing a SQL statement with an invalid optimizer statistics package + // or with a statistics package that allows garbage collection fails with + // an `INVALID_ARGUMENT` error. + string optimizer_statistics_package = 2; + } + + // Required. The session in which the SQL query should be performed. + string session = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } + ]; + + // The transaction to use. + // + // For queries, if none is provided, the default is a temporary read-only + // transaction with strong concurrency. + // + // Standard DML statements require a read-write transaction. To protect + // against replays, single-use transactions are not supported. The caller + // must either supply an existing transaction ID or begin a new transaction. + // + // Partitioned DML requires an existing Partitioned DML transaction ID. + TransactionSelector transaction = 2; + + // Required. The SQL string. + string sql = 3 [(google.api.field_behavior) = REQUIRED]; + + // Parameter names and values that bind to placeholders in the SQL string. + // + // A parameter placeholder consists of the `@` character followed by the + // parameter name (for example, `@firstName`). Parameter names must conform + // to the naming requirements of identifiers as specified at + // https://cloud.google.com/spanner/docs/lexical#identifiers. + // + // Parameters can appear anywhere that a literal value is expected. The same + // parameter name can be used more than once, for example: + // + // `"WHERE id > @msg_id AND id < @msg_id + 100"` + // + // It is an error to execute a SQL statement with unbound parameters. + google.protobuf.Struct params = 4; + + // It is not always possible for Cloud Spanner to infer the right SQL type + // from a JSON value. For example, values of type `BYTES` and values + // of type `STRING` both appear in [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings. + // + // In these cases, `param_types` can be used to specify the exact + // SQL type for some or all of the SQL statement parameters. See the + // definition of [Type][google.spanner.v1.Type] for more information + // about SQL types. + map param_types = 5; + + // If this request is resuming a previously interrupted SQL statement + // execution, `resume_token` should be copied from the last + // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the interruption. Doing this + // enables the new SQL statement execution to resume where the last one left + // off. The rest of the request parameters must exactly match the + // request that yielded this token. + bytes resume_token = 6; + + // Used to control the amount of debugging information returned in + // [ResultSetStats][google.spanner.v1.ResultSetStats]. If [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only + // be set to [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]. + QueryMode query_mode = 7; + + // If present, results will be restricted to the specified partition + // previously created using PartitionQuery(). There must be an exact + // match for the values of fields common to this message and the + // PartitionQueryRequest message used to create this partition_token. + bytes partition_token = 8; + + // A per-transaction sequence number used to identify this request. This field + // makes each request idempotent such that if the request is received multiple + // times, at most one will succeed. + // + // The sequence number must be monotonically increasing within the + // transaction. If a request arrives for the first time with an out-of-order + // sequence number, the transaction may be aborted. Replays of previously + // handled requests will yield the same response as the first execution. + // + // Required for DML statements. Ignored for queries. + int64 seqno = 9; + + // Query optimizer configuration to use for the given query. + QueryOptions query_options = 10; + + // Common options for this request. + RequestOptions request_options = 11; + + // If this is for a partitioned read and this field is set to `true`, the + // request will be executed via Spanner independent compute resources. + // + // If the field is set to `true` but the request does not set + // `partition_token`, the API will return an `INVALID_ARGUMENT` error. + bool data_boost_enabled = 15; +} + +// The request for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. +message ExecuteBatchDmlRequest { + // A single DML statement. + message Statement { + // Required. The DML string. + string sql = 1 [(google.api.field_behavior) = REQUIRED]; + + // Parameter names and values that bind to placeholders in the DML string. + // + // A parameter placeholder consists of the `@` character followed by the + // parameter name (for example, `@firstName`). Parameter names can contain + // letters, numbers, and underscores. + // + // Parameters can appear anywhere that a literal value is expected. The + // same parameter name can be used more than once, for example: + // + // `"WHERE id > @msg_id AND id < @msg_id + 100"` + // + // It is an error to execute a SQL statement with unbound parameters. + google.protobuf.Struct params = 2; + + // It is not always possible for Cloud Spanner to infer the right SQL type + // from a JSON value. For example, values of type `BYTES` and values + // of type `STRING` both appear in [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as JSON strings. + // + // In these cases, `param_types` can be used to specify the exact + // SQL type for some or all of the SQL statement parameters. See the + // definition of [Type][google.spanner.v1.Type] for more information + // about SQL types. + map param_types = 3; + } + + // Required. The session in which the DML statements should be performed. + string session = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } + ]; + + // Required. The transaction to use. Must be a read-write transaction. + // + // To protect against replays, single-use transactions are not supported. The + // caller must either supply an existing transaction ID or begin a new + // transaction. + TransactionSelector transaction = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The list of statements to execute in this batch. Statements are executed + // serially, such that the effects of statement `i` are visible to statement + // `i+1`. Each statement must be a DML statement. Execution stops at the + // first failed statement; the remaining statements are not executed. + // + // Callers must provide at least one statement. + repeated Statement statements = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. A per-transaction sequence number used to identify this request. This field + // makes each request idempotent such that if the request is received multiple + // times, at most one will succeed. + // + // The sequence number must be monotonically increasing within the + // transaction. If a request arrives for the first time with an out-of-order + // sequence number, the transaction may be aborted. Replays of previously + // handled requests will yield the same response as the first execution. + int64 seqno = 4 [(google.api.field_behavior) = REQUIRED]; + + // Common options for this request. + RequestOptions request_options = 5; +} + +// The response for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list +// of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML statement that has successfully +// executed, in the same order as the statements in the request. If a statement +// fails, the status in the response body identifies the cause of the failure. +// +// To check for DML statements that failed, use the following approach: +// +// 1. Check the status in the response message. The [google.rpc.Code][google.rpc.Code] enum +// value `OK` indicates that all statements were executed successfully. +// 2. If the status was not `OK`, check the number of result sets in the +// response. If the response contains `N` [ResultSet][google.spanner.v1.ResultSet] messages, then +// statement `N+1` in the request failed. +// +// Example 1: +// +// * Request: 5 DML statements, all executed successfully. +// * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the status `OK`. +// +// Example 2: +// +// * Request: 5 DML statements. The third statement has a syntax error. +// * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax error (`INVALID_ARGUMENT`) +// status. The number of [ResultSet][google.spanner.v1.ResultSet] messages indicates that the third +// statement failed, and the fourth and fifth statements were not executed. +message ExecuteBatchDmlResponse { + // One [ResultSet][google.spanner.v1.ResultSet] for each statement in the request that ran successfully, + // in the same order as the statements in the request. Each [ResultSet][google.spanner.v1.ResultSet] does + // not contain any rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each [ResultSet][google.spanner.v1.ResultSet] contain + // the number of rows modified by the statement. + // + // Only the first [ResultSet][google.spanner.v1.ResultSet] in the response contains valid + // [ResultSetMetadata][google.spanner.v1.ResultSetMetadata]. + repeated ResultSet result_sets = 1; + + // If all DML statements are executed successfully, the status is `OK`. + // Otherwise, the error status of the first failed statement. + google.rpc.Status status = 2; +} + +// Options for a PartitionQueryRequest and +// PartitionReadRequest. +message PartitionOptions { + // **Note:** This hint is currently ignored by PartitionQuery and + // PartitionRead requests. + // + // The desired data size for each partition generated. The default for this + // option is currently 1 GiB. This is only a hint. The actual size of each + // partition may be smaller or larger than this size request. + int64 partition_size_bytes = 1; + + // **Note:** This hint is currently ignored by PartitionQuery and + // PartitionRead requests. + // + // The desired maximum number of partitions to return. For example, this may + // be set to the number of workers available. The default for this option + // is currently 10,000. The maximum value is currently 200,000. This is only + // a hint. The actual number of partitions returned may be smaller or larger + // than this maximum count request. + int64 max_partitions = 2; +} + +// The request for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery] +message PartitionQueryRequest { + // Required. The session used to create the partitions. + string session = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } + ]; + + // Read only snapshot transactions are supported, read/write and single use + // transactions are not. + TransactionSelector transaction = 2; + + // Required. The query request to generate partitions for. The request will fail if + // the query is not root partitionable. The query plan of a root + // partitionable query has a single distributed union operator. A distributed + // union operator conceptually divides one or more tables into multiple + // splits, remotely evaluates a subquery independently on each split, and + // then unions all results. + // + // This must not contain DML commands, such as INSERT, UPDATE, or + // DELETE. Use [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a + // PartitionedDml transaction for large, partition-friendly DML operations. + string sql = 3 [(google.api.field_behavior) = REQUIRED]; + + // Parameter names and values that bind to placeholders in the SQL string. + // + // A parameter placeholder consists of the `@` character followed by the + // parameter name (for example, `@firstName`). Parameter names can contain + // letters, numbers, and underscores. + // + // Parameters can appear anywhere that a literal value is expected. The same + // parameter name can be used more than once, for example: + // + // `"WHERE id > @msg_id AND id < @msg_id + 100"` + // + // It is an error to execute a SQL statement with unbound parameters. + google.protobuf.Struct params = 4; + + // It is not always possible for Cloud Spanner to infer the right SQL type + // from a JSON value. For example, values of type `BYTES` and values + // of type `STRING` both appear in [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings. + // + // In these cases, `param_types` can be used to specify the exact + // SQL type for some or all of the SQL query parameters. See the + // definition of [Type][google.spanner.v1.Type] for more information + // about SQL types. + map param_types = 5; + + // Additional options that affect how many partitions are created. + PartitionOptions partition_options = 6; +} + +// The request for [PartitionRead][google.spanner.v1.Spanner.PartitionRead] +message PartitionReadRequest { + // Required. The session used to create the partitions. + string session = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } + ]; + + // Read only snapshot transactions are supported, read/write and single use + // transactions are not. + TransactionSelector transaction = 2; + + // Required. The name of the table in the database to be read. + string table = 3 [(google.api.field_behavior) = REQUIRED]; + + // If non-empty, the name of an index on [table][google.spanner.v1.PartitionReadRequest.table]. This index is + // used instead of the table primary key when interpreting [key_set][google.spanner.v1.PartitionReadRequest.key_set] + // and sorting result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set] for further information. + string index = 4; + + // The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be returned for each row matching + // this request. + repeated string columns = 5; + + // Required. `key_set` identifies the rows to be yielded. `key_set` names the + // primary keys of the rows in [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless [index][google.spanner.v1.PartitionReadRequest.index] + // is present. If [index][google.spanner.v1.PartitionReadRequest.index] is present, then [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names + // index keys in [index][google.spanner.v1.PartitionReadRequest.index]. + // + // It is not an error for the `key_set` to name rows that do not + // exist in the database. Read yields nothing for nonexistent rows. + KeySet key_set = 6 [(google.api.field_behavior) = REQUIRED]; + + // Additional options that affect how many partitions are created. + PartitionOptions partition_options = 9; +} + +// Information returned for each partition returned in a +// PartitionResponse. +message Partition { + // This token can be passed to Read, StreamingRead, ExecuteSql, or + // ExecuteStreamingSql requests to restrict the results to those identified by + // this partition token. + bytes partition_token = 1; +} + +// The response for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery] +// or [PartitionRead][google.spanner.v1.Spanner.PartitionRead] +message PartitionResponse { + // Partitions created by this request. + repeated Partition partitions = 1; + + // Transaction created by this request. + Transaction transaction = 2; +} + +// The request for [Read][google.spanner.v1.Spanner.Read] and +// [StreamingRead][google.spanner.v1.Spanner.StreamingRead]. +message ReadRequest { + // Required. The session in which the read should be performed. + string session = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } + ]; + + // The transaction to use. If none is provided, the default is a + // temporary read-only transaction with strong concurrency. + TransactionSelector transaction = 2; + + // Required. The name of the table in the database to be read. + string table = 3 [(google.api.field_behavior) = REQUIRED]; + + // If non-empty, the name of an index on [table][google.spanner.v1.ReadRequest.table]. This index is + // used instead of the table primary key when interpreting [key_set][google.spanner.v1.ReadRequest.key_set] + // and sorting result rows. See [key_set][google.spanner.v1.ReadRequest.key_set] for further information. + string index = 4; + + // Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be returned for each row matching + // this request. + repeated string columns = 5 [(google.api.field_behavior) = REQUIRED]; + + // Required. `key_set` identifies the rows to be yielded. `key_set` names the + // primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to be yielded, unless [index][google.spanner.v1.ReadRequest.index] + // is present. If [index][google.spanner.v1.ReadRequest.index] is present, then [key_set][google.spanner.v1.ReadRequest.key_set] instead names + // index keys in [index][google.spanner.v1.ReadRequest.index]. + // + // If the [partition_token][google.spanner.v1.ReadRequest.partition_token] field is empty, rows are yielded + // in table primary key order (if [index][google.spanner.v1.ReadRequest.index] is empty) or index key order + // (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the [partition_token][google.spanner.v1.ReadRequest.partition_token] field is not + // empty, rows will be yielded in an unspecified order. + // + // It is not an error for the `key_set` to name rows that do not + // exist in the database. Read yields nothing for nonexistent rows. + KeySet key_set = 6 [(google.api.field_behavior) = REQUIRED]; + + // If greater than zero, only the first `limit` rows are yielded. If `limit` + // is zero, the default is no limit. A limit cannot be specified if + // `partition_token` is set. + int64 limit = 8; + + // If this request is resuming a previously interrupted read, + // `resume_token` should be copied from the last + // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the interruption. Doing this + // enables the new read to resume where the last read left off. The + // rest of the request parameters must exactly match the request + // that yielded this token. + bytes resume_token = 9; + + // If present, results will be restricted to the specified partition + // previously created using PartitionRead(). There must be an exact + // match for the values of fields common to this message and the + // PartitionReadRequest message used to create this partition_token. + bytes partition_token = 10; + + // Common options for this request. + RequestOptions request_options = 11; + + // If this is for a partitioned query and this field is set to `true`, the + // request will be executed via Spanner independent compute resources. + // + // If the field is set to `true` but the request does not set + // `partition_token`, the API will return an `INVALID_ARGUMENT` error. + bool data_boost_enabled = 16; +} + +// The request for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction]. +message BeginTransactionRequest { + // Required. The session in which the transaction runs. + string session = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } + ]; + + // Required. Options for the new transaction. + TransactionOptions options = 2 [(google.api.field_behavior) = REQUIRED]; + + // Common options for this request. + // Priority is ignored for this request. Setting the priority in this + // request_options struct will not do anything. To set the priority for a + // transaction, set it on the reads and writes that are part of this + // transaction instead. + RequestOptions request_options = 3; +} + +// The request for [Commit][google.spanner.v1.Spanner.Commit]. +message CommitRequest { + // Required. The session in which the transaction to be committed is running. + string session = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } + ]; + + // Required. The transaction in which to commit. + oneof transaction { + // Commit a previously-started transaction. + bytes transaction_id = 2; + + // Execute mutations in a temporary transaction. Note that unlike + // commit of a previously-started transaction, commit with a + // temporary transaction is non-idempotent. That is, if the + // `CommitRequest` is sent to Cloud Spanner more than once (for + // instance, due to retries in the application, or in the + // transport library), it is possible that the mutations are + // executed more than once. If this is undesirable, use + // [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and + // [Commit][google.spanner.v1.Spanner.Commit] instead. + TransactionOptions single_use_transaction = 3; + } + + // The mutations to be executed when this transaction commits. All + // mutations are applied atomically, in the order they appear in + // this list. + repeated Mutation mutations = 4; + + // If `true`, then statistics related to the transaction will be included in + // the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats]. Default value is + // `false`. + bool return_commit_stats = 5; + + // Common options for this request. + RequestOptions request_options = 6; +} + +// The request for [Rollback][google.spanner.v1.Spanner.Rollback]. +message RollbackRequest { + // Required. The session in which the transaction to roll back is running. + string session = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } + ]; + + // Required. The transaction to roll back. + bytes transaction_id = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/transaction.proto b/owl-bot-staging/v1/protos/google/spanner/v1/transaction.proto new file mode 100644 index 000000000..49ab5cf52 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/spanner/v1/transaction.proto @@ -0,0 +1,525 @@ +// 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.spanner.v1; + +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; +option java_multiple_files = true; +option java_outer_classname = "TransactionProto"; +option java_package = "com.google.spanner.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\V1"; +option ruby_package = "Google::Cloud::Spanner::V1"; + +// Transactions: +// +// Each session can have at most one active transaction at a time (note that +// standalone reads and queries use a transaction internally and do count +// towards the one transaction limit). After the active transaction is +// completed, the session can immediately be re-used for the next transaction. +// It is not necessary to create a new session for each transaction. +// +// Transaction modes: +// +// Cloud Spanner supports three transaction modes: +// +// 1. Locking read-write. This type of transaction is the only way +// to write data into Cloud Spanner. These transactions rely on +// pessimistic locking and, if necessary, two-phase commit. +// Locking read-write transactions may abort, requiring the +// application to retry. +// +// 2. Snapshot read-only. Snapshot read-only transactions provide guaranteed +// consistency across several reads, but do not allow +// writes. Snapshot read-only transactions can be configured to read at +// timestamps in the past, or configured to perform a strong read +// (where Spanner will select a timestamp such that the read is +// guaranteed to see the effects of all transactions that have committed +// before the start of the read). Snapshot read-only transactions do not +// need to be committed. +// +// Queries on change streams must be performed with the snapshot read-only +// transaction mode, specifying a strong read. Please see +// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong] +// for more details. +// +// 3. Partitioned DML. This type of transaction is used to execute +// a single Partitioned DML statement. Partitioned DML partitions +// the key space and runs the DML statement over each partition +// in parallel using separate, internal transactions that commit +// independently. Partitioned DML transactions do not need to be +// committed. +// +// For transactions that only read, snapshot read-only transactions +// provide simpler semantics and are almost always faster. In +// particular, read-only transactions do not take locks, so they do +// not conflict with read-write transactions. As a consequence of not +// taking locks, they also do not abort, so retry loops are not needed. +// +// Transactions may only read-write data in a single database. They +// may, however, read-write data in different tables within that +// database. +// +// Locking read-write transactions: +// +// Locking transactions may be used to atomically read-modify-write +// data anywhere in a database. This type of transaction is externally +// consistent. +// +// Clients should attempt to minimize the amount of time a transaction +// is active. Faster transactions commit with higher probability +// and cause less contention. Cloud Spanner attempts to keep read locks +// active as long as the transaction continues to do reads, and the +// transaction has not been terminated by +// [Commit][google.spanner.v1.Spanner.Commit] or +// [Rollback][google.spanner.v1.Spanner.Rollback]. Long periods of +// inactivity at the client may cause Cloud Spanner to release a +// transaction's locks and abort it. +// +// Conceptually, a read-write transaction consists of zero or more +// reads or SQL statements followed by +// [Commit][google.spanner.v1.Spanner.Commit]. At any time before +// [Commit][google.spanner.v1.Spanner.Commit], the client can send a +// [Rollback][google.spanner.v1.Spanner.Rollback] request to abort the +// transaction. +// +// Semantics: +// +// Cloud Spanner can commit the transaction if all read locks it acquired +// are still valid at commit time, and it is able to acquire write +// locks for all writes. Cloud Spanner can abort the transaction for any +// reason. If a commit attempt returns `ABORTED`, Cloud Spanner guarantees +// that the transaction has not modified any user data in Cloud Spanner. +// +// Unless the transaction commits, Cloud Spanner makes no guarantees about +// how long the transaction's locks were held for. It is an error to +// use Cloud Spanner locks for any sort of mutual exclusion other than +// between Cloud Spanner transactions themselves. +// +// Retrying aborted transactions: +// +// When a transaction aborts, the application can choose to retry the +// whole transaction again. To maximize the chances of successfully +// committing the retry, the client should execute the retry in the +// same session as the original attempt. The original session's lock +// priority increases with each consecutive abort, meaning that each +// attempt has a slightly better chance of success than the previous. +// +// Under some circumstances (for example, many transactions attempting to +// modify the same row(s)), a transaction can abort many times in a +// short period before successfully committing. Thus, it is not a good +// idea to cap the number of retries a transaction can attempt; +// instead, it is better to limit the total amount of time spent +// retrying. +// +// Idle transactions: +// +// A transaction is considered idle if it has no outstanding reads or +// SQL queries and has not started a read or SQL query within the last 10 +// seconds. Idle transactions can be aborted by Cloud Spanner so that they +// don't hold on to locks indefinitely. If an idle transaction is aborted, the +// commit will fail with error `ABORTED`. +// +// If this behavior is undesirable, periodically executing a simple +// SQL query in the transaction (for example, `SELECT 1`) prevents the +// transaction from becoming idle. +// +// Snapshot read-only transactions: +// +// Snapshot read-only transactions provides a simpler method than +// locking read-write transactions for doing several consistent +// reads. However, this type of transaction does not support writes. +// +// Snapshot transactions do not take locks. Instead, they work by +// choosing a Cloud Spanner timestamp, then executing all reads at that +// timestamp. Since they do not acquire locks, they do not block +// concurrent read-write transactions. +// +// Unlike locking read-write transactions, snapshot read-only +// transactions never abort. They can fail if the chosen read +// timestamp is garbage collected; however, the default garbage +// collection policy is generous enough that most applications do not +// need to worry about this in practice. +// +// Snapshot read-only transactions do not need to call +// [Commit][google.spanner.v1.Spanner.Commit] or +// [Rollback][google.spanner.v1.Spanner.Rollback] (and in fact are not +// permitted to do so). +// +// To execute a snapshot transaction, the client specifies a timestamp +// bound, which tells Cloud Spanner how to choose a read timestamp. +// +// The types of timestamp bound are: +// +// - Strong (the default). +// - Bounded staleness. +// - Exact staleness. +// +// If the Cloud Spanner database to be read is geographically distributed, +// stale read-only transactions can execute more quickly than strong +// or read-write transactions, because they are able to execute far +// from the leader replica. +// +// Each type of timestamp bound is discussed in detail below. +// +// Strong: Strong reads are guaranteed to see the effects of all transactions +// that have committed before the start of the read. Furthermore, all +// rows yielded by a single read are consistent with each other -- if +// any part of the read observes a transaction, all parts of the read +// see the transaction. +// +// Strong reads are not repeatable: two consecutive strong read-only +// transactions might return inconsistent results if there are +// concurrent writes. If consistency across reads is required, the +// reads should be executed within a transaction or at an exact read +// timestamp. +// +// Queries on change streams (see below for more details) must also specify +// the strong read timestamp bound. +// +// See +// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong]. +// +// Exact staleness: +// +// These timestamp bounds execute reads at a user-specified +// timestamp. Reads at a timestamp are guaranteed to see a consistent +// prefix of the global transaction history: they observe +// modifications done by all transactions with a commit timestamp less than or +// equal to the read timestamp, and observe none of the modifications done by +// transactions with a larger commit timestamp. They will block until +// all conflicting transactions that may be assigned commit timestamps +// <= the read timestamp have finished. +// +// The timestamp can either be expressed as an absolute Cloud Spanner commit +// timestamp or a staleness relative to the current time. +// +// These modes do not require a "negotiation phase" to pick a +// timestamp. As a result, they execute slightly faster than the +// equivalent boundedly stale concurrency modes. On the other hand, +// boundedly stale reads usually return fresher results. +// +// See +// [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp] +// and +// [TransactionOptions.ReadOnly.exact_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact_staleness]. +// +// Bounded staleness: +// +// Bounded staleness modes allow Cloud Spanner to pick the read timestamp, +// subject to a user-provided staleness bound. Cloud Spanner chooses the +// newest timestamp within the staleness bound that allows execution +// of the reads at the closest available replica without blocking. +// +// All rows yielded are consistent with each other -- if any part of +// the read observes a transaction, all parts of the read see the +// transaction. Boundedly stale reads are not repeatable: two stale +// reads, even if they use the same staleness bound, can execute at +// different timestamps and thus return inconsistent results. +// +// Boundedly stale reads execute in two phases: the first phase +// negotiates a timestamp among all replicas needed to serve the +// read. In the second phase, reads are executed at the negotiated +// timestamp. +// +// As a result of the two phase execution, bounded staleness reads are +// usually a little slower than comparable exact staleness +// reads. However, they are typically able to return fresher +// results, and are more likely to execute at the closest replica. +// +// Because the timestamp negotiation requires up-front knowledge of +// which rows will be read, it can only be used with single-use +// read-only transactions. +// +// See +// [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness] +// and +// [TransactionOptions.ReadOnly.min_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min_read_timestamp]. +// +// Old read timestamps and garbage collection: +// +// Cloud Spanner continuously garbage collects deleted and overwritten data +// in the background to reclaim storage space. This process is known +// as "version GC". By default, version GC reclaims versions after they +// are one hour old. Because of this, Cloud Spanner cannot perform reads +// at read timestamps more than one hour in the past. This +// restriction also applies to in-progress reads and/or SQL queries whose +// timestamp become too old while executing. Reads and SQL queries with +// too-old read timestamps fail with the error `FAILED_PRECONDITION`. +// +// You can configure and extend the `VERSION_RETENTION_PERIOD` of a +// database up to a period as long as one week, which allows Cloud Spanner +// to perform reads up to one week in the past. +// +// Querying change Streams: +// +// A Change Stream is a schema object that can be configured to watch data +// changes on the entire database, a set of tables, or a set of columns +// in a database. +// +// When a change stream is created, Spanner automatically defines a +// corresponding SQL Table-Valued Function (TVF) that can be used to query +// the change records in the associated change stream using the +// ExecuteStreamingSql API. The name of the TVF for a change stream is +// generated from the name of the change stream: READ_. +// +// All queries on change stream TVFs must be executed using the +// ExecuteStreamingSql API with a single-use read-only transaction with a +// strong read-only timestamp_bound. The change stream TVF allows users to +// specify the start_timestamp and end_timestamp for the time range of +// interest. All change records within the retention period is accessible +// using the strong read-only timestamp_bound. All other TransactionOptions +// are invalid for change stream queries. +// +// In addition, if TransactionOptions.read_only.return_read_timestamp is set +// to true, a special value of 2^63 - 2 will be returned in the +// [Transaction][google.spanner.v1.Transaction] message that describes the +// transaction, instead of a valid read timestamp. This special value should be +// discarded and not used for any subsequent queries. +// +// Please see https://cloud.google.com/spanner/docs/change-streams +// for more details on how to query the change stream TVFs. +// +// Partitioned DML transactions: +// +// Partitioned DML transactions are used to execute DML statements with a +// different execution strategy that provides different, and often better, +// scalability properties for large, table-wide operations than DML in a +// ReadWrite transaction. Smaller scoped statements, such as an OLTP workload, +// should prefer using ReadWrite transactions. +// +// Partitioned DML partitions the keyspace and runs the DML statement on each +// partition in separate, internal transactions. These transactions commit +// automatically when complete, and run independently from one another. +// +// To reduce lock contention, this execution strategy only acquires read locks +// on rows that match the WHERE clause of the statement. Additionally, the +// smaller per-partition transactions hold locks for less time. +// +// That said, Partitioned DML is not a drop-in replacement for standard DML used +// in ReadWrite transactions. +// +// - The DML statement must be fully-partitionable. Specifically, the statement +// must be expressible as the union of many statements which each access only +// a single row of the table. +// +// - The statement is not applied atomically to all rows of the table. Rather, +// the statement is applied atomically to partitions of the table, in +// independent transactions. Secondary index rows are updated atomically +// with the base table rows. +// +// - Partitioned DML does not guarantee exactly-once execution semantics +// against a partition. The statement will be applied at least once to each +// partition. It is strongly recommended that the DML statement should be +// idempotent to avoid unexpected results. For instance, it is potentially +// dangerous to run a statement such as +// `UPDATE table SET column = column + 1` as it could be run multiple times +// against some rows. +// +// - The partitions are committed automatically - there is no support for +// Commit or Rollback. If the call returns an error, or if the client issuing +// the ExecuteSql call dies, it is possible that some rows had the statement +// executed on them successfully. It is also possible that statement was +// never executed against other rows. +// +// - Partitioned DML transactions may only contain the execution of a single +// DML statement via ExecuteSql or ExecuteStreamingSql. +// +// - If any error is encountered during the execution of the partitioned DML +// operation (for instance, a UNIQUE INDEX violation, division by zero, or a +// value that cannot be stored due to schema constraints), then the +// operation is stopped at that point and an error is returned. It is +// possible that at this point, some partitions have been committed (or even +// committed multiple times), and other partitions have not been run at all. +// +// Given the above, Partitioned DML is good fit for large, database-wide, +// operations that are idempotent, such as deleting old rows from a very large +// table. +message TransactionOptions { + // Message type to initiate a read-write transaction. Currently this + // transaction type has no options. + message ReadWrite { + // `ReadLockMode` is used to set the read lock mode for read-write + // transactions. + enum ReadLockMode { + // Default value. + // + // If the value is not specified, the pessimistic read lock is used. + READ_LOCK_MODE_UNSPECIFIED = 0; + + // Pessimistic lock mode. + // + // Read locks are acquired immediately on read. + PESSIMISTIC = 1; + + // Optimistic lock mode. + // + // Locks for reads within the transaction are not acquired on read. + // Instead the locks are acquired on a commit to validate that + // read/queried data has not changed since the transaction started. + OPTIMISTIC = 2; + } + + // Read lock mode for the transaction. + ReadLockMode read_lock_mode = 1; + } + + // Message type to initiate a Partitioned DML transaction. + message PartitionedDml {} + + // Message type to initiate a read-only transaction. + message ReadOnly { + // How to choose the timestamp for the read-only transaction. + oneof timestamp_bound { + // Read at a timestamp where all previously committed transactions + // are visible. + bool strong = 1; + + // Executes all reads at a timestamp >= `min_read_timestamp`. + // + // This is useful for requesting fresher data than some previous + // read, or data that is fresh enough to observe the effects of some + // previously committed transaction whose timestamp is known. + // + // Note that this option can only be used in single-use transactions. + // + // A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + // Example: `"2014-10-02T15:01:23.045123456Z"`. + google.protobuf.Timestamp min_read_timestamp = 2; + + // Read data at a timestamp >= `NOW - max_staleness` + // seconds. Guarantees that all writes that have committed more + // than the specified number of seconds ago are visible. Because + // Cloud Spanner chooses the exact timestamp, this mode works even if + // the client's local clock is substantially skewed from Cloud Spanner + // commit timestamps. + // + // Useful for reading the freshest data available at a nearby + // replica, while bounding the possible staleness if the local + // replica has fallen behind. + // + // Note that this option can only be used in single-use + // transactions. + google.protobuf.Duration max_staleness = 3; + + // Executes all reads at the given timestamp. Unlike other modes, + // reads at a specific timestamp are repeatable; the same read at + // the same timestamp always returns the same data. If the + // timestamp is in the future, the read will block until the + // specified timestamp, modulo the read's deadline. + // + // Useful for large scale consistent reads such as mapreduces, or + // for coordinating many reads against a consistent snapshot of the + // data. + // + // A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + // Example: `"2014-10-02T15:01:23.045123456Z"`. + google.protobuf.Timestamp read_timestamp = 4; + + // Executes all reads at a timestamp that is `exact_staleness` + // old. The timestamp is chosen soon after the read is started. + // + // Guarantees that all writes that have committed more than the + // specified number of seconds ago are visible. Because Cloud Spanner + // chooses the exact timestamp, this mode works even if the client's + // local clock is substantially skewed from Cloud Spanner commit + // timestamps. + // + // Useful for reading at nearby replicas without the distributed + // timestamp negotiation overhead of `max_staleness`. + google.protobuf.Duration exact_staleness = 5; + } + + // If true, the Cloud Spanner-selected read timestamp is included in + // the [Transaction][google.spanner.v1.Transaction] message that describes + // the transaction. + bool return_read_timestamp = 6; + } + + // Required. The type of transaction. + oneof mode { + // Transaction may write. + // + // Authorization to begin a read-write transaction requires + // `spanner.databases.beginOrRollbackReadWriteTransaction` permission + // on the `session` resource. + ReadWrite read_write = 1; + + // Partitioned DML transaction. + // + // Authorization to begin a Partitioned DML transaction requires + // `spanner.databases.beginPartitionedDmlTransaction` permission + // on the `session` resource. + PartitionedDml partitioned_dml = 3; + + // Transaction will not write. + // + // Authorization to begin a read-only transaction requires + // `spanner.databases.beginReadOnlyTransaction` permission + // on the `session` resource. + ReadOnly read_only = 2; + } +} + +// A transaction. +message Transaction { + // `id` may be used to identify the transaction in subsequent + // [Read][google.spanner.v1.Spanner.Read], + // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], + // [Commit][google.spanner.v1.Spanner.Commit], or + // [Rollback][google.spanner.v1.Spanner.Rollback] calls. + // + // Single-use read-only transactions do not have IDs, because + // single-use transactions do not support multiple requests. + bytes id = 1; + + // For snapshot read-only transactions, the read timestamp chosen + // for the transaction. Not returned by default: see + // [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp]. + // + // A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. + // Example: `"2014-10-02T15:01:23.045123456Z"`. + google.protobuf.Timestamp read_timestamp = 2; +} + +// This message is used to select the transaction in which a +// [Read][google.spanner.v1.Spanner.Read] or +// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs. +// +// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more +// information about transactions. +message TransactionSelector { + // If no fields are set, the default is a single use transaction + // with strong concurrency. + oneof selector { + // Execute the read or SQL query in a temporary transaction. + // This is the most efficient way to execute a transaction that + // consists of a single SQL query. + TransactionOptions single_use = 1; + + // Execute the read or SQL query in a previously-started transaction. + bytes id = 2; + + // Begin a new transaction and execute this read or SQL query in + // it. The transaction ID of the new transaction is returned in + // [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction], + // which is a [Transaction][google.spanner.v1.Transaction]. + TransactionOptions begin = 3; + } +} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/type.proto b/owl-bot-staging/v1/protos/google/spanner/v1/type.proto new file mode 100644 index 000000000..712ec187f --- /dev/null +++ b/owl-bot-staging/v1/protos/google/spanner/v1/type.proto @@ -0,0 +1,174 @@ +// 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.spanner.v1; + +import "google/api/field_behavior.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; +option java_multiple_files = true; +option java_outer_classname = "TypeProto"; +option java_package = "com.google.spanner.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\V1"; +option ruby_package = "Google::Cloud::Spanner::V1"; + +// `Type` indicates the type of a Cloud Spanner value, as might be stored in a +// table cell or returned from an SQL query. +message Type { + // Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. + TypeCode code = 1 [(google.api.field_behavior) = REQUIRED]; + + // If [code][google.spanner.v1.Type.code] == [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` + // is the type of the array elements. + Type array_element_type = 2; + + // If [code][google.spanner.v1.Type.code] == [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` + // provides type information for the struct's fields. + StructType struct_type = 3; + + // The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that disambiguates SQL type that Spanner will + // use to represent values of this type during query processing. This is + // necessary for some type codes because a single [TypeCode][google.spanner.v1.TypeCode] can be mapped + // to different SQL types depending on the SQL dialect. [type_annotation][google.spanner.v1.Type.type_annotation] + // typically is not needed to process the content of a value (it doesn't + // affect serialization) and clients can ignore it on the read path. + TypeAnnotationCode type_annotation = 4; +} + +// `StructType` defines the fields of a [STRUCT][google.spanner.v1.TypeCode.STRUCT] type. +message StructType { + // Message representing a single field of a struct. + message Field { + // The name of the field. For reads, this is the column name. For + // SQL queries, it is the column alias (e.g., `"Word"` in the + // query `"SELECT 'hello' AS Word"`), or the column name (e.g., + // `"ColName"` in the query `"SELECT ColName FROM Table"`). Some + // columns might have an empty name (e.g., `"SELECT + // UPPER(ColName)"`). Note that a query result can contain + // multiple fields with the same name. + string name = 1; + + // The type of the field. + Type type = 2; + } + + // The list of fields that make up this struct. Order is + // significant, because values of this struct type are represented as + // lists, where the order of field values matches the order of + // fields in the [StructType][google.spanner.v1.StructType]. In turn, the order of fields + // matches the order of columns in a read request, or the order of + // fields in the `SELECT` clause of a query. + repeated Field fields = 1; +} + +// `TypeCode` is used as part of [Type][google.spanner.v1.Type] to +// indicate the type of a Cloud Spanner value. +// +// Each legal value of a type can be encoded to or decoded from a JSON +// value, using the encodings described below. All Cloud Spanner values can +// be `null`, regardless of type; `null`s are always encoded as a JSON +// `null`. +enum TypeCode { + // Not specified. + TYPE_CODE_UNSPECIFIED = 0; + + // Encoded as JSON `true` or `false`. + BOOL = 1; + + // Encoded as `string`, in decimal format. + INT64 = 2; + + // Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or + // `"-Infinity"`. + FLOAT64 = 3; + + // Encoded as `string` in RFC 3339 timestamp format. The time zone + // must be present, and must be `"Z"`. + // + // If the schema has the column option + // `allow_commit_timestamp=true`, the placeholder string + // `"spanner.commit_timestamp()"` can be used to instruct the system + // to insert the commit timestamp associated with the transaction + // commit. + TIMESTAMP = 4; + + // Encoded as `string` in RFC 3339 date format. + DATE = 5; + + // Encoded as `string`. + STRING = 6; + + // Encoded as a base64-encoded `string`, as described in RFC 4648, + // section 4. + BYTES = 7; + + // Encoded as `list`, where the list elements are represented + // according to + // [array_element_type][google.spanner.v1.Type.array_element_type]. + ARRAY = 8; + + // Encoded as `list`, where list element `i` is represented according + // to [struct_type.fields[i]][google.spanner.v1.StructType.fields]. + STRUCT = 9; + + // Encoded as `string`, in decimal format or scientific notation format. + //
Decimal format: + //
`[+-]Digits[.[Digits]]` or + //
`[+-][Digits].Digits` + // + // Scientific notation: + //
`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or + //
`[+-][Digits].Digits[ExponentIndicator[+-]Digits]` + //
(ExponentIndicator is `"e"` or `"E"`) + NUMERIC = 10; + + // Encoded as a JSON-formatted `string` as described in RFC 7159. The + // following rules are applied when parsing JSON input: + // + // - Whitespace characters are not preserved. + // - If a JSON object has duplicate keys, only the first key is preserved. + // - Members of a JSON object are not guaranteed to have their order + // preserved. + // - JSON array elements will have their order preserved. + JSON = 11; +} + +// `TypeAnnotationCode` is used as a part of [Type][google.spanner.v1.Type] to +// disambiguate SQL types that should be used for a given Cloud Spanner value. +// Disambiguation is needed because the same Cloud Spanner type can be mapped to +// different SQL types depending on SQL dialect. TypeAnnotationCode doesn't +// affect the way value is serialized. +enum TypeAnnotationCode { + // Not specified. + TYPE_ANNOTATION_CODE_UNSPECIFIED = 0; + + // PostgreSQL compatible NUMERIC type. This annotation needs to be applied to + // [Type][google.spanner.v1.Type] instances having [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] + // type code to specify that values of this type should be treated as + // PostgreSQL NUMERIC values. Currently this annotation is always needed for + // [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] when a client interacts with PostgreSQL-enabled + // Spanner databases. + PG_NUMERIC = 2; + + // PostgreSQL compatible JSONB type. This annotation needs to be applied to + // [Type][google.spanner.v1.Type] instances having [JSON][google.spanner.v1.TypeCode.JSON] + // type code to specify that values of this type should be treated as + // PostgreSQL JSONB values. Currently this annotation is always needed for + // [JSON][google.spanner.v1.TypeCode.JSON] when a client interacts with PostgreSQL-enabled + // Spanner databases. + PG_JSONB = 3; +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 000000000..65a2f00e9 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const SpannerClient = v1.SpannerClient; +type SpannerClient = v1.SpannerClient; +export {v1, SpannerClient}; +export default {v1, SpannerClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 000000000..e10e70ad5 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,167 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.spanner.v1", + "libraryPackage": "@google-cloud/spanner", + "services": { + "Spanner": { + "clients": { + "grpc": { + "libraryClient": "SpannerClient", + "rpcs": { + "CreateSession": { + "methods": [ + "createSession" + ] + }, + "BatchCreateSessions": { + "methods": [ + "batchCreateSessions" + ] + }, + "GetSession": { + "methods": [ + "getSession" + ] + }, + "DeleteSession": { + "methods": [ + "deleteSession" + ] + }, + "ExecuteSql": { + "methods": [ + "executeSql" + ] + }, + "ExecuteBatchDml": { + "methods": [ + "executeBatchDml" + ] + }, + "Read": { + "methods": [ + "read" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "PartitionQuery": { + "methods": [ + "partitionQuery" + ] + }, + "PartitionRead": { + "methods": [ + "partitionRead" + ] + }, + "ExecuteStreamingSql": { + "methods": [ + "executeStreamingSql" + ] + }, + "StreamingRead": { + "methods": [ + "streamingRead" + ] + }, + "ListSessions": { + "methods": [ + "listSessions", + "listSessionsStream", + "listSessionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SpannerClient", + "rpcs": { + "CreateSession": { + "methods": [ + "createSession" + ] + }, + "BatchCreateSessions": { + "methods": [ + "batchCreateSessions" + ] + }, + "GetSession": { + "methods": [ + "getSession" + ] + }, + "DeleteSession": { + "methods": [ + "deleteSession" + ] + }, + "ExecuteSql": { + "methods": [ + "executeSql" + ] + }, + "ExecuteBatchDml": { + "methods": [ + "executeBatchDml" + ] + }, + "Read": { + "methods": [ + "read" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "PartitionQuery": { + "methods": [ + "partitionQuery" + ] + }, + "PartitionRead": { + "methods": [ + "partitionRead" + ] + }, + "ListSessions": { + "methods": [ + "listSessions", + "listSessionsStream", + "listSessionsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 000000000..680a3e1f4 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 {SpannerClient} from './spanner_client'; diff --git a/owl-bot-staging/v1/src/v1/spanner_client.ts b/owl-bot-staging/v1/src/v1/spanner_client.ts new file mode 100644 index 000000000..871ae0d5d --- /dev/null +++ b/owl-bot-staging/v1/src/v1/spanner_client.ts @@ -0,0 +1,2047 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform, PassThrough} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/spanner_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './spanner_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Cloud Spanner API + * + * The Cloud Spanner API can be used to manage sessions and execute + * transactions on data stored in Cloud Spanner databases. + * @class + * @memberof v1 + */ +export class SpannerClient { + 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}; + spannerStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SpannerClient. + * + * @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 SpannerClient({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 SpannerClient; + 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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 = { + databasePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instances/{instance}/databases/{database}' + ), + sessionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/instances/{instance}/databases/{database}/sessions/{session}' + ), + }; + + // 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 = { + listSessions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'sessions') + }; + + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this.descriptors.stream = { + executeStreamingSql: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), + streamingRead: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.spanner.v1.Spanner', 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.spannerStub) { + return this.spannerStub; + } + + // Put together the "service stub" for + // google.spanner.v1.Spanner. + this.spannerStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.spanner.v1.Spanner') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.spanner.v1.Spanner, + 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 spannerStubMethods = + ['createSession', 'batchCreateSessions', 'getSession', 'listSessions', 'deleteSession', 'executeSql', 'executeStreamingSql', 'executeBatchDml', 'read', 'streamingRead', 'beginTransaction', 'commit', 'rollback', 'partitionQuery', 'partitionRead']; + for (const methodName of spannerStubMethods) { + const callPromise = this.spannerStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + if (methodName in this.descriptors.stream) { + const stream = new PassThrough(); + setImmediate(() => { + stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.')); + }); + return stream; + } + 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.stream[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.spannerStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'spanner.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 'spanner.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', + 'https://www.googleapis.com/auth/spanner.data' + ]; + } + + 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 -- + // ------------------- +/** + * Creates a new session. A session can be used to perform + * transactions that read and/or modify data in a Cloud Spanner database. + * Sessions are meant to be reused for many consecutive + * transactions. + * + * Sessions can only execute one transaction at a time. To execute + * multiple concurrent read-write/write-only transactions, create + * multiple sessions. Note that standalone reads and queries use a + * transaction internally, and count toward the one transaction + * limit. + * + * Active sessions use additional server resources, so it is a good idea to + * delete idle and unneeded sessions. + * Aside from explicit deletes, Cloud Spanner may delete sessions for which no + * operations are sent for more than an hour. If a session is deleted, + * requests to it return `NOT_FOUND`. + * + * Idle sessions can be kept alive by sending a trivial SQL query + * periodically, e.g., `"SELECT 1"`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database in which the new session is created. + * @param {google.spanner.v1.Session} request.session + * Required. The session to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.spanner.v1.Session | Session}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + createSession( + request?: protos.google.spanner.v1.ICreateSessionRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.ICreateSessionRequest|undefined, {}|undefined + ]>; + createSession( + request: protos.google.spanner.v1.ICreateSessionRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.ICreateSessionRequest|null|undefined, + {}|null|undefined>): void; + createSession( + request: protos.google.spanner.v1.ICreateSessionRequest, + callback: Callback< + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.ICreateSessionRequest|null|undefined, + {}|null|undefined>): void; + createSession( + request?: protos.google.spanner.v1.ICreateSessionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.ICreateSessionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.ICreateSessionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.ICreateSessionRequest|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({ + 'database': request.database ?? '', + }); + this.initialize(); + return this.innerApiCalls.createSession(request, options, callback); + } +/** + * Creates multiple new sessions. + * + * This API can be used to initialize a session cache on the clients. + * See https://goo.gl/TgSFN2 for best practices on session cache management. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database in which the new sessions are created. + * @param {google.spanner.v1.Session} request.sessionTemplate + * Parameters to be applied to each created session. + * @param {number} request.sessionCount + * Required. The number of sessions to be created in this batch call. + * The API may return fewer than the requested number of sessions. If a + * specific number of sessions are desired, the client can make additional + * calls to BatchCreateSessions (adjusting + * {@link google.spanner.v1.BatchCreateSessionsRequest.session_count|session_count} as necessary). + * @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 {@link google.spanner.v1.BatchCreateSessionsResponse | BatchCreateSessionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + batchCreateSessions( + request?: protos.google.spanner.v1.IBatchCreateSessionsRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.IBatchCreateSessionsResponse, + protos.google.spanner.v1.IBatchCreateSessionsRequest|undefined, {}|undefined + ]>; + batchCreateSessions( + request: protos.google.spanner.v1.IBatchCreateSessionsRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.v1.IBatchCreateSessionsResponse, + protos.google.spanner.v1.IBatchCreateSessionsRequest|null|undefined, + {}|null|undefined>): void; + batchCreateSessions( + request: protos.google.spanner.v1.IBatchCreateSessionsRequest, + callback: Callback< + protos.google.spanner.v1.IBatchCreateSessionsResponse, + protos.google.spanner.v1.IBatchCreateSessionsRequest|null|undefined, + {}|null|undefined>): void; + batchCreateSessions( + request?: protos.google.spanner.v1.IBatchCreateSessionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.v1.IBatchCreateSessionsResponse, + protos.google.spanner.v1.IBatchCreateSessionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.v1.IBatchCreateSessionsResponse, + protos.google.spanner.v1.IBatchCreateSessionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.v1.IBatchCreateSessionsResponse, + protos.google.spanner.v1.IBatchCreateSessionsRequest|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({ + 'database': request.database ?? '', + }); + this.initialize(); + return this.innerApiCalls.batchCreateSessions(request, options, callback); + } +/** + * Gets a session. Returns `NOT_FOUND` if the session does not exist. + * This is mainly useful for determining whether a session is still + * alive. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the session to retrieve. + * @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 {@link google.spanner.v1.Session | Session}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + getSession( + request?: protos.google.spanner.v1.IGetSessionRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.IGetSessionRequest|undefined, {}|undefined + ]>; + getSession( + request: protos.google.spanner.v1.IGetSessionRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.IGetSessionRequest|null|undefined, + {}|null|undefined>): void; + getSession( + request: protos.google.spanner.v1.IGetSessionRequest, + callback: Callback< + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.IGetSessionRequest|null|undefined, + {}|null|undefined>): void; + getSession( + request?: protos.google.spanner.v1.IGetSessionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.IGetSessionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.IGetSessionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.v1.ISession, + protos.google.spanner.v1.IGetSessionRequest|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({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getSession(request, options, callback); + } +/** + * Ends a session, releasing server resources associated with it. This will + * asynchronously trigger cancellation of any operations that are running with + * this session. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the session to delete. + * @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 {@link google.protobuf.Empty | Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + deleteSession( + request?: protos.google.spanner.v1.IDeleteSessionRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IDeleteSessionRequest|undefined, {}|undefined + ]>; + deleteSession( + request: protos.google.spanner.v1.IDeleteSessionRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>): void; + deleteSession( + request: protos.google.spanner.v1.IDeleteSessionRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>): void; + deleteSession( + request?: protos.google.spanner.v1.IDeleteSessionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IDeleteSessionRequest|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({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteSession(request, options, callback); + } +/** + * Executes an SQL statement, returning all results in a single reply. This + * method cannot be used to return a result set larger than 10 MiB; + * if the query yields more data than that, the query fails with + * a `FAILED_PRECONDITION` error. + * + * Operations inside read-write transactions might return `ABORTED`. If + * this occurs, the application should restart the transaction from + * the beginning. See {@link google.spanner.v1.Transaction|Transaction} for more details. + * + * Larger result sets can be fetched in streaming fashion by calling + * {@link google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.session + * Required. The session in which the SQL query should be performed. + * @param {google.spanner.v1.TransactionSelector} request.transaction + * The transaction to use. + * + * For queries, if none is provided, the default is a temporary read-only + * transaction with strong concurrency. + * + * Standard DML statements require a read-write transaction. To protect + * against replays, single-use transactions are not supported. The caller + * must either supply an existing transaction ID or begin a new transaction. + * + * Partitioned DML requires an existing Partitioned DML transaction ID. + * @param {string} request.sql + * Required. The SQL string. + * @param {google.protobuf.Struct} request.params + * Parameter names and values that bind to placeholders in the SQL string. + * + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names must conform + * to the naming requirements of identifiers as specified at + * https://cloud.google.com/spanner/docs/lexical#identifiers. + * + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * + * It is an error to execute a SQL statement with unbound parameters. + * @param {number[]} request.paramTypes + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in {@link google.spanner.v1.ExecuteSqlRequest.params|params} as JSON strings. + * + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of {@link google.spanner.v1.Type|Type} for more information + * about SQL types. + * @param {Buffer} request.resumeToken + * If this request is resuming a previously interrupted SQL statement + * execution, `resume_token` should be copied from the last + * {@link google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the interruption. Doing this + * enables the new SQL statement execution to resume where the last one left + * off. The rest of the request parameters must exactly match the + * request that yielded this token. + * @param {google.spanner.v1.ExecuteSqlRequest.QueryMode} request.queryMode + * Used to control the amount of debugging information returned in + * {@link google.spanner.v1.ResultSetStats|ResultSetStats}. If {@link google.spanner.v1.ExecuteSqlRequest.partition_token|partition_token} is set, {@link google.spanner.v1.ExecuteSqlRequest.query_mode|query_mode} can only + * be set to {@link google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL|QueryMode.NORMAL}. + * @param {Buffer} request.partitionToken + * If present, results will be restricted to the specified partition + * previously created using PartitionQuery(). There must be an exact + * match for the values of fields common to this message and the + * PartitionQueryRequest message used to create this partition_token. + * @param {number} request.seqno + * A per-transaction sequence number used to identify this request. This field + * makes each request idempotent such that if the request is received multiple + * times, at most one will succeed. + * + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * + * Required for DML statements. Ignored for queries. + * @param {google.spanner.v1.ExecuteSqlRequest.QueryOptions} request.queryOptions + * Query optimizer configuration to use for the given query. + * @param {google.spanner.v1.RequestOptions} request.requestOptions + * Common options for this request. + * @param {boolean} request.dataBoostEnabled + * If this is for a partitioned read and this field is set to `true`, the + * request will be executed via Spanner independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API will return an `INVALID_ARGUMENT` error. + * @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 {@link google.spanner.v1.ResultSet | ResultSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + executeSql( + request?: protos.google.spanner.v1.IExecuteSqlRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IExecuteSqlRequest|undefined, {}|undefined + ]>; + executeSql( + request: protos.google.spanner.v1.IExecuteSqlRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IExecuteSqlRequest|null|undefined, + {}|null|undefined>): void; + executeSql( + request: protos.google.spanner.v1.IExecuteSqlRequest, + callback: Callback< + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IExecuteSqlRequest|null|undefined, + {}|null|undefined>): void; + executeSql( + request?: protos.google.spanner.v1.IExecuteSqlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IExecuteSqlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IExecuteSqlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IExecuteSqlRequest|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({ + 'session': request.session ?? '', + }); + this.initialize(); + return this.innerApiCalls.executeSql(request, options, callback); + } +/** + * Executes a batch of SQL DML statements. This method allows many statements + * to be run with lower latency than submitting them sequentially with + * {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}. + * + * Statements are executed in sequential order. A request can succeed even if + * a statement fails. The {@link google.spanner.v1.ExecuteBatchDmlResponse.status|ExecuteBatchDmlResponse.status} field in the + * response provides information about the statement that failed. Clients must + * inspect this field to determine whether an error occurred. + * + * Execution stops after the first failed statement; the remaining statements + * are not executed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.session + * Required. The session in which the DML statements should be performed. + * @param {google.spanner.v1.TransactionSelector} request.transaction + * Required. The transaction to use. Must be a read-write transaction. + * + * To protect against replays, single-use transactions are not supported. The + * caller must either supply an existing transaction ID or begin a new + * transaction. + * @param {number[]} request.statements + * Required. The list of statements to execute in this batch. Statements are executed + * serially, such that the effects of statement `i` are visible to statement + * `i+1`. Each statement must be a DML statement. Execution stops at the + * first failed statement; the remaining statements are not executed. + * + * Callers must provide at least one statement. + * @param {number} request.seqno + * Required. A per-transaction sequence number used to identify this request. This field + * makes each request idempotent such that if the request is received multiple + * times, at most one will succeed. + * + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * @param {google.spanner.v1.RequestOptions} request.requestOptions + * Common options for this request. + * @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 {@link google.spanner.v1.ExecuteBatchDmlResponse | ExecuteBatchDmlResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + executeBatchDml( + request?: protos.google.spanner.v1.IExecuteBatchDmlRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.IExecuteBatchDmlResponse, + protos.google.spanner.v1.IExecuteBatchDmlRequest|undefined, {}|undefined + ]>; + executeBatchDml( + request: protos.google.spanner.v1.IExecuteBatchDmlRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.v1.IExecuteBatchDmlResponse, + protos.google.spanner.v1.IExecuteBatchDmlRequest|null|undefined, + {}|null|undefined>): void; + executeBatchDml( + request: protos.google.spanner.v1.IExecuteBatchDmlRequest, + callback: Callback< + protos.google.spanner.v1.IExecuteBatchDmlResponse, + protos.google.spanner.v1.IExecuteBatchDmlRequest|null|undefined, + {}|null|undefined>): void; + executeBatchDml( + request?: protos.google.spanner.v1.IExecuteBatchDmlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.v1.IExecuteBatchDmlResponse, + protos.google.spanner.v1.IExecuteBatchDmlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.v1.IExecuteBatchDmlResponse, + protos.google.spanner.v1.IExecuteBatchDmlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.v1.IExecuteBatchDmlResponse, + protos.google.spanner.v1.IExecuteBatchDmlRequest|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({ + 'session': request.session ?? '', + }); + this.initialize(); + return this.innerApiCalls.executeBatchDml(request, options, callback); + } +/** + * Reads rows from the database using key lookups and scans, as a + * simple key/value style alternative to + * {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}. This method cannot be used to + * return a result set larger than 10 MiB; if the read matches more + * data than that, the read fails with a `FAILED_PRECONDITION` + * error. + * + * Reads inside read-write transactions might return `ABORTED`. If + * this occurs, the application should restart the transaction from + * the beginning. See {@link google.spanner.v1.Transaction|Transaction} for more details. + * + * Larger result sets can be yielded in streaming fashion by calling + * {@link google.spanner.v1.Spanner.StreamingRead|StreamingRead} instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.session + * Required. The session in which the read should be performed. + * @param {google.spanner.v1.TransactionSelector} request.transaction + * The transaction to use. If none is provided, the default is a + * temporary read-only transaction with strong concurrency. + * @param {string} request.table + * Required. The name of the table in the database to be read. + * @param {string} request.index + * If non-empty, the name of an index on {@link google.spanner.v1.ReadRequest.table|table}. This index is + * used instead of the table primary key when interpreting {@link google.spanner.v1.ReadRequest.key_set|key_set} + * and sorting result rows. See {@link google.spanner.v1.ReadRequest.key_set|key_set} for further information. + * @param {string[]} request.columns + * Required. The columns of {@link google.spanner.v1.ReadRequest.table|table} to be returned for each row matching + * this request. + * @param {google.spanner.v1.KeySet} request.keySet + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in {@link google.spanner.v1.ReadRequest.table|table} to be yielded, unless {@link google.spanner.v1.ReadRequest.index|index} + * is present. If {@link google.spanner.v1.ReadRequest.index|index} is present, then {@link google.spanner.v1.ReadRequest.key_set|key_set} instead names + * index keys in {@link google.spanner.v1.ReadRequest.index|index}. + * + * If the {@link google.spanner.v1.ReadRequest.partition_token|partition_token} field is empty, rows are yielded + * in table primary key order (if {@link google.spanner.v1.ReadRequest.index|index} is empty) or index key order + * (if {@link google.spanner.v1.ReadRequest.index|index} is non-empty). If the {@link google.spanner.v1.ReadRequest.partition_token|partition_token} field is not + * empty, rows will be yielded in an unspecified order. + * + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * @param {number} request.limit + * If greater than zero, only the first `limit` rows are yielded. If `limit` + * is zero, the default is no limit. A limit cannot be specified if + * `partition_token` is set. + * @param {Buffer} request.resumeToken + * If this request is resuming a previously interrupted read, + * `resume_token` should be copied from the last + * {@link google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the interruption. Doing this + * enables the new read to resume where the last read left off. The + * rest of the request parameters must exactly match the request + * that yielded this token. + * @param {Buffer} request.partitionToken + * If present, results will be restricted to the specified partition + * previously created using PartitionRead(). There must be an exact + * match for the values of fields common to this message and the + * PartitionReadRequest message used to create this partition_token. + * @param {google.spanner.v1.RequestOptions} request.requestOptions + * Common options for this request. + * @param {boolean} request.dataBoostEnabled + * If this is for a partitioned query and this field is set to `true`, the + * request will be executed via Spanner independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API will return an `INVALID_ARGUMENT` error. + * @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 {@link google.spanner.v1.ResultSet | ResultSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + read( + request?: protos.google.spanner.v1.IReadRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IReadRequest|undefined, {}|undefined + ]>; + read( + request: protos.google.spanner.v1.IReadRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IReadRequest|null|undefined, + {}|null|undefined>): void; + read( + request: protos.google.spanner.v1.IReadRequest, + callback: Callback< + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IReadRequest|null|undefined, + {}|null|undefined>): void; + read( + request?: protos.google.spanner.v1.IReadRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IReadRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IReadRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.v1.IResultSet, + protos.google.spanner.v1.IReadRequest|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({ + 'session': request.session ?? '', + }); + this.initialize(); + return this.innerApiCalls.read(request, options, callback); + } +/** + * Begins a new transaction. This step can often be skipped: + * {@link google.spanner.v1.Spanner.Read|Read}, {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql} and + * {@link google.spanner.v1.Spanner.Commit|Commit} can begin a new transaction as a + * side-effect. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.session + * Required. The session in which the transaction runs. + * @param {google.spanner.v1.TransactionOptions} request.options + * Required. Options for the new transaction. + * @param {google.spanner.v1.RequestOptions} request.requestOptions + * Common options for this request. + * Priority is ignored for this request. Setting the priority in this + * request_options struct will not do anything. To set the priority for a + * transaction, set it on the reads and writes that are part of this + * transaction instead. + * @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 {@link google.spanner.v1.Transaction | Transaction}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + beginTransaction( + request?: protos.google.spanner.v1.IBeginTransactionRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.ITransaction, + protos.google.spanner.v1.IBeginTransactionRequest|undefined, {}|undefined + ]>; + beginTransaction( + request: protos.google.spanner.v1.IBeginTransactionRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.v1.ITransaction, + protos.google.spanner.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): void; + beginTransaction( + request: protos.google.spanner.v1.IBeginTransactionRequest, + callback: Callback< + protos.google.spanner.v1.ITransaction, + protos.google.spanner.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): void; + beginTransaction( + request?: protos.google.spanner.v1.IBeginTransactionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.v1.ITransaction, + protos.google.spanner.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.v1.ITransaction, + protos.google.spanner.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.v1.ITransaction, + protos.google.spanner.v1.IBeginTransactionRequest|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({ + 'session': request.session ?? '', + }); + this.initialize(); + return this.innerApiCalls.beginTransaction(request, options, callback); + } +/** + * Commits a transaction. The request includes the mutations to be + * applied to rows in the database. + * + * `Commit` might return an `ABORTED` error. This can occur at any time; + * commonly, the cause is conflicts with concurrent + * transactions. However, it can also happen for a variety of other + * reasons. If `Commit` returns `ABORTED`, the caller should re-attempt + * the transaction from the beginning, re-using the same session. + * + * On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, + * for example, if the client job experiences a 1+ hour networking failure. + * At that point, Cloud Spanner has lost track of the transaction outcome and + * we recommend that you perform another read from the database to see the + * state of things as they are now. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.session + * Required. The session in which the transaction to be committed is running. + * @param {Buffer} request.transactionId + * Commit a previously-started transaction. + * @param {google.spanner.v1.TransactionOptions} request.singleUseTransaction + * Execute mutations in a temporary transaction. Note that unlike + * commit of a previously-started transaction, commit with a + * temporary transaction is non-idempotent. That is, if the + * `CommitRequest` is sent to Cloud Spanner more than once (for + * instance, due to retries in the application, or in the + * transport library), it is possible that the mutations are + * executed more than once. If this is undesirable, use + * {@link google.spanner.v1.Spanner.BeginTransaction|BeginTransaction} and + * {@link google.spanner.v1.Spanner.Commit|Commit} instead. + * @param {number[]} request.mutations + * The mutations to be executed when this transaction commits. All + * mutations are applied atomically, in the order they appear in + * this list. + * @param {boolean} request.returnCommitStats + * If `true`, then statistics related to the transaction will be included in + * the {@link google.spanner.v1.CommitResponse.commit_stats|CommitResponse}. Default value is + * `false`. + * @param {google.spanner.v1.RequestOptions} request.requestOptions + * Common options for this request. + * @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 {@link google.spanner.v1.CommitResponse | CommitResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + commit( + request?: protos.google.spanner.v1.ICommitRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.ICommitResponse, + protos.google.spanner.v1.ICommitRequest|undefined, {}|undefined + ]>; + commit( + request: protos.google.spanner.v1.ICommitRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.v1.ICommitResponse, + protos.google.spanner.v1.ICommitRequest|null|undefined, + {}|null|undefined>): void; + commit( + request: protos.google.spanner.v1.ICommitRequest, + callback: Callback< + protos.google.spanner.v1.ICommitResponse, + protos.google.spanner.v1.ICommitRequest|null|undefined, + {}|null|undefined>): void; + commit( + request?: protos.google.spanner.v1.ICommitRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.v1.ICommitResponse, + protos.google.spanner.v1.ICommitRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.v1.ICommitResponse, + protos.google.spanner.v1.ICommitRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.v1.ICommitResponse, + protos.google.spanner.v1.ICommitRequest|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({ + 'session': request.session ?? '', + }); + this.initialize(); + return this.innerApiCalls.commit(request, options, callback); + } +/** + * Rolls back a transaction, releasing any locks it holds. It is a good + * idea to call this for any transaction that includes one or more + * {@link google.spanner.v1.Spanner.Read|Read} or {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql} requests and + * ultimately decides not to commit. + * + * `Rollback` returns `OK` if it successfully aborts the transaction, the + * transaction was already aborted, or the transaction is not + * found. `Rollback` never returns `ABORTED`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.session + * Required. The session in which the transaction to roll back is running. + * @param {Buffer} request.transactionId + * Required. The transaction to roll back. + * @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 {@link google.protobuf.Empty | Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + rollback( + request?: protos.google.spanner.v1.IRollbackRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IRollbackRequest|undefined, {}|undefined + ]>; + rollback( + request: protos.google.spanner.v1.IRollbackRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IRollbackRequest|null|undefined, + {}|null|undefined>): void; + rollback( + request: protos.google.spanner.v1.IRollbackRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IRollbackRequest|null|undefined, + {}|null|undefined>): void; + rollback( + request?: protos.google.spanner.v1.IRollbackRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IRollbackRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IRollbackRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.spanner.v1.IRollbackRequest|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({ + 'session': request.session ?? '', + }); + this.initialize(); + return this.innerApiCalls.rollback(request, options, callback); + } +/** + * Creates a set of partition tokens that can be used to execute a query + * operation in parallel. Each of the returned partition tokens can be used + * by {@link google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} to specify a subset + * of the query result to read. The same session and read-only transaction + * must be used by the PartitionQueryRequest used to create the + * partition tokens and the ExecuteSqlRequests that use the partition tokens. + * + * Partition tokens become invalid when the session used to create them + * is deleted, is idle for too long, begins a new transaction, or becomes too + * old. When any of these happen, it is not possible to resume the query, and + * the whole operation must be restarted from the beginning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.session + * Required. The session used to create the partitions. + * @param {google.spanner.v1.TransactionSelector} request.transaction + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * @param {string} request.sql + * Required. The query request to generate partitions for. The request will fail if + * the query is not root partitionable. The query plan of a root + * partitionable query has a single distributed union operator. A distributed + * union operator conceptually divides one or more tables into multiple + * splits, remotely evaluates a subquery independently on each split, and + * then unions all results. + * + * This must not contain DML commands, such as INSERT, UPDATE, or + * DELETE. Use {@link google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} with a + * PartitionedDml transaction for large, partition-friendly DML operations. + * @param {google.protobuf.Struct} request.params + * Parameter names and values that bind to placeholders in the SQL string. + * + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names can contain + * letters, numbers, and underscores. + * + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * + * It is an error to execute a SQL statement with unbound parameters. + * @param {number[]} request.paramTypes + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in {@link google.spanner.v1.PartitionQueryRequest.params|params} as JSON strings. + * + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL query parameters. See the + * definition of {@link google.spanner.v1.Type|Type} for more information + * about SQL types. + * @param {google.spanner.v1.PartitionOptions} request.partitionOptions + * Additional options that affect how many partitions are created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.spanner.v1.PartitionResponse | PartitionResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + partitionQuery( + request?: protos.google.spanner.v1.IPartitionQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionQueryRequest|undefined, {}|undefined + ]>; + partitionQuery( + request: protos.google.spanner.v1.IPartitionQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionQueryRequest|null|undefined, + {}|null|undefined>): void; + partitionQuery( + request: protos.google.spanner.v1.IPartitionQueryRequest, + callback: Callback< + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionQueryRequest|null|undefined, + {}|null|undefined>): void; + partitionQuery( + request?: protos.google.spanner.v1.IPartitionQueryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionQueryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionQueryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionQueryRequest|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({ + 'session': request.session ?? '', + }); + this.initialize(); + return this.innerApiCalls.partitionQuery(request, options, callback); + } +/** + * Creates a set of partition tokens that can be used to execute a read + * operation in parallel. Each of the returned partition tokens can be used + * by {@link google.spanner.v1.Spanner.StreamingRead|StreamingRead} to specify a subset of the read + * result to read. The same session and read-only transaction must be used by + * the PartitionReadRequest used to create the partition tokens and the + * ReadRequests that use the partition tokens. There are no ordering + * guarantees on rows returned among the returned partition tokens, or even + * within each individual StreamingRead call issued with a partition_token. + * + * Partition tokens become invalid when the session used to create them + * is deleted, is idle for too long, begins a new transaction, or becomes too + * old. When any of these happen, it is not possible to resume the read, and + * the whole operation must be restarted from the beginning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.session + * Required. The session used to create the partitions. + * @param {google.spanner.v1.TransactionSelector} request.transaction + * Read only snapshot transactions are supported, read/write and single use + * transactions are not. + * @param {string} request.table + * Required. The name of the table in the database to be read. + * @param {string} request.index + * If non-empty, the name of an index on {@link google.spanner.v1.PartitionReadRequest.table|table}. This index is + * used instead of the table primary key when interpreting {@link google.spanner.v1.PartitionReadRequest.key_set|key_set} + * and sorting result rows. See {@link google.spanner.v1.PartitionReadRequest.key_set|key_set} for further information. + * @param {string[]} request.columns + * The columns of {@link google.spanner.v1.PartitionReadRequest.table|table} to be returned for each row matching + * this request. + * @param {google.spanner.v1.KeySet} request.keySet + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in {@link google.spanner.v1.PartitionReadRequest.table|table} to be yielded, unless {@link google.spanner.v1.PartitionReadRequest.index|index} + * is present. If {@link google.spanner.v1.PartitionReadRequest.index|index} is present, then {@link google.spanner.v1.PartitionReadRequest.key_set|key_set} instead names + * index keys in {@link google.spanner.v1.PartitionReadRequest.index|index}. + * + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * @param {google.spanner.v1.PartitionOptions} request.partitionOptions + * Additional options that affect how many partitions are created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.spanner.v1.PartitionResponse | PartitionResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + */ + partitionRead( + request?: protos.google.spanner.v1.IPartitionReadRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionReadRequest|undefined, {}|undefined + ]>; + partitionRead( + request: protos.google.spanner.v1.IPartitionReadRequest, + options: CallOptions, + callback: Callback< + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionReadRequest|null|undefined, + {}|null|undefined>): void; + partitionRead( + request: protos.google.spanner.v1.IPartitionReadRequest, + callback: Callback< + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionReadRequest|null|undefined, + {}|null|undefined>): void; + partitionRead( + request?: protos.google.spanner.v1.IPartitionReadRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionReadRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionReadRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.spanner.v1.IPartitionResponse, + protos.google.spanner.v1.IPartitionReadRequest|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({ + 'session': request.session ?? '', + }); + this.initialize(); + return this.innerApiCalls.partitionRead(request, options, callback); + } + +/** + * Like {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, except returns the result + * set as a stream. Unlike {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, there + * is no limit on the size of the returned result set. However, no + * individual row in the result set can exceed 100 MiB, and no + * column value can exceed 10 MiB. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.session + * Required. The session in which the SQL query should be performed. + * @param {google.spanner.v1.TransactionSelector} request.transaction + * The transaction to use. + * + * For queries, if none is provided, the default is a temporary read-only + * transaction with strong concurrency. + * + * Standard DML statements require a read-write transaction. To protect + * against replays, single-use transactions are not supported. The caller + * must either supply an existing transaction ID or begin a new transaction. + * + * Partitioned DML requires an existing Partitioned DML transaction ID. + * @param {string} request.sql + * Required. The SQL string. + * @param {google.protobuf.Struct} request.params + * Parameter names and values that bind to placeholders in the SQL string. + * + * A parameter placeholder consists of the `@` character followed by the + * parameter name (for example, `@firstName`). Parameter names must conform + * to the naming requirements of identifiers as specified at + * https://cloud.google.com/spanner/docs/lexical#identifiers. + * + * Parameters can appear anywhere that a literal value is expected. The same + * parameter name can be used more than once, for example: + * + * `"WHERE id > @msg_id AND id < @msg_id + 100"` + * + * It is an error to execute a SQL statement with unbound parameters. + * @param {number[]} request.paramTypes + * It is not always possible for Cloud Spanner to infer the right SQL type + * from a JSON value. For example, values of type `BYTES` and values + * of type `STRING` both appear in {@link google.spanner.v1.ExecuteSqlRequest.params|params} as JSON strings. + * + * In these cases, `param_types` can be used to specify the exact + * SQL type for some or all of the SQL statement parameters. See the + * definition of {@link google.spanner.v1.Type|Type} for more information + * about SQL types. + * @param {Buffer} request.resumeToken + * If this request is resuming a previously interrupted SQL statement + * execution, `resume_token` should be copied from the last + * {@link google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the interruption. Doing this + * enables the new SQL statement execution to resume where the last one left + * off. The rest of the request parameters must exactly match the + * request that yielded this token. + * @param {google.spanner.v1.ExecuteSqlRequest.QueryMode} request.queryMode + * Used to control the amount of debugging information returned in + * {@link google.spanner.v1.ResultSetStats|ResultSetStats}. If {@link google.spanner.v1.ExecuteSqlRequest.partition_token|partition_token} is set, {@link google.spanner.v1.ExecuteSqlRequest.query_mode|query_mode} can only + * be set to {@link google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL|QueryMode.NORMAL}. + * @param {Buffer} request.partitionToken + * If present, results will be restricted to the specified partition + * previously created using PartitionQuery(). There must be an exact + * match for the values of fields common to this message and the + * PartitionQueryRequest message used to create this partition_token. + * @param {number} request.seqno + * A per-transaction sequence number used to identify this request. This field + * makes each request idempotent such that if the request is received multiple + * times, at most one will succeed. + * + * The sequence number must be monotonically increasing within the + * transaction. If a request arrives for the first time with an out-of-order + * sequence number, the transaction may be aborted. Replays of previously + * handled requests will yield the same response as the first execution. + * + * Required for DML statements. Ignored for queries. + * @param {google.spanner.v1.ExecuteSqlRequest.QueryOptions} request.queryOptions + * Query optimizer configuration to use for the given query. + * @param {google.spanner.v1.RequestOptions} request.requestOptions + * Common options for this request. + * @param {boolean} request.dataBoostEnabled + * If this is for a partitioned read and this field is set to `true`, the + * request will be executed via Spanner independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API will return an `INVALID_ARGUMENT` error. + * @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 {@link google.spanner.v1.PartialResultSet | PartialResultSet} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + */ + executeStreamingSql( + request?: protos.google.spanner.v1.IExecuteSqlRequest, + options?: CallOptions): + gax.CancellableStream{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'session': request.session ?? '', + }); + this.initialize(); + return this.innerApiCalls.executeStreamingSql(request, options); + } + +/** + * Like {@link google.spanner.v1.Spanner.Read|Read}, except returns the result set as a + * stream. Unlike {@link google.spanner.v1.Spanner.Read|Read}, there is no limit on the + * size of the returned result set. However, no individual row in + * the result set can exceed 100 MiB, and no column value can exceed + * 10 MiB. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.session + * Required. The session in which the read should be performed. + * @param {google.spanner.v1.TransactionSelector} request.transaction + * The transaction to use. If none is provided, the default is a + * temporary read-only transaction with strong concurrency. + * @param {string} request.table + * Required. The name of the table in the database to be read. + * @param {string} request.index + * If non-empty, the name of an index on {@link google.spanner.v1.ReadRequest.table|table}. This index is + * used instead of the table primary key when interpreting {@link google.spanner.v1.ReadRequest.key_set|key_set} + * and sorting result rows. See {@link google.spanner.v1.ReadRequest.key_set|key_set} for further information. + * @param {string[]} request.columns + * Required. The columns of {@link google.spanner.v1.ReadRequest.table|table} to be returned for each row matching + * this request. + * @param {google.spanner.v1.KeySet} request.keySet + * Required. `key_set` identifies the rows to be yielded. `key_set` names the + * primary keys of the rows in {@link google.spanner.v1.ReadRequest.table|table} to be yielded, unless {@link google.spanner.v1.ReadRequest.index|index} + * is present. If {@link google.spanner.v1.ReadRequest.index|index} is present, then {@link google.spanner.v1.ReadRequest.key_set|key_set} instead names + * index keys in {@link google.spanner.v1.ReadRequest.index|index}. + * + * If the {@link google.spanner.v1.ReadRequest.partition_token|partition_token} field is empty, rows are yielded + * in table primary key order (if {@link google.spanner.v1.ReadRequest.index|index} is empty) or index key order + * (if {@link google.spanner.v1.ReadRequest.index|index} is non-empty). If the {@link google.spanner.v1.ReadRequest.partition_token|partition_token} field is not + * empty, rows will be yielded in an unspecified order. + * + * It is not an error for the `key_set` to name rows that do not + * exist in the database. Read yields nothing for nonexistent rows. + * @param {number} request.limit + * If greater than zero, only the first `limit` rows are yielded. If `limit` + * is zero, the default is no limit. A limit cannot be specified if + * `partition_token` is set. + * @param {Buffer} request.resumeToken + * If this request is resuming a previously interrupted read, + * `resume_token` should be copied from the last + * {@link google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the interruption. Doing this + * enables the new read to resume where the last read left off. The + * rest of the request parameters must exactly match the request + * that yielded this token. + * @param {Buffer} request.partitionToken + * If present, results will be restricted to the specified partition + * previously created using PartitionRead(). There must be an exact + * match for the values of fields common to this message and the + * PartitionReadRequest message used to create this partition_token. + * @param {google.spanner.v1.RequestOptions} request.requestOptions + * Common options for this request. + * @param {boolean} request.dataBoostEnabled + * If this is for a partitioned query and this field is set to `true`, the + * request will be executed via Spanner independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API will return an `INVALID_ARGUMENT` error. + * @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 {@link google.spanner.v1.PartialResultSet | PartialResultSet} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + */ + streamingRead( + request?: protos.google.spanner.v1.IReadRequest, + options?: CallOptions): + gax.CancellableStream{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'session': request.session ?? '', + }); + this.initialize(); + return this.innerApiCalls.streamingRead(request, options); + } + + /** + * Lists all sessions in a given database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database in which to list sessions. + * @param {number} request.pageSize + * Number of sessions to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token} from a previous + * {@link google.spanner.v1.ListSessionsResponse|ListSessionsResponse}. + * @param {string} request.filter + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * + * * `labels.key` where key is the name of a label + * + * Some examples of using filters are: + * + * * `labels.env:*` --> The session has the label "env". + * * `labels.env:dev` --> The session has the label "env" and the value of + * the label contains the string "dev". + * @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 {@link google.spanner.v1.Session | Session}. + * 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 `listSessionsAsync()` + * 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. + */ + listSessions( + request?: protos.google.spanner.v1.IListSessionsRequest, + options?: CallOptions): + Promise<[ + protos.google.spanner.v1.ISession[], + protos.google.spanner.v1.IListSessionsRequest|null, + protos.google.spanner.v1.IListSessionsResponse + ]>; + listSessions( + request: protos.google.spanner.v1.IListSessionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.spanner.v1.IListSessionsRequest, + protos.google.spanner.v1.IListSessionsResponse|null|undefined, + protos.google.spanner.v1.ISession>): void; + listSessions( + request: protos.google.spanner.v1.IListSessionsRequest, + callback: PaginationCallback< + protos.google.spanner.v1.IListSessionsRequest, + protos.google.spanner.v1.IListSessionsResponse|null|undefined, + protos.google.spanner.v1.ISession>): void; + listSessions( + request?: protos.google.spanner.v1.IListSessionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.spanner.v1.IListSessionsRequest, + protos.google.spanner.v1.IListSessionsResponse|null|undefined, + protos.google.spanner.v1.ISession>, + callback?: PaginationCallback< + protos.google.spanner.v1.IListSessionsRequest, + protos.google.spanner.v1.IListSessionsResponse|null|undefined, + protos.google.spanner.v1.ISession>): + Promise<[ + protos.google.spanner.v1.ISession[], + protos.google.spanner.v1.IListSessionsRequest|null, + protos.google.spanner.v1.IListSessionsResponse + ]>|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({ + 'database': request.database ?? '', + }); + this.initialize(); + return this.innerApiCalls.listSessions(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.database + * Required. The database in which to list sessions. + * @param {number} request.pageSize + * Number of sessions to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token} from a previous + * {@link google.spanner.v1.ListSessionsResponse|ListSessionsResponse}. + * @param {string} request.filter + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * + * * `labels.key` where key is the name of a label + * + * Some examples of using filters are: + * + * * `labels.env:*` --> The session has the label "env". + * * `labels.env:dev` --> The session has the label "env" and the value of + * the label contains the string "dev". + * @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 {@link google.spanner.v1.Session | Session} 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 `listSessionsAsync()` + * 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. + */ + listSessionsStream( + request?: protos.google.spanner.v1.IListSessionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'database': request.database ?? '', + }); + const defaultCallSettings = this._defaults['listSessions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSessions.createStream( + this.innerApiCalls.listSessions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listSessions`, 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.database + * Required. The database in which to list sessions. + * @param {number} request.pageSize + * Number of sessions to be returned in the response. If 0 or less, defaults + * to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token} from a previous + * {@link google.spanner.v1.ListSessionsResponse|ListSessionsResponse}. + * @param {string} request.filter + * An expression for filtering the results of the request. Filter rules are + * case insensitive. The fields eligible for filtering are: + * + * * `labels.key` where key is the name of a label + * + * Some examples of using filters are: + * + * * `labels.env:*` --> The session has the label "env". + * * `labels.env:dev` --> The session has the label "env" and the value of + * the label contains the string "dev". + * @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 + * {@link google.spanner.v1.Session | Session}. 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. + */ + listSessionsAsync( + request?: protos.google.spanner.v1.IListSessionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'database': request.database ?? '', + }); + const defaultCallSettings = this._defaults['listSessions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSessions.asyncIterate( + this.innerApiCalls['listSessions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified database resource name string. + * + * @param {string} project + * @param {string} instance + * @param {string} database + * @returns {string} Resource name string. + */ + databasePath(project:string,instance:string,database:string) { + return this.pathTemplates.databasePathTemplate.render({ + project: project, + instance: instance, + database: database, + }); + } + + /** + * Parse the project from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDatabaseName(databaseName: string) { + return this.pathTemplates.databasePathTemplate.match(databaseName).project; + } + + /** + * Parse the instance from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromDatabaseName(databaseName: string) { + return this.pathTemplates.databasePathTemplate.match(databaseName).instance; + } + + /** + * Parse the database from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromDatabaseName(databaseName: string) { + return this.pathTemplates.databasePathTemplate.match(databaseName).database; + } + + /** + * Return a fully-qualified session resource name string. + * + * @param {string} project + * @param {string} instance + * @param {string} database + * @param {string} session + * @returns {string} Resource name string. + */ + sessionPath(project:string,instance:string,database:string,session:string) { + return this.pathTemplates.sessionPathTemplate.render({ + project: project, + instance: instance, + database: database, + session: session, + }); + } + + /** + * Parse the project from Session resource. + * + * @param {string} sessionName + * A fully-qualified path representing Session resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSessionName(sessionName: string) { + return this.pathTemplates.sessionPathTemplate.match(sessionName).project; + } + + /** + * Parse the instance from Session resource. + * + * @param {string} sessionName + * A fully-qualified path representing Session resource. + * @returns {string} A string representing the instance. + */ + matchInstanceFromSessionName(sessionName: string) { + return this.pathTemplates.sessionPathTemplate.match(sessionName).instance; + } + + /** + * Parse the database from Session resource. + * + * @param {string} sessionName + * A fully-qualified path representing Session resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromSessionName(sessionName: string) { + return this.pathTemplates.sessionPathTemplate.match(sessionName).database; + } + + /** + * Parse the session from Session resource. + * + * @param {string} sessionName + * A fully-qualified path representing Session resource. + * @returns {string} A string representing the session. + */ + matchSessionFromSessionName(sessionName: string) { + return this.pathTemplates.sessionPathTemplate.match(sessionName).session; + } + + /** + * 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.spannerStub && !this._terminated) { + return this.spannerStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/spanner_client_config.json b/owl-bot-staging/v1/src/v1/spanner_client_config.json new file mode 100644 index 000000000..d14bef0e6 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/spanner_client_config.json @@ -0,0 +1,113 @@ +{ + "interfaces": { + "google.spanner.v1.Spanner": { + "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 + }, + "9442ca297df43f7314712e1a19d003838e738a45": { + "initial_retry_delay_millis": 250, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 32000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateSession": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "BatchCreateSessions": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "GetSession": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "ListSessions": { + "timeout_millis": 3600000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "DeleteSession": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "ExecuteSql": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "ExecuteStreamingSql": { + "timeout_millis": 3600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ExecuteBatchDml": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "Read": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "StreamingRead": { + "timeout_millis": 3600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "BeginTransaction": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "Commit": { + "timeout_millis": 3600000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "Rollback": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "PartitionQuery": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + }, + "PartitionRead": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/spanner_proto_list.json b/owl-bot-staging/v1/src/v1/spanner_proto_list.json new file mode 100644 index 000000000..de809666e --- /dev/null +++ b/owl-bot-staging/v1/src/v1/spanner_proto_list.json @@ -0,0 +1,10 @@ +[ + "../../protos/google/spanner/v1/commit_response.proto", + "../../protos/google/spanner/v1/keys.proto", + "../../protos/google/spanner/v1/mutation.proto", + "../../protos/google/spanner/v1/query_plan.proto", + "../../protos/google/spanner/v1/result_set.proto", + "../../protos/google/spanner/v1/spanner.proto", + "../../protos/google/spanner/v1/transaction.proto", + "../../protos/google/spanner/v1/type.proto" +] diff --git a/owl-bot-staging/v1/test/gapic_spanner_v1.ts b/owl-bot-staging/v1/test/gapic_spanner_v1.ts new file mode 100644 index 000000000..2fa52bce8 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_spanner_v1.ts @@ -0,0 +1,2047 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 spannerModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +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 stubServerStreamingCall(response?: ResponseType, error?: Error) { + const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // write something to the stream to trigger transformStub and send the response back to the client + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + return sinon.stub().returns(mockStream); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.SpannerClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = spannerModule.v1.SpannerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = spannerModule.v1.SpannerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = spannerModule.v1.SpannerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new spannerModule.v1.SpannerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new spannerModule.v1.SpannerClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.spannerStub, undefined); + await client.initialize(); + assert(client.spannerStub); + }); + + it('has close method for the initialized client', done => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.spannerStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.spannerStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new spannerModule.v1.SpannerClient({ + 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 spannerModule.v1.SpannerClient({ + 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('createSession', () => { + it('invokes createSession without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.CreateSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.CreateSessionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.Session() + ); + client.innerApiCalls.createSession = stubSimpleCall(expectedResponse); + const [response] = await client.createSession(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSession as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSession as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSession without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.CreateSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.CreateSessionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.Session() + ); + client.innerApiCalls.createSession = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSession( + request, + (err?: Error|null, result?: protos.google.spanner.v1.ISession|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSession as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSession as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSession with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.CreateSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.CreateSessionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSession = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createSession(request), expectedError); + const actualRequest = (client.innerApiCalls.createSession as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSession as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSession with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.CreateSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.CreateSessionRequest', ['database']); + request.database = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createSession(request), expectedError); + }); + }); + + describe('batchCreateSessions', () => { + it('invokes batchCreateSessions without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.BatchCreateSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.BatchCreateSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.BatchCreateSessionsResponse() + ); + client.innerApiCalls.batchCreateSessions = stubSimpleCall(expectedResponse); + const [response] = await client.batchCreateSessions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchCreateSessions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchCreateSessions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchCreateSessions without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.BatchCreateSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.BatchCreateSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.BatchCreateSessionsResponse() + ); + client.innerApiCalls.batchCreateSessions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchCreateSessions( + request, + (err?: Error|null, result?: protos.google.spanner.v1.IBatchCreateSessionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchCreateSessions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchCreateSessions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchCreateSessions with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.BatchCreateSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.BatchCreateSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchCreateSessions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchCreateSessions(request), expectedError); + const actualRequest = (client.innerApiCalls.batchCreateSessions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchCreateSessions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchCreateSessions with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.BatchCreateSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.BatchCreateSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchCreateSessions(request), expectedError); + }); + }); + + describe('getSession', () => { + it('invokes getSession without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.GetSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.GetSessionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.Session() + ); + client.innerApiCalls.getSession = stubSimpleCall(expectedResponse); + const [response] = await client.getSession(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSession as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSession as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSession without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.GetSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.GetSessionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.Session() + ); + client.innerApiCalls.getSession = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSession( + request, + (err?: Error|null, result?: protos.google.spanner.v1.ISession|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSession as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSession as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSession with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.GetSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.GetSessionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSession = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSession(request), expectedError); + const actualRequest = (client.innerApiCalls.getSession as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSession as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSession with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.GetSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.GetSessionRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getSession(request), expectedError); + }); + }); + + describe('deleteSession', () => { + it('invokes deleteSession without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.DeleteSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.DeleteSessionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSession = stubSimpleCall(expectedResponse); + const [response] = await client.deleteSession(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSession as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSession as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSession without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.DeleteSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.DeleteSessionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSession = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSession( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSession as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSession as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSession with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.DeleteSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.DeleteSessionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSession = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteSession(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteSession as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSession as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSession with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.DeleteSessionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.DeleteSessionRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteSession(request), expectedError); + }); + }); + + describe('executeSql', () => { + it('invokes executeSql without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteSqlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.ResultSet() + ); + client.innerApiCalls.executeSql = stubSimpleCall(expectedResponse); + const [response] = await client.executeSql(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executeSql as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeSql without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteSqlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.ResultSet() + ); + client.innerApiCalls.executeSql = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeSql( + request, + (err?: Error|null, result?: protos.google.spanner.v1.IResultSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executeSql as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeSql with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteSqlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeSql = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.executeSql(request), expectedError); + const actualRequest = (client.innerApiCalls.executeSql as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeSql with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteSqlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); + request.session = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.executeSql(request), expectedError); + }); + }); + + describe('executeBatchDml', () => { + it('invokes executeBatchDml without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteBatchDmlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteBatchDmlRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.ExecuteBatchDmlResponse() + ); + client.innerApiCalls.executeBatchDml = stubSimpleCall(expectedResponse); + const [response] = await client.executeBatchDml(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executeBatchDml as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeBatchDml as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeBatchDml without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteBatchDmlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteBatchDmlRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.ExecuteBatchDmlResponse() + ); + client.innerApiCalls.executeBatchDml = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeBatchDml( + request, + (err?: Error|null, result?: protos.google.spanner.v1.IExecuteBatchDmlResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executeBatchDml as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeBatchDml as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeBatchDml with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteBatchDmlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteBatchDmlRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeBatchDml = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.executeBatchDml(request), expectedError); + const actualRequest = (client.innerApiCalls.executeBatchDml as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeBatchDml as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeBatchDml with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteBatchDmlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteBatchDmlRequest', ['session']); + request.session = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.executeBatchDml(request), expectedError); + }); + }); + + describe('read', () => { + it('invokes read without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.ResultSet() + ); + client.innerApiCalls.read = stubSimpleCall(expectedResponse); + const [response] = await client.read(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.read as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.read as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes read without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.ResultSet() + ); + client.innerApiCalls.read = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.read( + request, + (err?: Error|null, result?: protos.google.spanner.v1.IResultSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.read as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.read as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes read with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.read = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.read(request), expectedError); + const actualRequest = (client.innerApiCalls.read as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.read as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes read with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); + request.session = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.read(request), expectedError); + }); + }); + + describe('beginTransaction', () => { + it('invokes beginTransaction without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.BeginTransactionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.BeginTransactionRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.Transaction() + ); + client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); + const [response] = await client.beginTransaction(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes beginTransaction without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.BeginTransactionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.BeginTransactionRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.Transaction() + ); + client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.beginTransaction( + request, + (err?: Error|null, result?: protos.google.spanner.v1.ITransaction|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes beginTransaction with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.BeginTransactionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.BeginTransactionRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.beginTransaction(request), expectedError); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes beginTransaction with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.BeginTransactionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.BeginTransactionRequest', ['session']); + request.session = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.beginTransaction(request), expectedError); + }); + }); + + describe('commit', () => { + it('invokes commit without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.CommitRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.CommitRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.CommitResponse() + ); + client.innerApiCalls.commit = stubSimpleCall(expectedResponse); + const [response] = await client.commit(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes commit without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.CommitRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.CommitRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.CommitResponse() + ); + client.innerApiCalls.commit = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.commit( + request, + (err?: Error|null, result?: protos.google.spanner.v1.ICommitResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes commit with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.CommitRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.CommitRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.commit(request), expectedError); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes commit with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.CommitRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.CommitRequest', ['session']); + request.session = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.commit(request), expectedError); + }); + }); + + describe('rollback', () => { + it('invokes rollback without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.RollbackRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.RollbackRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); + const [response] = await client.rollback(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollback without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.RollbackRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.RollbackRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rollback( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollback with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.RollbackRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.RollbackRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollback with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.RollbackRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.RollbackRequest', ['session']); + request.session = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.rollback(request), expectedError); + }); + }); + + describe('partitionQuery', () => { + it('invokes partitionQuery without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.PartitionQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.PartitionQueryRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.PartitionResponse() + ); + client.innerApiCalls.partitionQuery = stubSimpleCall(expectedResponse); + const [response] = await client.partitionQuery(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes partitionQuery without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.PartitionQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.PartitionQueryRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.PartitionResponse() + ); + client.innerApiCalls.partitionQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.partitionQuery( + request, + (err?: Error|null, result?: protos.google.spanner.v1.IPartitionResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes partitionQuery with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.PartitionQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.PartitionQueryRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.partitionQuery(request), expectedError); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes partitionQuery with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.PartitionQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.PartitionQueryRequest', ['session']); + request.session = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.partitionQuery(request), expectedError); + }); + }); + + describe('partitionRead', () => { + it('invokes partitionRead without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.PartitionReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.PartitionReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.PartitionResponse() + ); + client.innerApiCalls.partitionRead = stubSimpleCall(expectedResponse); + const [response] = await client.partitionRead(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.partitionRead as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionRead as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes partitionRead without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.PartitionReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.PartitionReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.PartitionResponse() + ); + client.innerApiCalls.partitionRead = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.partitionRead( + request, + (err?: Error|null, result?: protos.google.spanner.v1.IPartitionResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.partitionRead as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionRead as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes partitionRead with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.PartitionReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.PartitionReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.partitionRead = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.partitionRead(request), expectedError); + const actualRequest = (client.innerApiCalls.partitionRead as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionRead as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes partitionRead with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.PartitionReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.PartitionReadRequest', ['session']); + request.session = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.partitionRead(request), expectedError); + }); + }); + + describe('executeStreamingSql', () => { + it('invokes executeStreamingSql without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteSqlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.PartialResultSet() + ); + client.innerApiCalls.executeStreamingSql = stubServerStreamingCall(expectedResponse); + const stream = client.executeStreamingSql(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.executeStreamingSql as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeStreamingSql as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeStreamingSql with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteSqlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeStreamingSql = stubServerStreamingCall(undefined, expectedError); + const stream = client.executeStreamingSql(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + const actualRequest = (client.innerApiCalls.executeStreamingSql as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.executeStreamingSql as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeStreamingSql with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ExecuteSqlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); + request.session = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.executeStreamingSql(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + }); + }); + + describe('streamingRead', () => { + it('invokes streamingRead without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.spanner.v1.PartialResultSet() + ); + client.innerApiCalls.streamingRead = stubServerStreamingCall(expectedResponse); + const stream = client.streamingRead(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.streamingRead as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.streamingRead as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes streamingRead with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); + request.session = defaultValue1; + const expectedHeaderRequestParams = `session=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.streamingRead = stubServerStreamingCall(undefined, expectedError); + const stream = client.streamingRead(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + const actualRequest = (client.innerApiCalls.streamingRead as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.streamingRead as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes streamingRead with closed client', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ReadRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); + request.session = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.streamingRead(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + }); + }); + + describe('listSessions', () => { + it('invokes listSessions without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ListSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.v1.Session()), + generateSampleMessage(new protos.google.spanner.v1.Session()), + generateSampleMessage(new protos.google.spanner.v1.Session()), + ]; + client.innerApiCalls.listSessions = stubSimpleCall(expectedResponse); + const [response] = await client.listSessions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSessions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSessions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSessions without error using callback', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ListSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.v1.Session()), + generateSampleMessage(new protos.google.spanner.v1.Session()), + generateSampleMessage(new protos.google.spanner.v1.Session()), + ]; + client.innerApiCalls.listSessions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSessions( + request, + (err?: Error|null, result?: protos.google.spanner.v1.ISession[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSessions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSessions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSessions with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ListSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSessions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listSessions(request), expectedError); + const actualRequest = (client.innerApiCalls.listSessions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSessions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSessionsStream without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ListSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.v1.Session()), + generateSampleMessage(new protos.google.spanner.v1.Session()), + generateSampleMessage(new protos.google.spanner.v1.Session()), + ]; + client.descriptors.page.listSessions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listSessionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.v1.Session[] = []; + stream.on('data', (response: protos.google.spanner.v1.Session) => { + 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.listSessions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSessions, request)); + assert( + (client.descriptors.page.listSessions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listSessionsStream with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ListSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSessions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listSessionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.spanner.v1.Session[] = []; + stream.on('data', (response: protos.google.spanner.v1.Session) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listSessions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSessions, request)); + assert( + (client.descriptors.page.listSessions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSessions without error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ListSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.spanner.v1.Session()), + generateSampleMessage(new protos.google.spanner.v1.Session()), + generateSampleMessage(new protos.google.spanner.v1.Session()), + ]; + client.descriptors.page.listSessions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.spanner.v1.ISession[] = []; + const iterable = client.listSessionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSessions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSessions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSessions with error', async () => { + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.spanner.v1.ListSessionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSessions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSessionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.spanner.v1.ISession[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSessions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSessions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('database', () => { + const fakePath = "/rendered/path/database"; + const expectedParameters = { + project: "projectValue", + instance: "instanceValue", + database: "databaseValue", + }; + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.databasePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.databasePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('databasePath', () => { + const result = client.databasePath("projectValue", "instanceValue", "databaseValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.databasePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDatabaseName', () => { + const result = client.matchProjectFromDatabaseName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromDatabaseName', () => { + const result = client.matchInstanceFromDatabaseName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDatabaseFromDatabaseName', () => { + const result = client.matchDatabaseFromDatabaseName(fakePath); + assert.strictEqual(result, "databaseValue"); + assert((client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('session', () => { + const fakePath = "/rendered/path/session"; + const expectedParameters = { + project: "projectValue", + instance: "instanceValue", + database: "databaseValue", + session: "sessionValue", + }; + const client = new spannerModule.v1.SpannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.sessionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.sessionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('sessionPath', () => { + const result = client.sessionPath("projectValue", "instanceValue", "databaseValue", "sessionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.sessionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromSessionName', () => { + const result = client.matchProjectFromSessionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.sessionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchInstanceFromSessionName', () => { + const result = client.matchInstanceFromSessionName(fakePath); + assert.strictEqual(result, "instanceValue"); + assert((client.pathTemplates.sessionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDatabaseFromSessionName', () => { + const result = client.matchDatabaseFromSessionName(fakePath); + assert.strictEqual(result, "databaseValue"); + assert((client.pathTemplates.sessionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSessionFromSessionName', () => { + const result = client.matchSessionFromSessionName(fakePath); + assert.strictEqual(result, "sessionValue"); + assert((client.pathTemplates.sessionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 000000000..ee59a7326 --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'spanner', + filename: './spanner.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 88c83ae0ef501a1299ee8923855295c9150c8afe Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 2 Mar 2023 14:53:13 +0000 Subject: [PATCH 2/2] =?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 --- .../admin/database/v1/.eslintignore | 7 - .../admin/database/v1/.eslintrc.json | 3 - owl-bot-staging/admin/database/v1/.gitignore | 14 - owl-bot-staging/admin/database/v1/.jsdoc.js | 55 - owl-bot-staging/admin/database/v1/.mocharc.js | 33 - .../admin/database/v1/.prettierrc.js | 22 - owl-bot-staging/admin/database/v1/README.md | 1 - .../admin/database/v1/linkinator.config.json | 16 - .../admin/database/v1/package.json | 64 - .../spanner/admin/database/v1/backup.proto | 609 --- .../spanner/admin/database/v1/common.proto | 112 - .../database/v1/spanner_database_admin.proto | 930 ----- .../admin/database/v1/src/index.ts | 25 - .../v1/src/v1/database_admin_client.ts | 3557 ---------------- .../src/v1/database_admin_client_config.json | 130 - .../v1/src/v1/database_admin_proto_list.json | 5 - .../database/v1/src/v1/gapic_metadata.json | 233 -- .../admin/database/v1/src/v1/index.ts | 19 - .../v1/test/gapic_database_admin_v1.ts | 3680 ----------------- .../admin/database/v1/tsconfig.json | 19 - .../admin/database/v1/webpack.config.js | 64 - .../admin/instance/v1/.eslintignore | 7 - .../admin/instance/v1/.eslintrc.json | 3 - owl-bot-staging/admin/instance/v1/.gitignore | 14 - owl-bot-staging/admin/instance/v1/.jsdoc.js | 55 - owl-bot-staging/admin/instance/v1/.mocharc.js | 33 - .../admin/instance/v1/.prettierrc.js | 22 - owl-bot-staging/admin/instance/v1/README.md | 1 - .../admin/instance/v1/linkinator.config.json | 16 - .../admin/instance/v1/package.json | 64 - .../spanner/admin/instance/v1/common.proto | 42 - .../instance/v1/spanner_instance_admin.proto | 1081 ----- .../admin/instance/v1/src/index.ts | 25 - .../instance/v1/src/v1/gapic_metadata.json | 175 - .../admin/instance/v1/src/v1/index.ts | 19 - .../v1/src/v1/instance_admin_client.ts | 2419 ----------- .../src/v1/instance_admin_client_config.json | 101 - .../v1/src/v1/instance_admin_proto_list.json | 4 - .../v1/test/gapic_instance_admin_v1.ts | 2437 ----------- .../admin/instance/v1/tsconfig.json | 19 - .../admin/instance/v1/webpack.config.js | 64 - owl-bot-staging/v1/.eslintignore | 7 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 16 - owl-bot-staging/v1/package.json | 64 - .../google/spanner/v1/commit_response.proto | 50 - .../v1/protos/google/spanner/v1/keys.proto | 163 - .../protos/google/spanner/v1/mutation.proto | 107 - .../protos/google/spanner/v1/query_plan.proto | 128 - .../protos/google/spanner/v1/result_set.proto | 216 - .../v1/protos/google/spanner/v1/spanner.proto | 1042 ----- .../google/spanner/v1/transaction.proto | 525 --- .../v1/protos/google/spanner/v1/type.proto | 174 - owl-bot-staging/v1/src/index.ts | 25 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 167 - owl-bot-staging/v1/src/v1/index.ts | 19 - owl-bot-staging/v1/src/v1/spanner_client.ts | 2047 --------- .../v1/src/v1/spanner_client_config.json | 113 - .../v1/src/v1/spanner_proto_list.json | 10 - owl-bot-staging/v1/test/gapic_spanner_v1.ts | 2047 --------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - protos/google/spanner/v1/spanner.proto | 14 + protos/protos.d.ts | 12 + protos/protos.js | 46 + protos/protos.json | 8 + src/v1/spanner_client.ts | 24 + 72 files changed, 104 insertions(+), 23330 deletions(-) delete mode 100644 owl-bot-staging/admin/database/v1/.eslintignore delete mode 100644 owl-bot-staging/admin/database/v1/.eslintrc.json delete mode 100644 owl-bot-staging/admin/database/v1/.gitignore delete mode 100644 owl-bot-staging/admin/database/v1/.jsdoc.js delete mode 100644 owl-bot-staging/admin/database/v1/.mocharc.js delete mode 100644 owl-bot-staging/admin/database/v1/.prettierrc.js delete mode 100644 owl-bot-staging/admin/database/v1/README.md delete mode 100644 owl-bot-staging/admin/database/v1/linkinator.config.json delete mode 100644 owl-bot-staging/admin/database/v1/package.json delete mode 100644 owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/backup.proto delete mode 100644 owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/common.proto delete mode 100644 owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/spanner_database_admin.proto delete mode 100644 owl-bot-staging/admin/database/v1/src/index.ts delete mode 100644 owl-bot-staging/admin/database/v1/src/v1/database_admin_client.ts delete mode 100644 owl-bot-staging/admin/database/v1/src/v1/database_admin_client_config.json delete mode 100644 owl-bot-staging/admin/database/v1/src/v1/database_admin_proto_list.json delete mode 100644 owl-bot-staging/admin/database/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/admin/database/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/admin/database/v1/test/gapic_database_admin_v1.ts delete mode 100644 owl-bot-staging/admin/database/v1/tsconfig.json delete mode 100644 owl-bot-staging/admin/database/v1/webpack.config.js delete mode 100644 owl-bot-staging/admin/instance/v1/.eslintignore delete mode 100644 owl-bot-staging/admin/instance/v1/.eslintrc.json delete mode 100644 owl-bot-staging/admin/instance/v1/.gitignore delete mode 100644 owl-bot-staging/admin/instance/v1/.jsdoc.js delete mode 100644 owl-bot-staging/admin/instance/v1/.mocharc.js delete mode 100644 owl-bot-staging/admin/instance/v1/.prettierrc.js delete mode 100644 owl-bot-staging/admin/instance/v1/README.md delete mode 100644 owl-bot-staging/admin/instance/v1/linkinator.config.json delete mode 100644 owl-bot-staging/admin/instance/v1/package.json delete mode 100644 owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/common.proto delete mode 100644 owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto delete mode 100644 owl-bot-staging/admin/instance/v1/src/index.ts delete mode 100644 owl-bot-staging/admin/instance/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/admin/instance/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client.ts delete mode 100644 owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client_config.json delete mode 100644 owl-bot-staging/admin/instance/v1/src/v1/instance_admin_proto_list.json delete mode 100644 owl-bot-staging/admin/instance/v1/test/gapic_instance_admin_v1.ts delete mode 100644 owl-bot-staging/admin/instance/v1/tsconfig.json delete mode 100644 owl-bot-staging/admin/instance/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/commit_response.proto delete mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/keys.proto delete mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/mutation.proto delete mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/query_plan.proto delete mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/result_set.proto delete mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/spanner.proto delete mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/transaction.proto delete mode 100644 owl-bot-staging/v1/protos/google/spanner/v1/type.proto delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/spanner_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/spanner_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/spanner_proto_list.json delete mode 100644 owl-bot-staging/v1/test/gapic_spanner_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js diff --git a/owl-bot-staging/admin/database/v1/.eslintignore b/owl-bot-staging/admin/database/v1/.eslintignore deleted file mode 100644 index cfc348ec4..000000000 --- a/owl-bot-staging/admin/database/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/admin/database/v1/.eslintrc.json b/owl-bot-staging/admin/database/v1/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/admin/database/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/admin/database/v1/.gitignore b/owl-bot-staging/admin/database/v1/.gitignore deleted file mode 100644 index d4f03a0df..000000000 --- a/owl-bot-staging/admin/database/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/admin/database/v1/.jsdoc.js b/owl-bot-staging/admin/database/v1/.jsdoc.js deleted file mode 100644 index e37e0473a..000000000 --- a/owl-bot-staging/admin/database/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 2023 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/spanner', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/admin/database/v1/.mocharc.js b/owl-bot-staging/admin/database/v1/.mocharc.js deleted file mode 100644 index 1a38f257d..000000000 --- a/owl-bot-staging/admin/database/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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/admin/database/v1/.prettierrc.js b/owl-bot-staging/admin/database/v1/.prettierrc.js deleted file mode 100644 index 55639e70f..000000000 --- a/owl-bot-staging/admin/database/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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/admin/database/v1/README.md b/owl-bot-staging/admin/database/v1/README.md deleted file mode 100644 index c258fda43..000000000 --- a/owl-bot-staging/admin/database/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Database: Nodejs Client diff --git a/owl-bot-staging/admin/database/v1/linkinator.config.json b/owl-bot-staging/admin/database/v1/linkinator.config.json deleted file mode 100644 index befd23c86..000000000 --- a/owl-bot-staging/admin/database/v1/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/admin/database/v1/package.json b/owl-bot-staging/admin/database/v1/package.json deleted file mode 100644 index c95291c19..000000000 --- a/owl-bot-staging/admin/database/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/spanner", - "version": "0.1.0", - "description": "Database client for Node.js", - "repository": "googleapis/nodejs-database", - "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 database", - "database", - "database admin" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "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.5.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/backup.proto b/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/backup.proto deleted file mode 100644 index 5e019543e..000000000 --- a/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/backup.proto +++ /dev/null @@ -1,609 +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.spanner.admin.database.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/spanner/admin/database/v1/common.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database"; -option java_multiple_files = true; -option java_outer_classname = "BackupProto"; -option java_package = "com.google.spanner.admin.database.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; -option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1"; - -// A backup of a Cloud Spanner database. -message Backup { - option (google.api.resource) = { - type: "spanner.googleapis.com/Backup" - pattern: "projects/{project}/instances/{instance}/backups/{backup}" - }; - - // Indicates the current state of the backup. - enum State { - // Not specified. - STATE_UNSPECIFIED = 0; - - // The pending backup is still being created. Operations on the - // backup may fail with `FAILED_PRECONDITION` in this state. - CREATING = 1; - - // The backup is complete and ready for use. - READY = 2; - } - - // Required for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation. - // Name of the database from which this backup was - // created. This needs to be in the same instance as the backup. - // Values are of the form - // `projects//instances//databases/`. - string database = 2 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - }]; - - // The backup will contain an externally consistent copy of the database at - // the timestamp specified by `version_time`. If `version_time` is not - // specified, the system will set `version_time` to the `create_time` of the - // backup. - google.protobuf.Timestamp version_time = 9; - - // Required for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] - // operation. The expiration time of the backup, with microseconds - // granularity that must be at least 6 hours and at most 366 days - // from the time the CreateBackup request is processed. Once the `expire_time` - // has passed, the backup is eligible to be automatically deleted by Cloud - // Spanner to free the resources used by the backup. - google.protobuf.Timestamp expire_time = 3; - - // Output only for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation. - // Required for the [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup] operation. - // - // A globally unique identifier for the backup which cannot be - // changed. Values are of the form - // `projects//instances//backups/[a-z][a-z0-9_\-]*[a-z0-9]` - // The final segment of the name must be between 2 and 60 characters - // in length. - // - // The backup is stored in the location(s) specified in the instance - // configuration of the instance containing the backup, identified - // by the prefix of the backup name of the form - // `projects//instances/`. - string name = 1; - - // Output only. The time the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] - // request is received. If the request does not specify `version_time`, the - // `version_time` of the backup will be equivalent to the `create_time`. - google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Size of the backup in bytes. - int64 size_bytes = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The current state of the backup. - State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The names of the restored databases that reference the backup. - // The database names are of - // the form `projects//instances//databases/`. - // Referencing databases may exist in different instances. The existence of - // any referencing database prevents the backup from being deleted. When a - // restored database from the backup enters the `READY` state, the reference - // to the backup is removed. - repeated string referencing_databases = 7 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - } - ]; - - // Output only. The encryption information for the backup. - EncryptionInfo encryption_info = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The database dialect information for the backup. - DatabaseDialect database_dialect = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The names of the destination backups being created by copying - // this source backup. The backup names are of the form - // `projects//instances//backups/`. - // Referencing backups may exist in different instances. The existence of - // any referencing backup prevents the backup from being deleted. When the - // copy operation is done (either successfully completed or cancelled or the - // destination backup is deleted), the reference to the backup is removed. - repeated string referencing_backups = 11 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Backup" - } - ]; - - // Output only. The max allowed expiration time of the backup, with - // microseconds granularity. A backup's expiration time can be configured in - // multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or - // copying an existing backup, the expiration time specified must be - // less than `Backup.max_expire_time`. - google.protobuf.Timestamp max_expire_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The request for [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]. -message CreateBackupRequest { - // Required. The name of the instance in which the backup will be - // created. This must be the same instance that contains the database the - // backup will be created from. The backup will be stored in the - // location(s) specified in the instance configuration of this - // instance. Values are of the form - // `projects//instances/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Instance" - } - ]; - - // Required. The id of the backup to be created. The `backup_id` appended to - // `parent` forms the full backup name of the form - // `projects//instances//backups/`. - string backup_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The backup to create. - Backup backup = 3 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The encryption configuration used to encrypt the backup. If this field is - // not specified, the backup will use the same - // encryption configuration as the database by default, namely - // [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] = - // `USE_DATABASE_ENCRYPTION`. - CreateBackupEncryptionConfig encryption_config = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Metadata type for the operation returned by -// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]. -message CreateBackupMetadata { - // The name of the backup being created. - string name = 1 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Backup" - }]; - - // The name of the database the backup is created from. - string database = 2 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - }]; - - // The progress of the - // [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation. - OperationProgress progress = 3; - - // The time at which cancellation of this operation was received. - // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] - // starts asynchronous cancellation on a long-running operation. The server - // makes a best effort to cancel the operation, but success is not guaranteed. - // Clients can use - // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or - // other methods to check whether the cancellation succeeded or whether the - // operation completed despite cancellation. On successful cancellation, - // the operation is not deleted; instead, it becomes an operation with - // an [Operation.error][google.longrunning.Operation.error] value with a - // [google.rpc.Status.code][google.rpc.Status.code] of 1, - // corresponding to `Code.CANCELLED`. - google.protobuf.Timestamp cancel_time = 4; -} - -// The request for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]. -message CopyBackupRequest { - // Required. The name of the destination instance that will contain the backup copy. - // Values are of the form: `projects//instances/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Instance" - } - ]; - - // Required. The id of the backup copy. - // The `backup_id` appended to `parent` forms the full backup_uri of the form - // `projects//instances//backups/`. - string backup_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The source backup to be copied. - // The source backup needs to be in READY state for it to be copied. - // Once CopyBackup is in progress, the source backup cannot be deleted or - // cleaned up on expiration until CopyBackup is finished. - // Values are of the form: - // `projects//instances//backups/`. - string source_backup = 3 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Backup" - } - ]; - - // Required. The expiration time of the backup in microsecond granularity. - // The expiration time must be at least 6 hours and at most 366 days - // from the `create_time` of the source backup. Once the `expire_time` has - // passed, the backup is eligible to be automatically deleted by Cloud Spanner - // to free the resources used by the backup. - google.protobuf.Timestamp expire_time = 4 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The encryption configuration used to encrypt the backup. If this field is - // not specified, the backup will use the same - // encryption configuration as the source backup by default, namely - // [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] = - // `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. - CopyBackupEncryptionConfig encryption_config = 5 [(google.api.field_behavior) = OPTIONAL]; -} - -// Metadata type for the google.longrunning.Operation returned by -// [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]. -message CopyBackupMetadata { - // The name of the backup being created through the copy operation. - // Values are of the form - // `projects//instances//backups/`. - string name = 1 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Backup" - }]; - - // The name of the source backup that is being copied. - // Values are of the form - // `projects//instances//backups/`. - string source_backup = 2 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Backup" - }]; - - // The progress of the - // [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] operation. - OperationProgress progress = 3; - - // The time at which cancellation of CopyBackup operation was received. - // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] - // starts asynchronous cancellation on a long-running operation. The server - // makes a best effort to cancel the operation, but success is not guaranteed. - // Clients can use - // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or - // other methods to check whether the cancellation succeeded or whether the - // operation completed despite cancellation. On successful cancellation, - // the operation is not deleted; instead, it becomes an operation with - // an [Operation.error][google.longrunning.Operation.error] value with a - // [google.rpc.Status.code][google.rpc.Status.code] of 1, - // corresponding to `Code.CANCELLED`. - google.protobuf.Timestamp cancel_time = 4; -} - -// The request for [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup]. -message UpdateBackupRequest { - // Required. The backup to update. `backup.name`, and the fields to be updated - // as specified by `update_mask` are required. Other fields are ignored. - // Update is only supported for the following fields: - // * `backup.expire_time`. - Backup backup = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A mask specifying which fields (e.g. `expire_time`) in the - // Backup resource should be updated. This mask is relative to the Backup - // resource, not to the request message. The field mask must always be - // specified; this prevents any future fields from being erased accidentally - // by clients that do not know about them. - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The request for [GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup]. -message GetBackupRequest { - // Required. Name of the backup. - // Values are of the form - // `projects//instances//backups/`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Backup" - } - ]; -} - -// The request for [DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup]. -message DeleteBackupRequest { - // Required. Name of the backup to delete. - // Values are of the form - // `projects//instances//backups/`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Backup" - } - ]; -} - -// The request for [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]. -message ListBackupsRequest { - // Required. The instance to list backups from. Values are of the - // form `projects//instances/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Instance" - } - ]; - - // An expression that filters the list of returned backups. - // - // A filter expression consists of a field name, a comparison operator, and a - // value for filtering. - // The value must be a string, a number, or a boolean. The comparison operator - // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - // Colon `:` is the contains operator. Filter rules are not case sensitive. - // - // The following fields in the [Backup][google.spanner.admin.database.v1.Backup] are eligible for filtering: - // - // * `name` - // * `database` - // * `state` - // * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - // * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - // * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - // * `size_bytes` - // - // You can combine multiple expressions by enclosing each expression in - // parentheses. By default, expressions are combined with AND logic, but - // you can specify AND, OR, and NOT logic explicitly. - // - // Here are a few examples: - // - // * `name:Howl` - The backup's name contains the string "howl". - // * `database:prod` - // - The database's name contains the string "prod". - // * `state:CREATING` - The backup is pending creation. - // * `state:READY` - The backup is fully created and ready for use. - // * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` - // - The backup name contains the string "howl" and `create_time` - // of the backup is before 2018-03-28T14:50:00Z. - // * `expire_time < \"2018-03-28T14:50:00Z\"` - // - The backup `expire_time` is before 2018-03-28T14:50:00Z. - // * `size_bytes > 10000000000` - The backup's size is greater than 10GB - string filter = 2; - - // Number of backups to be returned in the response. If 0 or - // less, defaults to the server's maximum allowed page size. - int32 page_size = 3; - - // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.admin.database.v1.ListBackupsResponse.next_page_token] from a - // previous [ListBackupsResponse][google.spanner.admin.database.v1.ListBackupsResponse] to the same `parent` and with the same - // `filter`. - string page_token = 4; -} - -// The response for [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]. -message ListBackupsResponse { - // The list of matching backups. Backups returned are ordered by `create_time` - // in descending order, starting from the most recent `create_time`. - repeated Backup backups = 1; - - // `next_page_token` can be sent in a subsequent - // [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups] call to fetch more - // of the matching backups. - string next_page_token = 2; -} - -// The request for -// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]. -message ListBackupOperationsRequest { - // Required. The instance of the backup operations. Values are of - // the form `projects//instances/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Instance" - } - ]; - - // An expression that filters the list of returned backup operations. - // - // A filter expression consists of a field name, a - // comparison operator, and a value for filtering. - // The value must be a string, a number, or a boolean. The comparison operator - // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - // Colon `:` is the contains operator. Filter rules are not case sensitive. - // - // The following fields in the [operation][google.longrunning.Operation] - // are eligible for filtering: - // - // * `name` - The name of the long-running operation - // * `done` - False if the operation is in progress, else true. - // * `metadata.@type` - the type of metadata. For example, the type string - // for [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] is - // `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. - // * `metadata.` - any field in metadata.value. - // `metadata.@type` must be specified first if filtering on metadata - // fields. - // * `error` - Error associated with the long-running operation. - // * `response.@type` - the type of response. - // * `response.` - any field in response.value. - // - // You can combine multiple expressions by enclosing each expression in - // parentheses. By default, expressions are combined with AND logic, but - // you can specify AND, OR, and NOT logic explicitly. - // - // Here are a few examples: - // - // * `done:true` - The operation is complete. - // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - // `metadata.database:prod` - Returns operations where: - // * The operation's metadata type is [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. - // * The database the backup was taken from has a name containing the - // string "prod". - // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - // `(metadata.name:howl) AND` \ - // `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ - // `(error:*)` - Returns operations where: - // * The operation's metadata type is [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. - // * The backup name contains the string "howl". - // * The operation started before 2018-03-28T14:50:00Z. - // * The operation resulted in an error. - // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ - // `(metadata.source_backup:test) AND` \ - // `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ - // `(error:*)` - Returns operations where: - // * The operation's metadata type is [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. - // * The source backup of the copied backup name contains the string - // "test". - // * The operation started before 2022-01-18T14:50:00Z. - // * The operation resulted in an error. - // * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - // `(metadata.database:test_db)) OR` \ - // `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) - // AND` \ - // `(metadata.source_backup:test_bkp)) AND` \ - // `(error:*)` - Returns operations where: - // * The operation's metadata matches either of criteria: - // * The operation's metadata type is [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] AND the - // database the backup was taken from has name containing string - // "test_db" - // * The operation's metadata type is [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata] AND the - // backup the backup was copied from has name containing string - // "test_bkp" - // * The operation resulted in an error. - string filter = 2; - - // Number of operations to be returned in the response. If 0 or - // less, defaults to the server's maximum allowed page size. - int32 page_size = 3; - - // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token] - // from a previous [ListBackupOperationsResponse][google.spanner.admin.database.v1.ListBackupOperationsResponse] to the - // same `parent` and with the same `filter`. - string page_token = 4; -} - -// The response for -// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]. -message ListBackupOperationsResponse { - // The list of matching backup [long-running - // operations][google.longrunning.Operation]. Each operation's name will be - // prefixed by the backup's name. The operation's - // [metadata][google.longrunning.Operation.metadata] field type - // `metadata.type_url` describes the type of the metadata. Operations returned - // include those that are pending or have completed/failed/canceled within the - // last 7 days. Operations returned are ordered by - // `operation.metadata.value.progress.start_time` in descending order starting - // from the most recently started operation. - repeated google.longrunning.Operation operations = 1; - - // `next_page_token` can be sent in a subsequent - // [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations] - // call to fetch more of the matching metadata. - string next_page_token = 2; -} - -// Information about a backup. -message BackupInfo { - // Name of the backup. - string backup = 1 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Backup" - }]; - - // The backup contains an externally consistent copy of `source_database` at - // the timestamp specified by `version_time`. If the - // [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] request did not specify - // `version_time`, the `version_time` of the backup is equivalent to the - // `create_time`. - google.protobuf.Timestamp version_time = 4; - - // The time the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] request was - // received. - google.protobuf.Timestamp create_time = 2; - - // Name of the database the backup was created from. - string source_database = 3 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - }]; -} - -// Encryption configuration for the backup to create. -message CreateBackupEncryptionConfig { - // Encryption types for the backup. - enum EncryptionType { - // Unspecified. Do not use. - ENCRYPTION_TYPE_UNSPECIFIED = 0; - - // Use the same encryption configuration as the database. This is the - // default option when - // [encryption_config][google.spanner.admin.database.v1.CreateBackupEncryptionConfig] is empty. - // For example, if the database is using `Customer_Managed_Encryption`, the - // backup will be using the same Cloud KMS key as the database. - USE_DATABASE_ENCRYPTION = 1; - - // Use Google default encryption. - GOOGLE_DEFAULT_ENCRYPTION = 2; - - // Use customer managed encryption. If specified, `kms_key_name` - // must contain a valid Cloud KMS key. - CUSTOMER_MANAGED_ENCRYPTION = 3; - } - - // Required. The encryption type of the backup. - EncryptionType encryption_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The Cloud KMS key that will be used to protect the backup. - // This field should be set only when - // [encryption_type][google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type] is - // `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form - // `projects//locations//keyRings//cryptoKeys/`. - string kms_key_name = 2 [ - (google.api.field_behavior) = OPTIONAL, - (google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - } - ]; -} - -// Encryption configuration for the copied backup. -message CopyBackupEncryptionConfig { - // Encryption types for the backup. - enum EncryptionType { - // Unspecified. Do not use. - ENCRYPTION_TYPE_UNSPECIFIED = 0; - - // This is the default option for [CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup] - // when [encryption_config][google.spanner.admin.database.v1.CopyBackupEncryptionConfig] is not specified. - // For example, if the source backup is using `Customer_Managed_Encryption`, - // the backup will be using the same Cloud KMS key as the source backup. - USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; - - // Use Google default encryption. - GOOGLE_DEFAULT_ENCRYPTION = 2; - - // Use customer managed encryption. If specified, `kms_key_name` - // must contain a valid Cloud KMS key. - CUSTOMER_MANAGED_ENCRYPTION = 3; - } - - // Required. The encryption type of the backup. - EncryptionType encryption_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The Cloud KMS key that will be used to protect the backup. - // This field should be set only when - // [encryption_type][google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type] is - // `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form - // `projects//locations//keyRings//cryptoKeys/`. - string kms_key_name = 2 [ - (google.api.field_behavior) = OPTIONAL, - (google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - } - ]; -} diff --git a/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/common.proto b/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/common.proto deleted file mode 100644 index 720ebb95d..000000000 --- a/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/common.proto +++ /dev/null @@ -1,112 +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.spanner.admin.database.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.spanner.admin.database.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; -option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1"; -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: "cloudkms.googleapis.com/CryptoKeyVersion" - pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}" -}; - -// Encapsulates progress related information for a Cloud Spanner long -// running operation. -message OperationProgress { - // Percent completion of the operation. - // Values are between 0 and 100 inclusive. - int32 progress_percent = 1; - - // Time the request was received. - google.protobuf.Timestamp start_time = 2; - - // If set, the time at which this operation failed or was completed - // successfully. - google.protobuf.Timestamp end_time = 3; -} - -// Encryption configuration for a Cloud Spanner database. -message EncryptionConfig { - // The Cloud KMS key to be used for encrypting and decrypting - // the database. Values are of the form - // `projects//locations//keyRings//cryptoKeys/`. - string kms_key_name = 2 [(google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - }]; -} - -// Encryption information for a Cloud Spanner database or backup. -message EncryptionInfo { - // Possible encryption types. - enum Type { - // Encryption type was not specified, though data at rest remains encrypted. - TYPE_UNSPECIFIED = 0; - - // The data is encrypted at rest with a key that is - // fully managed by Google. No key version or status will be populated. - // This is the default state. - GOOGLE_DEFAULT_ENCRYPTION = 1; - - // The data is encrypted at rest with a key that is - // managed by the customer. The active version of the key. `kms_key_version` - // will be populated, and `encryption_status` may be populated. - CUSTOMER_MANAGED_ENCRYPTION = 2; - } - - // Output only. The type of encryption. - Type encryption_type = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If present, the status of a recent encrypt/decrypt call on underlying data - // for this database or backup. Regardless of status, data is always encrypted - // at rest. - google.rpc.Status encryption_status = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A Cloud KMS key version that is being used to protect the database or - // backup. - string kms_key_version = 2 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKeyVersion" - } - ]; -} - -// Indicates the dialect type of a database. -enum DatabaseDialect { - // Default value. This value will create a database with the - // GOOGLE_STANDARD_SQL dialect. - DATABASE_DIALECT_UNSPECIFIED = 0; - - // Google standard SQL. - GOOGLE_STANDARD_SQL = 1; - - // PostgreSQL supported SQL. - POSTGRESQL = 2; -} diff --git a/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/spanner_database_admin.proto b/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/spanner_database_admin.proto deleted file mode 100644 index 91489ae4b..000000000 --- a/owl-bot-staging/admin/database/v1/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +++ /dev/null @@ -1,930 +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.spanner.admin.database.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; -import "google/spanner/admin/database/v1/backup.proto"; -import "google/spanner/admin/database/v1/common.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database"; -option java_multiple_files = true; -option java_outer_classname = "SpannerDatabaseAdminProto"; -option java_package = "com.google.spanner.admin.database.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; -option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1"; -option (google.api.resource_definition) = { - type: "spanner.googleapis.com/Instance" - pattern: "projects/{project}/instances/{instance}" -}; - -// Cloud Spanner Database Admin API -// -// The Cloud Spanner Database Admin API can be used to: -// * create, drop, and list databases -// * update the schema of pre-existing databases -// * create, delete and list backups for a database -// * restore a database from an existing backup -service DatabaseAdmin { - option (google.api.default_host) = "spanner.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/spanner.admin"; - - // Lists Cloud Spanner databases. - rpc ListDatabases(ListDatabasesRequest) returns (ListDatabasesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/instances/*}/databases" - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a new Cloud Spanner database and starts to prepare it for serving. - // The returned [long-running operation][google.longrunning.Operation] will - // have a name of the format `/operations/` and - // can be used to track preparation of the database. The - // [metadata][google.longrunning.Operation.metadata] field type is - // [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The - // [response][google.longrunning.Operation.response] field type is - // [Database][google.spanner.admin.database.v1.Database], if successful. - rpc CreateDatabase(CreateDatabaseRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/instances/*}/databases" - body: "*" - }; - option (google.api.method_signature) = "parent,create_statement"; - option (google.longrunning.operation_info) = { - response_type: "google.spanner.admin.database.v1.Database" - metadata_type: "google.spanner.admin.database.v1.CreateDatabaseMetadata" - }; - } - - // Gets the state of a Cloud Spanner database. - rpc GetDatabase(GetDatabaseRequest) returns (Database) { - option (google.api.http) = { - get: "/v1/{name=projects/*/instances/*/databases/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the schema of a Cloud Spanner database by - // creating/altering/dropping tables, columns, indexes, etc. The returned - // [long-running operation][google.longrunning.Operation] will have a name of - // the format `/operations/` and can be used to - // track execution of the schema change(s). The - // [metadata][google.longrunning.Operation.metadata] field type is - // [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. - rpc UpdateDatabaseDdl(UpdateDatabaseDdlRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{database=projects/*/instances/*/databases/*}/ddl" - body: "*" - }; - option (google.api.method_signature) = "database,statements"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata" - }; - } - - // Drops (aka deletes) a Cloud Spanner database. - // Completed backups for the database will be retained according to their - // `expire_time`. - // Note: Cloud Spanner might continue to accept requests for a few seconds - // after the database has been deleted. - rpc DropDatabase(DropDatabaseRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{database=projects/*/instances/*/databases/*}" - }; - option (google.api.method_signature) = "database"; - } - - // Returns the schema of a Cloud Spanner database as a list of formatted - // DDL statements. This method does not show pending schema updates, those may - // be queried using the [Operations][google.longrunning.Operations] API. - rpc GetDatabaseDdl(GetDatabaseDdlRequest) returns (GetDatabaseDdlResponse) { - option (google.api.http) = { - get: "/v1/{database=projects/*/instances/*/databases/*}/ddl" - }; - option (google.api.method_signature) = "database"; - } - - // Sets the access control policy on a database or backup resource. - // Replaces any existing policy. - // - // Authorization requires `spanner.databases.setIamPolicy` - // permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. - // For backups, authorization requires `spanner.backups.setIamPolicy` - // permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/instances/*/backups/*}:setIamPolicy" - body: "*" - } - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Gets the access control policy for a database or backup resource. - // Returns an empty policy if a database or backup exists but does not have a - // policy set. - // - // Authorization requires `spanner.databases.getIamPolicy` permission on - // [resource][google.iam.v1.GetIamPolicyRequest.resource]. - // For backups, authorization requires `spanner.backups.getIamPolicy` - // permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/instances/*/backups/*}:getIamPolicy" - body: "*" - } - }; - option (google.api.method_signature) = "resource"; - } - - // Returns permissions that the caller has on the specified database or backup - // resource. - // - // Attempting this RPC on a non-existent Cloud Spanner database will - // result in a NOT_FOUND error if the user has - // `spanner.databases.list` permission on the containing Cloud - // Spanner instance. Otherwise returns an empty set of permissions. - // Calling this method on a backup that does not exist will - // result in a NOT_FOUND error if the user has - // `spanner.backups.list` permission on the containing instance. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/instances/*/backups/*}:testIamPermissions" - body: "*" - } - additional_bindings { - post: "/v1/{resource=projects/*/instances/*/databases/*/databaseRoles/*}:testIamPermissions" - body: "*" - } - }; - option (google.api.method_signature) = "resource,permissions"; - } - - // Starts creating a new Cloud Spanner Backup. - // The returned backup [long-running operation][google.longrunning.Operation] - // will have a name of the format - // `projects//instances//backups//operations/` - // and can be used to track creation of the backup. The - // [metadata][google.longrunning.Operation.metadata] field type is - // [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The - // [response][google.longrunning.Operation.response] field type is - // [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the - // creation and delete the backup. - // There can be only one pending backup creation per database. Backup creation - // of different databases can run concurrently. - rpc CreateBackup(CreateBackupRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/instances/*}/backups" - body: "backup" - }; - option (google.api.method_signature) = "parent,backup,backup_id"; - option (google.longrunning.operation_info) = { - response_type: "google.spanner.admin.database.v1.Backup" - metadata_type: "google.spanner.admin.database.v1.CreateBackupMetadata" - }; - } - - // Starts copying a Cloud Spanner Backup. - // The returned backup [long-running operation][google.longrunning.Operation] - // will have a name of the format - // `projects//instances//backups//operations/` - // and can be used to track copying of the backup. The operation is associated - // with the destination backup. - // The [metadata][google.longrunning.Operation.metadata] field type is - // [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. - // The [response][google.longrunning.Operation.response] field type is - // [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the - // copying and delete the backup. - // Concurrent CopyBackup requests can run on the same source backup. - rpc CopyBackup(CopyBackupRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/instances/*}/backups:copy" - body: "*" - }; - option (google.api.method_signature) = "parent,backup_id,source_backup,expire_time"; - option (google.longrunning.operation_info) = { - response_type: "google.spanner.admin.database.v1.Backup" - metadata_type: "google.spanner.admin.database.v1.CopyBackupMetadata" - }; - } - - // Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - rpc GetBackup(GetBackupRequest) returns (Backup) { - option (google.api.http) = { - get: "/v1/{name=projects/*/instances/*/backups/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - rpc UpdateBackup(UpdateBackupRequest) returns (Backup) { - option (google.api.http) = { - patch: "/v1/{backup.name=projects/*/instances/*/backups/*}" - body: "backup" - }; - option (google.api.method_signature) = "backup,update_mask"; - } - - // Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - rpc DeleteBackup(DeleteBackupRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/instances/*/backups/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists completed and pending backups. - // Backups returned are ordered by `create_time` in descending order, - // starting from the most recent `create_time`. - rpc ListBackups(ListBackupsRequest) returns (ListBackupsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/instances/*}/backups" - }; - option (google.api.method_signature) = "parent"; - } - - // Create a new database by restoring from a completed backup. The new - // database must be in the same project and in an instance with the same - // instance configuration as the instance containing - // the backup. The returned database [long-running - // operation][google.longrunning.Operation] has a name of the format - // `projects//instances//databases//operations/`, - // and can be used to track the progress of the operation, and to cancel it. - // The [metadata][google.longrunning.Operation.metadata] field type is - // [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. - // The [response][google.longrunning.Operation.response] type - // is [Database][google.spanner.admin.database.v1.Database], if - // successful. Cancelling the returned operation will stop the restore and - // delete the database. - // There can be only one database being restored into an instance at a time. - // Once the restore operation completes, a new restore operation can be - // initiated, without waiting for the optimize operation associated with the - // first restore to complete. - rpc RestoreDatabase(RestoreDatabaseRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/instances/*}/databases:restore" - body: "*" - }; - option (google.api.method_signature) = "parent,database_id,backup"; - option (google.longrunning.operation_info) = { - response_type: "google.spanner.admin.database.v1.Database" - metadata_type: "google.spanner.admin.database.v1.RestoreDatabaseMetadata" - }; - } - - // Lists database [longrunning-operations][google.longrunning.Operation]. - // A database operation has a name of the form - // `projects//instances//databases//operations/`. - // The long-running operation - // [metadata][google.longrunning.Operation.metadata] field type - // `metadata.type_url` describes the type of the metadata. Operations returned - // include those that have completed/failed/canceled within the last 7 days, - // and pending operations. - rpc ListDatabaseOperations(ListDatabaseOperationsRequest) returns (ListDatabaseOperationsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/instances/*}/databaseOperations" - }; - option (google.api.method_signature) = "parent"; - } - - // Lists the backup [long-running operations][google.longrunning.Operation] in - // the given instance. A backup operation has a name of the form - // `projects//instances//backups//operations/`. - // The long-running operation - // [metadata][google.longrunning.Operation.metadata] field type - // `metadata.type_url` describes the type of the metadata. Operations returned - // include those that have completed/failed/canceled within the last 7 days, - // and pending operations. Operations returned are ordered by - // `operation.metadata.value.progress.start_time` in descending order starting - // from the most recently started operation. - rpc ListBackupOperations(ListBackupOperationsRequest) returns (ListBackupOperationsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/instances/*}/backupOperations" - }; - option (google.api.method_signature) = "parent"; - } - - // Lists Cloud Spanner database roles. - rpc ListDatabaseRoles(ListDatabaseRolesRequest) returns (ListDatabaseRolesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/instances/*/databases/*}/databaseRoles" - }; - option (google.api.method_signature) = "parent"; - } -} - -// Information about the database restore. -message RestoreInfo { - // The type of the restore source. - RestoreSourceType source_type = 1; - - // Information about the source used to restore the database. - oneof source_info { - // Information about the backup used to restore the database. The backup - // may no longer exist. - BackupInfo backup_info = 2; - } -} - -// A Cloud Spanner database. -message Database { - option (google.api.resource) = { - type: "spanner.googleapis.com/Database" - pattern: "projects/{project}/instances/{instance}/databases/{database}" - }; - - // Indicates the current state of the database. - enum State { - // Not specified. - STATE_UNSPECIFIED = 0; - - // The database is still being created. Operations on the database may fail - // with `FAILED_PRECONDITION` in this state. - CREATING = 1; - - // The database is fully created and ready for use. - READY = 2; - - // The database is fully created and ready for use, but is still - // being optimized for performance and cannot handle full load. - // - // In this state, the database still references the backup - // it was restore from, preventing the backup - // from being deleted. When optimizations are complete, the full performance - // of the database will be restored, and the database will transition to - // `READY` state. - READY_OPTIMIZING = 3; - } - - // Required. The name of the database. Values are of the form - // `projects//instances//databases/`, - // where `` is as specified in the `CREATE DATABASE` - // statement. This name can be passed to other API methods to - // identify the database. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Output only. The current database state. - State state = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If exists, the time at which the database creation started. - google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Applicable only for restored databases. Contains information - // about the restore source. - RestoreInfo restore_info = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For databases that are using customer managed encryption, this - // field contains the encryption configuration for the database. - // For databases that are using Google default or other types of encryption, - // this field is empty. - EncryptionConfig encryption_config = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. For databases that are using customer managed encryption, this - // field contains the encryption information for the database, such as - // encryption state and the Cloud KMS key versions that are in use. - // - // For databases that are using Google default or other types of encryption, - // this field is empty. - // - // This field is propagated lazily from the backend. There might be a delay - // from when a key version is being used and when it appears in this field. - repeated EncryptionInfo encryption_info = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The period in which Cloud Spanner retains all versions of data - // for the database. This is the same as the value of version_retention_period - // database option set using - // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]. Defaults to 1 hour, - // if not set. - string version_retention_period = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Earliest timestamp at which older versions of the data can be - // read. This value is continuously updated by Cloud Spanner and becomes stale - // the moment it is queried. If you are using this value to recover data, make - // sure to account for the time from the moment when the value is queried to - // the moment when you initiate the recovery. - google.protobuf.Timestamp earliest_version_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The read-write region which contains the database's leader - // replicas. - // - // This is the same as the value of default_leader - // database option set using DatabaseAdmin.CreateDatabase or - // DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty. - string default_leader = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The dialect of the Cloud Spanner Database. - DatabaseDialect database_dialect = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The request for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]. -message ListDatabasesRequest { - // Required. The instance whose databases should be listed. - // Values are of the form `projects//instances/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Instance" - } - ]; - - // Number of databases to be returned in the response. If 0 or less, - // defaults to the server's maximum allowed page size. - int32 page_size = 3; - - // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] from a - // previous [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse]. - string page_token = 4; -} - -// The response for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]. -message ListDatabasesResponse { - // Databases that matched the request. - repeated Database databases = 1; - - // `next_page_token` can be sent in a subsequent - // [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] call to fetch more - // of the matching databases. - string next_page_token = 2; -} - -// The request for [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase]. -message CreateDatabaseRequest { - // Required. The name of the instance that will serve the new database. - // Values are of the form `projects//instances/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Instance" - } - ]; - - // Required. A `CREATE DATABASE` statement, which specifies the ID of the - // new database. The database ID must conform to the regular expression - // `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length. - // If the database ID is a reserved word or if it contains a hyphen, the - // database ID must be enclosed in backticks (`` ` ``). - string create_statement = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. A list of DDL statements to run inside the newly created - // database. Statements can create tables, indexes, etc. These - // statements execute atomically with the creation of the database: - // if there is an error in any statement, the database is not created. - repeated string extra_statements = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The encryption configuration for the database. If this field is not - // specified, Cloud Spanner will encrypt/decrypt all data at rest using - // Google default encryption. - EncryptionConfig encryption_config = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The dialect of the Cloud Spanner Database. - DatabaseDialect database_dialect = 5 [(google.api.field_behavior) = OPTIONAL]; -} - -// Metadata type for the operation returned by -// [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase]. -message CreateDatabaseMetadata { - // The database being created. - string database = 1 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - }]; -} - -// The request for [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase]. -message GetDatabaseRequest { - // Required. The name of the requested database. Values are of the form - // `projects//instances//databases/`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - } - ]; -} - -// Enqueues the given DDL statements to be applied, in order but not -// necessarily all at once, to the database schema at some point (or -// points) in the future. The server checks that the statements -// are executable (syntactically valid, name tables that exist, etc.) -// before enqueueing them, but they may still fail upon -// later execution (e.g., if a statement from another batch of -// statements is applied first and it conflicts in some way, or if -// there is some data-related problem like a `NULL` value in a column to -// which `NOT NULL` would be added). If a statement fails, all -// subsequent statements in the batch are automatically cancelled. -// -// Each batch of statements is assigned a name which can be used with -// the [Operations][google.longrunning.Operations] API to monitor -// progress. See the -// [operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id] field for more -// details. -message UpdateDatabaseDdlRequest { - // Required. The database to update. - string database = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - } - ]; - - // Required. DDL statements to be applied to the database. - repeated string statements = 2 [(google.api.field_behavior) = REQUIRED]; - - // If empty, the new update request is assigned an - // automatically-generated operation ID. Otherwise, `operation_id` - // is used to construct the name of the resulting - // [Operation][google.longrunning.Operation]. - // - // Specifying an explicit operation ID simplifies determining - // whether the statements were executed in the event that the - // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] call is replayed, - // or the return value is otherwise lost: the [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] and - // `operation_id` fields can be combined to form the - // [name][google.longrunning.Operation.name] of the resulting - // [longrunning.Operation][google.longrunning.Operation]: `/operations/`. - // - // `operation_id` should be unique within the database, and must be - // a valid identifier: `[a-z][a-z0-9_]*`. Note that - // automatically-generated operation IDs always begin with an - // underscore. If the named operation already exists, - // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] returns - // `ALREADY_EXISTS`. - string operation_id = 3; -} - -// Metadata type for the operation returned by -// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]. -message UpdateDatabaseDdlMetadata { - // The database being modified. - string database = 1 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - }]; - - // For an update this list contains all the statements. For an - // individual statement, this list contains only that statement. - repeated string statements = 2; - - // Reports the commit timestamps of all statements that have - // succeeded so far, where `commit_timestamps[i]` is the commit - // timestamp for the statement `statements[i]`. - repeated google.protobuf.Timestamp commit_timestamps = 3; - - // Output only. When true, indicates that the operation is throttled e.g - // due to resource constraints. When resources become available the operation - // will resume and this field will be false again. - bool throttled = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The progress of the - // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] operations. - // Currently, only index creation statements will have a continuously - // updating progress. - // For non-index creation statements, `progress[i]` will have start time - // and end time populated with commit timestamp of operation, - // as well as a progress of 100% once the operation has completed. - // `progress[i]` is the operation progress for `statements[i]`. - repeated OperationProgress progress = 5; -} - -// The request for [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase]. -message DropDatabaseRequest { - // Required. The database to be dropped. - string database = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - } - ]; -} - -// The request for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl]. -message GetDatabaseDdlRequest { - // Required. The database whose schema we wish to get. - // Values are of the form - // `projects//instances//databases/` - string database = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - } - ]; -} - -// The response for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl]. -message GetDatabaseDdlResponse { - // A list of formatted DDL statements defining the schema of the database - // specified in the request. - repeated string statements = 1; -} - -// The request for -// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]. -message ListDatabaseOperationsRequest { - // Required. The instance of the database operations. - // Values are of the form `projects//instances/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Instance" - } - ]; - - // An expression that filters the list of returned operations. - // - // A filter expression consists of a field name, a - // comparison operator, and a value for filtering. - // The value must be a string, a number, or a boolean. The comparison operator - // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - // Colon `:` is the contains operator. Filter rules are not case sensitive. - // - // The following fields in the [Operation][google.longrunning.Operation] - // are eligible for filtering: - // - // * `name` - The name of the long-running operation - // * `done` - False if the operation is in progress, else true. - // * `metadata.@type` - the type of metadata. For example, the type string - // for [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata] is - // `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. - // * `metadata.` - any field in metadata.value. - // `metadata.@type` must be specified first, if filtering on metadata - // fields. - // * `error` - Error associated with the long-running operation. - // * `response.@type` - the type of response. - // * `response.` - any field in response.value. - // - // You can combine multiple expressions by enclosing each expression in - // parentheses. By default, expressions are combined with AND logic. However, - // you can specify AND, OR, and NOT logic explicitly. - // - // Here are a few examples: - // - // * `done:true` - The operation is complete. - // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ - // `(metadata.source_type:BACKUP) AND` \ - // `(metadata.backup_info.backup:backup_howl) AND` \ - // `(metadata.name:restored_howl) AND` \ - // `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ - // `(error:*)` - Return operations where: - // * The operation's metadata type is [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. - // * The database is restored from a backup. - // * The backup name contains "backup_howl". - // * The restored database's name contains "restored_howl". - // * The operation started before 2018-03-28T14:50:00Z. - // * The operation resulted in an error. - string filter = 2; - - // Number of operations to be returned in the response. If 0 or - // less, defaults to the server's maximum allowed page size. - int32 page_size = 3; - - // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token] - // from a previous [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse] to the - // same `parent` and with the same `filter`. - string page_token = 4; -} - -// The response for -// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]. -message ListDatabaseOperationsResponse { - // The list of matching database [long-running - // operations][google.longrunning.Operation]. Each operation's name will be - // prefixed by the database's name. The operation's - // [metadata][google.longrunning.Operation.metadata] field type - // `metadata.type_url` describes the type of the metadata. - repeated google.longrunning.Operation operations = 1; - - // `next_page_token` can be sent in a subsequent - // [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations] - // call to fetch more of the matching metadata. - string next_page_token = 2; -} - -// The request for -// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]. -message RestoreDatabaseRequest { - // Required. The name of the instance in which to create the - // restored database. This instance must be in the same project and - // have the same instance configuration as the instance containing - // the source backup. Values are of the form - // `projects//instances/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Instance" - } - ]; - - // Required. The id of the database to create and restore to. This - // database must not already exist. The `database_id` appended to - // `parent` forms the full database name of the form - // `projects//instances//databases/`. - string database_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The source from which to restore. - oneof source { - // Name of the backup from which to restore. Values are of the form - // `projects//instances//backups/`. - string backup = 3 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Backup" - }]; - } - - // Optional. An encryption configuration describing the encryption type and key - // resources in Cloud KMS used to encrypt/decrypt the database to restore to. - // If this field is not specified, the restored database will use - // the same encryption configuration as the backup by default, namely - // [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] = - // `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. - RestoreDatabaseEncryptionConfig encryption_config = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Encryption configuration for the restored database. -message RestoreDatabaseEncryptionConfig { - // Encryption types for the database to be restored. - enum EncryptionType { - // Unspecified. Do not use. - ENCRYPTION_TYPE_UNSPECIFIED = 0; - - // This is the default option when - // [encryption_config][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig] is not specified. - USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION = 1; - - // Use Google default encryption. - GOOGLE_DEFAULT_ENCRYPTION = 2; - - // Use customer managed encryption. If specified, `kms_key_name` must - // must contain a valid Cloud KMS key. - CUSTOMER_MANAGED_ENCRYPTION = 3; - } - - // Required. The encryption type of the restored database. - EncryptionType encryption_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The Cloud KMS key that will be used to encrypt/decrypt the restored - // database. This field should be set only when - // [encryption_type][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type] is - // `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form - // `projects//locations//keyRings//cryptoKeys/`. - string kms_key_name = 2 [ - (google.api.field_behavior) = OPTIONAL, - (google.api.resource_reference) = { - type: "cloudkms.googleapis.com/CryptoKey" - } - ]; -} - -// Metadata type for the long-running operation returned by -// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]. -message RestoreDatabaseMetadata { - // Name of the database being created and restored to. - string name = 1 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - }]; - - // The type of the restore source. - RestoreSourceType source_type = 2; - - // Information about the source used to restore the database, as specified by - // `source` in [RestoreDatabaseRequest][google.spanner.admin.database.v1.RestoreDatabaseRequest]. - oneof source_info { - // Information about the backup used to restore the database. - BackupInfo backup_info = 3; - } - - // The progress of the - // [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase] - // operation. - OperationProgress progress = 4; - - // The time at which cancellation of this operation was received. - // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] - // starts asynchronous cancellation on a long-running operation. The server - // makes a best effort to cancel the operation, but success is not guaranteed. - // Clients can use - // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or - // other methods to check whether the cancellation succeeded or whether the - // operation completed despite cancellation. On successful cancellation, - // the operation is not deleted; instead, it becomes an operation with - // an [Operation.error][google.longrunning.Operation.error] value with a - // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`. - google.protobuf.Timestamp cancel_time = 5; - - // If exists, the name of the long-running operation that will be used to - // track the post-restore optimization process to optimize the performance of - // the restored database, and remove the dependency on the restore source. - // The name is of the form - // `projects//instances//databases//operations/` - // where the is the name of database being created and restored to. - // The metadata type of the long-running operation is - // [OptimizeRestoredDatabaseMetadata][google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]. This long-running operation will be - // automatically created by the system after the RestoreDatabase long-running - // operation completes successfully. This operation will not be created if the - // restore was not successful. - string optimize_database_operation_name = 6; -} - -// Metadata type for the long-running operation used to track the progress -// of optimizations performed on a newly restored database. This long-running -// operation is automatically created by the system after the successful -// completion of a database restore, and cannot be cancelled. -message OptimizeRestoredDatabaseMetadata { - // Name of the restored database being optimized. - string name = 1 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - }]; - - // The progress of the post-restore optimizations. - OperationProgress progress = 2; -} - -// Indicates the type of the restore source. -enum RestoreSourceType { - // No restore associated. - TYPE_UNSPECIFIED = 0; - - // A backup was used as the source of the restore. - BACKUP = 1; -} - -// A Cloud Spanner database role. -message DatabaseRole { - option (google.api.resource) = { - type: "spanner.googleapis.com/DatabaseRole" - pattern: "projects/{project}/instances/{instance}/databases/{database}/databaseRoles/{role}" - }; - - // Required. The name of the database role. Values are of the form - // `projects//instances//databases//databaseRoles/ - // {role}`, where `` is as specified in the `CREATE ROLE` - // DDL statement. This name can be passed to Get/Set IAMPolicy methods to - // identify the database role. - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The request for [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles]. -message ListDatabaseRolesRequest { - // Required. The database whose roles should be listed. - // Values are of the form - // `projects//instances//databases//databaseRoles`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - } - ]; - - // Number of database roles to be returned in the response. If 0 or less, - // defaults to the server's maximum allowed page size. - int32 page_size = 2; - - // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token] from a - // previous [ListDatabaseRolesResponse][google.spanner.admin.database.v1.ListDatabaseRolesResponse]. - string page_token = 3; -} - -// The response for [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles]. -message ListDatabaseRolesResponse { - // Database roles that matched the request. - repeated DatabaseRole database_roles = 1; - - // `next_page_token` can be sent in a subsequent - // [ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles] - // call to fetch more of the matching roles. - string next_page_token = 2; -} diff --git a/owl-bot-staging/admin/database/v1/src/index.ts b/owl-bot-staging/admin/database/v1/src/index.ts deleted file mode 100644 index 8426cae7a..000000000 --- a/owl-bot-staging/admin/database/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const DatabaseAdminClient = v1.DatabaseAdminClient; -type DatabaseAdminClient = v1.DatabaseAdminClient; -export {v1, DatabaseAdminClient}; -export default {v1, DatabaseAdminClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/admin/database/v1/src/v1/database_admin_client.ts b/owl-bot-staging/admin/database/v1/src/v1/database_admin_client.ts deleted file mode 100644 index 95fe0cb8b..000000000 --- a/owl-bot-staging/admin/database/v1/src/v1/database_admin_client.ts +++ /dev/null @@ -1,3557 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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/v1/database_admin_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './database_admin_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Spanner Database Admin API - * - * The Cloud Spanner Database Admin API can be used to: - * * create, drop, and list databases - * * update the schema of pre-existing databases - * * create, delete and list backups for a database - * * restore a database from an existing backup - * @class - * @memberof v1 - */ -export class DatabaseAdminClient { - 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; - databaseAdminStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DatabaseAdminClient. - * - * @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 DatabaseAdminClient({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 DatabaseAdminClient; - 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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 = { - backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}/backups/{backup}' - ), - cryptoKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}' - ), - databasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}/databases/{database}' - ), - databaseRolePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}/databases/{database}/databaseRoles/{role}' - ), - instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}' - ), - }; - - // 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 = { - listDatabases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'databases'), - listBackups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backups'), - listDatabaseOperations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'operations'), - listBackupOperations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'operations'), - listDatabaseRoles: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'databaseRoles') - }; - - 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.CancelOperation',post: '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel',additional_bindings: [{post: '/v1/{name=projects/*/instances/*/operations/*}:cancel',},{post: '/v1/{name=projects/*/instances/*/backups/*/operations/*}:cancel',},{post: '/v1/{name=projects/*/instanceConfigs/*/operations/*}:cancel',}], - },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/instances/*/databases/*/operations/*}',additional_bindings: [{delete: '/v1/{name=projects/*/instances/*/operations/*}',},{delete: '/v1/{name=projects/*/instances/*/backups/*/operations/*}',},{delete: '/v1/{name=projects/*/instanceConfigs/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/instances/*/databases/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/instances/*/operations/*}',},{get: '/v1/{name=projects/*/instances/*/backups/*/operations/*}',},{get: '/v1/{name=projects/*/instanceConfigs/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/instances/*/databases/*/operations}',additional_bindings: [{get: '/v1/{name=projects/*/instances/*/operations}',},{get: '/v1/{name=projects/*/instances/*/backups/*/operations}',},{get: '/v1/{name=projects/*/instanceConfigs/*/operations}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createDatabaseResponse = protoFilesRoot.lookup( - '.google.spanner.admin.database.v1.Database') as gax.protobuf.Type; - const createDatabaseMetadata = protoFilesRoot.lookup( - '.google.spanner.admin.database.v1.CreateDatabaseMetadata') as gax.protobuf.Type; - const updateDatabaseDdlResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const updateDatabaseDdlMetadata = protoFilesRoot.lookup( - '.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata') as gax.protobuf.Type; - const createBackupResponse = protoFilesRoot.lookup( - '.google.spanner.admin.database.v1.Backup') as gax.protobuf.Type; - const createBackupMetadata = protoFilesRoot.lookup( - '.google.spanner.admin.database.v1.CreateBackupMetadata') as gax.protobuf.Type; - const copyBackupResponse = protoFilesRoot.lookup( - '.google.spanner.admin.database.v1.Backup') as gax.protobuf.Type; - const copyBackupMetadata = protoFilesRoot.lookup( - '.google.spanner.admin.database.v1.CopyBackupMetadata') as gax.protobuf.Type; - const restoreDatabaseResponse = protoFilesRoot.lookup( - '.google.spanner.admin.database.v1.Database') as gax.protobuf.Type; - const restoreDatabaseMetadata = protoFilesRoot.lookup( - '.google.spanner.admin.database.v1.RestoreDatabaseMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createDatabase: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createDatabaseResponse.decode.bind(createDatabaseResponse), - createDatabaseMetadata.decode.bind(createDatabaseMetadata)), - updateDatabaseDdl: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateDatabaseDdlResponse.decode.bind(updateDatabaseDdlResponse), - updateDatabaseDdlMetadata.decode.bind(updateDatabaseDdlMetadata)), - createBackup: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createBackupResponse.decode.bind(createBackupResponse), - createBackupMetadata.decode.bind(createBackupMetadata)), - copyBackup: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - copyBackupResponse.decode.bind(copyBackupResponse), - copyBackupMetadata.decode.bind(copyBackupMetadata)), - restoreDatabase: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - restoreDatabaseResponse.decode.bind(restoreDatabaseResponse), - restoreDatabaseMetadata.decode.bind(restoreDatabaseMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.spanner.admin.database.v1.DatabaseAdmin', 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.databaseAdminStub) { - return this.databaseAdminStub; - } - - // Put together the "service stub" for - // google.spanner.admin.database.v1.DatabaseAdmin. - this.databaseAdminStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.spanner.admin.database.v1.DatabaseAdmin') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.spanner.admin.database.v1.DatabaseAdmin, - 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 databaseAdminStubMethods = - ['listDatabases', 'createDatabase', 'getDatabase', 'updateDatabaseDdl', 'dropDatabase', 'getDatabaseDdl', 'setIamPolicy', 'getIamPolicy', 'testIamPermissions', 'createBackup', 'copyBackup', 'getBackup', 'updateBackup', 'deleteBackup', 'listBackups', 'restoreDatabase', 'listDatabaseOperations', 'listBackupOperations', 'listDatabaseRoles']; - for (const methodName of databaseAdminStubMethods) { - const callPromise = this.databaseAdminStub.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.databaseAdminStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'spanner.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 'spanner.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', - 'https://www.googleapis.com/auth/spanner.admin' - ]; - } - - 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 the state of a Cloud Spanner database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the requested database. Values are of the form - * `projects//instances//databases/`. - * @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 {@link google.spanner.admin.database.v1.Database | Database}. - * 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/v1/database_admin.get_database.js - * region_tag:spanner_v1_generated_DatabaseAdmin_GetDatabase_async - */ - getDatabase( - request?: protos.google.spanner.admin.database.v1.IGetDatabaseRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.database.v1.IDatabase, - protos.google.spanner.admin.database.v1.IGetDatabaseRequest|undefined, {}|undefined - ]>; - getDatabase( - request: protos.google.spanner.admin.database.v1.IGetDatabaseRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.admin.database.v1.IDatabase, - protos.google.spanner.admin.database.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>): void; - getDatabase( - request: protos.google.spanner.admin.database.v1.IGetDatabaseRequest, - callback: Callback< - protos.google.spanner.admin.database.v1.IDatabase, - protos.google.spanner.admin.database.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>): void; - getDatabase( - request?: protos.google.spanner.admin.database.v1.IGetDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.admin.database.v1.IDatabase, - protos.google.spanner.admin.database.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.admin.database.v1.IDatabase, - protos.google.spanner.admin.database.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.admin.database.v1.IDatabase, - protos.google.spanner.admin.database.v1.IGetDatabaseRequest|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({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getDatabase(request, options, callback); - } -/** - * Drops (aka deletes) a Cloud Spanner database. - * Completed backups for the database will be retained according to their - * `expire_time`. - * Note: Cloud Spanner might continue to accept requests for a few seconds - * after the database has been deleted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database to be dropped. - * @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 {@link google.protobuf.Empty | Empty}. - * 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/v1/database_admin.drop_database.js - * region_tag:spanner_v1_generated_DatabaseAdmin_DropDatabase_async - */ - dropDatabase( - request?: protos.google.spanner.admin.database.v1.IDropDatabaseRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDropDatabaseRequest|undefined, {}|undefined - ]>; - dropDatabase( - request: protos.google.spanner.admin.database.v1.IDropDatabaseRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDropDatabaseRequest|null|undefined, - {}|null|undefined>): void; - dropDatabase( - request: protos.google.spanner.admin.database.v1.IDropDatabaseRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDropDatabaseRequest|null|undefined, - {}|null|undefined>): void; - dropDatabase( - request?: protos.google.spanner.admin.database.v1.IDropDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDropDatabaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDropDatabaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDropDatabaseRequest|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({ - 'database': request.database ?? '', - }); - this.initialize(); - return this.innerApiCalls.dropDatabase(request, options, callback); - } -/** - * Returns the schema of a Cloud Spanner database as a list of formatted - * DDL statements. This method does not show pending schema updates, those may - * be queried using the {@link google.longrunning.Operations|Operations} API. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database whose schema we wish to get. - * Values are of the form - * `projects//instances//databases/` - * @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 {@link google.spanner.admin.database.v1.GetDatabaseDdlResponse | GetDatabaseDdlResponse}. - * 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/v1/database_admin.get_database_ddl.js - * region_tag:spanner_v1_generated_DatabaseAdmin_GetDatabaseDdl_async - */ - getDatabaseDdl( - request?: protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, - protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|undefined, {}|undefined - ]>; - getDatabaseDdl( - request: protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, - protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|null|undefined, - {}|null|undefined>): void; - getDatabaseDdl( - request: protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest, - callback: Callback< - protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, - protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|null|undefined, - {}|null|undefined>): void; - getDatabaseDdl( - request?: protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, - protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, - protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse, - protos.google.spanner.admin.database.v1.IGetDatabaseDdlRequest|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({ - 'database': request.database ?? '', - }); - this.initialize(); - return this.innerApiCalls.getDatabaseDdl(request, options, callback); - } -/** - * Sets the access control policy on a database or backup resource. - * Replaces any existing policy. - * - * Authorization requires `spanner.databases.setIamPolicy` - * permission on {@link google.iam.v1.SetIamPolicyRequest.resource|resource}. - * For backups, authorization requires `spanner.backups.setIamPolicy` - * permission on {@link google.iam.v1.SetIamPolicyRequest.resource|resource}. - * - * @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 {@link google.iam.v1.Policy | 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/v1/database_admin.set_iam_policy.js - * region_tag:spanner_v1_generated_DatabaseAdmin_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); - } -/** - * Gets the access control policy for a database or backup resource. - * Returns an empty policy if a database or backup exists but does not have a - * policy set. - * - * Authorization requires `spanner.databases.getIamPolicy` permission on - * {@link google.iam.v1.GetIamPolicyRequest.resource|resource}. - * For backups, authorization requires `spanner.backups.getIamPolicy` - * permission on {@link google.iam.v1.GetIamPolicyRequest.resource|resource}. - * - * @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 {@link google.iam.v1.Policy | 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/v1/database_admin.get_iam_policy.js - * region_tag:spanner_v1_generated_DatabaseAdmin_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); - } -/** - * Returns permissions that the caller has on the specified database or backup - * resource. - * - * Attempting this RPC on a non-existent Cloud Spanner database will - * result in a NOT_FOUND error if the user has - * `spanner.databases.list` permission on the containing Cloud - * Spanner instance. Otherwise returns an empty set of permissions. - * Calling this method on a backup that does not exist will - * result in a NOT_FOUND error if the user has - * `spanner.backups.list` permission on the containing instance. - * - * @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 {@link google.iam.v1.TestIamPermissionsResponse | 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/v1/database_admin.test_iam_permissions.js - * region_tag:spanner_v1_generated_DatabaseAdmin_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); - } -/** - * Gets metadata on a pending or completed {@link google.spanner.admin.database.v1.Backup|Backup}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the backup. - * Values are of the form - * `projects//instances//backups/`. - * @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 {@link google.spanner.admin.database.v1.Backup | Backup}. - * 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/v1/database_admin.get_backup.js - * region_tag:spanner_v1_generated_DatabaseAdmin_GetBackup_async - */ - getBackup( - request?: protos.google.spanner.admin.database.v1.IGetBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IGetBackupRequest|undefined, {}|undefined - ]>; - getBackup( - request: protos.google.spanner.admin.database.v1.IGetBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; - getBackup( - request: protos.google.spanner.admin.database.v1.IGetBackupRequest, - callback: Callback< - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; - getBackup( - request?: protos.google.spanner.admin.database.v1.IGetBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IGetBackupRequest|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({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getBackup(request, options, callback); - } -/** - * Updates a pending or completed {@link google.spanner.admin.database.v1.Backup|Backup}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.spanner.admin.database.v1.Backup} request.backup - * Required. The backup to update. `backup.name`, and the fields to be updated - * as specified by `update_mask` are required. Other fields are ignored. - * Update is only supported for the following fields: - * * `backup.expire_time`. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A mask specifying which fields (e.g. `expire_time`) in the - * Backup resource should be updated. This mask is relative to the Backup - * resource, not to the request message. The field mask must always be - * specified; this prevents any future fields from being erased accidentally - * by clients that do not know about them. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.spanner.admin.database.v1.Backup | Backup}. - * 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/v1/database_admin.update_backup.js - * region_tag:spanner_v1_generated_DatabaseAdmin_UpdateBackup_async - */ - updateBackup( - request?: protos.google.spanner.admin.database.v1.IUpdateBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IUpdateBackupRequest|undefined, {}|undefined - ]>; - updateBackup( - request: protos.google.spanner.admin.database.v1.IUpdateBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): void; - updateBackup( - request: protos.google.spanner.admin.database.v1.IUpdateBackupRequest, - callback: Callback< - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): void; - updateBackup( - request?: protos.google.spanner.admin.database.v1.IUpdateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IUpdateBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.admin.database.v1.IBackup, - protos.google.spanner.admin.database.v1.IUpdateBackupRequest|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({ - 'backup.name': request.backup!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateBackup(request, options, callback); - } -/** - * Deletes a pending or completed {@link google.spanner.admin.database.v1.Backup|Backup}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the backup to delete. - * Values are of the form - * `projects//instances//backups/`. - * @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 {@link google.protobuf.Empty | Empty}. - * 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/v1/database_admin.delete_backup.js - * region_tag:spanner_v1_generated_DatabaseAdmin_DeleteBackup_async - */ - deleteBackup( - request?: protos.google.spanner.admin.database.v1.IDeleteBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDeleteBackupRequest|undefined, {}|undefined - ]>; - deleteBackup( - request: protos.google.spanner.admin.database.v1.IDeleteBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): void; - deleteBackup( - request: protos.google.spanner.admin.database.v1.IDeleteBackupRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): void; - deleteBackup( - request?: protos.google.spanner.admin.database.v1.IDeleteBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDeleteBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.database.v1.IDeleteBackupRequest|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({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteBackup(request, options, callback); - } - -/** - * Creates a new Cloud Spanner database and starts to prepare it for serving. - * The returned {@link google.longrunning.Operation|long-running operation} will - * have a name of the format `/operations/` and - * can be used to track preparation of the database. The - * {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.spanner.admin.database.v1.CreateDatabaseMetadata|CreateDatabaseMetadata}. The - * {@link google.longrunning.Operation.response|response} field type is - * {@link google.spanner.admin.database.v1.Database|Database}, if successful. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the instance that will serve the new database. - * Values are of the form `projects//instances/`. - * @param {string} request.createStatement - * Required. A `CREATE DATABASE` statement, which specifies the ID of the - * new database. The database ID must conform to the regular expression - * `{@link a-z0-9_\-|a-z}*[a-z0-9]` and be between 2 and 30 characters in length. - * If the database ID is a reserved word or if it contains a hyphen, the - * database ID must be enclosed in backticks (`` ` ``). - * @param {string[]} [request.extraStatements] - * Optional. A list of DDL statements to run inside the newly created - * database. Statements can create tables, indexes, etc. These - * statements execute atomically with the creation of the database: - * if there is an error in any statement, the database is not created. - * @param {google.spanner.admin.database.v1.EncryptionConfig} [request.encryptionConfig] - * Optional. The encryption configuration for the database. If this field is not - * specified, Cloud Spanner will encrypt/decrypt all data at rest using - * Google default encryption. - * @param {google.spanner.admin.database.v1.DatabaseDialect} [request.databaseDialect] - * Optional. The dialect of the Cloud Spanner Database. - * @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/v1/database_admin.create_database.js - * region_tag:spanner_v1_generated_DatabaseAdmin_CreateDatabase_async - */ - createDatabase( - request?: protos.google.spanner.admin.database.v1.ICreateDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createDatabase( - request: protos.google.spanner.admin.database.v1.ICreateDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createDatabase( - request: protos.google.spanner.admin.database.v1.ICreateDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createDatabase( - request?: protos.google.spanner.admin.database.v1.ICreateDatabaseRequest, - 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 || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createDatabase(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createDatabase()`. - * @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/v1/database_admin.create_database.js - * region_tag:spanner_v1_generated_DatabaseAdmin_CreateDatabase_async - */ - async checkCreateDatabaseProgress(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.createDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the schema of a Cloud Spanner database by - * creating/altering/dropping tables, columns, indexes, etc. The returned - * {@link google.longrunning.Operation|long-running operation} will have a name of - * the format `/operations/` and can be used to - * track execution of the schema change(s). The - * {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata|UpdateDatabaseDdlMetadata}. The operation has no response. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database to update. - * @param {string[]} request.statements - * Required. DDL statements to be applied to the database. - * @param {string} request.operationId - * If empty, the new update request is assigned an - * automatically-generated operation ID. Otherwise, `operation_id` - * is used to construct the name of the resulting - * {@link google.longrunning.Operation|Operation}. - * - * Specifying an explicit operation ID simplifies determining - * whether the statements were executed in the event that the - * {@link google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl|UpdateDatabaseDdl} call is replayed, - * or the return value is otherwise lost: the {@link google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database|database} and - * `operation_id` fields can be combined to form the - * {@link google.longrunning.Operation.name|name} of the resulting - * {@link google.longrunning.Operation|longrunning.Operation}: `/operations/`. - * - * `operation_id` should be unique within the database, and must be - * a valid identifier: `{@link a-z0-9_|a-z}*`. Note that - * automatically-generated operation IDs always begin with an - * underscore. If the named operation already exists, - * {@link google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl|UpdateDatabaseDdl} returns - * `ALREADY_EXISTS`. - * @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/v1/database_admin.update_database_ddl.js - * region_tag:spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_async - */ - updateDatabaseDdl( - request?: protos.google.spanner.admin.database.v1.IUpdateDatabaseDdlRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateDatabaseDdl( - request: protos.google.spanner.admin.database.v1.IUpdateDatabaseDdlRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateDatabaseDdl( - request: protos.google.spanner.admin.database.v1.IUpdateDatabaseDdlRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateDatabaseDdl( - request?: protos.google.spanner.admin.database.v1.IUpdateDatabaseDdlRequest, - 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 || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'database': request.database ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateDatabaseDdl(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateDatabaseDdl()`. - * @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/v1/database_admin.update_database_ddl.js - * region_tag:spanner_v1_generated_DatabaseAdmin_UpdateDatabaseDdl_async - */ - async checkUpdateDatabaseDdlProgress(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.updateDatabaseDdl, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts creating a new Cloud Spanner Backup. - * The returned backup {@link google.longrunning.Operation|long-running operation} - * will have a name of the format - * `projects//instances//backups//operations/` - * and can be used to track creation of the backup. The - * {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. The - * {@link google.longrunning.Operation.response|response} field type is - * {@link google.spanner.admin.database.v1.Backup|Backup}, if successful. Cancelling the returned operation will stop the - * creation and delete the backup. - * There can be only one pending backup creation per database. Backup creation - * of different databases can run concurrently. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the instance in which the backup will be - * created. This must be the same instance that contains the database the - * backup will be created from. The backup will be stored in the - * location(s) specified in the instance configuration of this - * instance. Values are of the form - * `projects//instances/`. - * @param {string} request.backupId - * Required. The id of the backup to be created. The `backup_id` appended to - * `parent` forms the full backup name of the form - * `projects//instances//backups/`. - * @param {google.spanner.admin.database.v1.Backup} request.backup - * Required. The backup to create. - * @param {google.spanner.admin.database.v1.CreateBackupEncryptionConfig} [request.encryptionConfig] - * Optional. The encryption configuration used to encrypt the backup. If this field is - * not specified, the backup will use the same - * encryption configuration as the database by default, namely - * {@link google.spanner.admin.database.v1.CreateBackupEncryptionConfig.encryption_type|encryption_type} = - * `USE_DATABASE_ENCRYPTION`. - * @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/v1/database_admin.create_backup.js - * region_tag:spanner_v1_generated_DatabaseAdmin_CreateBackup_async - */ - createBackup( - request?: protos.google.spanner.admin.database.v1.ICreateBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createBackup( - request: protos.google.spanner.admin.database.v1.ICreateBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createBackup( - request: protos.google.spanner.admin.database.v1.ICreateBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createBackup( - request?: protos.google.spanner.admin.database.v1.ICreateBackupRequest, - 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 || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createBackup(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createBackup()`. - * @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/v1/database_admin.create_backup.js - * region_tag:spanner_v1_generated_DatabaseAdmin_CreateBackup_async - */ - async checkCreateBackupProgress(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.createBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts copying a Cloud Spanner Backup. - * The returned backup {@link google.longrunning.Operation|long-running operation} - * will have a name of the format - * `projects//instances//backups//operations/` - * and can be used to track copying of the backup. The operation is associated - * with the destination backup. - * The {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata}. - * The {@link google.longrunning.Operation.response|response} field type is - * {@link google.spanner.admin.database.v1.Backup|Backup}, if successful. Cancelling the returned operation will stop the - * copying and delete the backup. - * Concurrent CopyBackup requests can run on the same source backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the destination instance that will contain the backup copy. - * Values are of the form: `projects//instances/`. - * @param {string} request.backupId - * Required. The id of the backup copy. - * The `backup_id` appended to `parent` forms the full backup_uri of the form - * `projects//instances//backups/`. - * @param {string} request.sourceBackup - * Required. The source backup to be copied. - * The source backup needs to be in READY state for it to be copied. - * Once CopyBackup is in progress, the source backup cannot be deleted or - * cleaned up on expiration until CopyBackup is finished. - * Values are of the form: - * `projects//instances//backups/`. - * @param {google.protobuf.Timestamp} request.expireTime - * Required. The expiration time of the backup in microsecond granularity. - * The expiration time must be at least 6 hours and at most 366 days - * from the `create_time` of the source backup. Once the `expire_time` has - * passed, the backup is eligible to be automatically deleted by Cloud Spanner - * to free the resources used by the backup. - * @param {google.spanner.admin.database.v1.CopyBackupEncryptionConfig} [request.encryptionConfig] - * Optional. The encryption configuration used to encrypt the backup. If this field is - * not specified, the backup will use the same - * encryption configuration as the source backup by default, namely - * {@link google.spanner.admin.database.v1.CopyBackupEncryptionConfig.encryption_type|encryption_type} = - * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. - * @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/v1/database_admin.copy_backup.js - * region_tag:spanner_v1_generated_DatabaseAdmin_CopyBackup_async - */ - copyBackup( - request?: protos.google.spanner.admin.database.v1.ICopyBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - copyBackup( - request: protos.google.spanner.admin.database.v1.ICopyBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - copyBackup( - request: protos.google.spanner.admin.database.v1.ICopyBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - copyBackup( - request?: protos.google.spanner.admin.database.v1.ICopyBackupRequest, - 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 || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.copyBackup(request, options, callback); - } -/** - * Check the status of the long running operation returned by `copyBackup()`. - * @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/v1/database_admin.copy_backup.js - * region_tag:spanner_v1_generated_DatabaseAdmin_CopyBackup_async - */ - async checkCopyBackupProgress(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.copyBackup, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Create a new database by restoring from a completed backup. The new - * database must be in the same project and in an instance with the same - * instance configuration as the instance containing - * the backup. The returned database [long-running - * operation][google.longrunning.Operation] has a name of the format - * `projects//instances//databases//operations/`, - * and can be used to track the progress of the operation, and to cancel it. - * The {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata}. - * The {@link google.longrunning.Operation.response|response} type - * is {@link google.spanner.admin.database.v1.Database|Database}, if - * successful. Cancelling the returned operation will stop the restore and - * delete the database. - * There can be only one database being restored into an instance at a time. - * Once the restore operation completes, a new restore operation can be - * initiated, without waiting for the optimize operation associated with the - * first restore to complete. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the instance in which to create the - * restored database. This instance must be in the same project and - * have the same instance configuration as the instance containing - * the source backup. Values are of the form - * `projects//instances/`. - * @param {string} request.databaseId - * Required. The id of the database to create and restore to. This - * database must not already exist. The `database_id` appended to - * `parent` forms the full database name of the form - * `projects//instances//databases/`. - * @param {string} request.backup - * Name of the backup from which to restore. Values are of the form - * `projects//instances//backups/`. - * @param {google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig} [request.encryptionConfig] - * Optional. An encryption configuration describing the encryption type and key - * resources in Cloud KMS used to encrypt/decrypt the database to restore to. - * If this field is not specified, the restored database will use - * the same encryption configuration as the backup by default, namely - * {@link google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.encryption_type|encryption_type} = - * `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`. - * @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/v1/database_admin.restore_database.js - * region_tag:spanner_v1_generated_DatabaseAdmin_RestoreDatabase_async - */ - restoreDatabase( - request?: protos.google.spanner.admin.database.v1.IRestoreDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - restoreDatabase( - request: protos.google.spanner.admin.database.v1.IRestoreDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - restoreDatabase( - request: protos.google.spanner.admin.database.v1.IRestoreDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - restoreDatabase( - request?: protos.google.spanner.admin.database.v1.IRestoreDatabaseRequest, - 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 || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.restoreDatabase(request, options, callback); - } -/** - * Check the status of the long running operation returned by `restoreDatabase()`. - * @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/v1/database_admin.restore_database.js - * region_tag:spanner_v1_generated_DatabaseAdmin_RestoreDatabase_async - */ - async checkRestoreDatabaseProgress(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.restoreDatabase, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Cloud Spanner databases. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The instance whose databases should be listed. - * Values are of the form `projects//instances/`. - * @param {number} request.pageSize - * Number of databases to be returned in the response. If 0 or less, - * defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.database.v1.ListDatabasesResponse|ListDatabasesResponse}. - * @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 {@link google.spanner.admin.database.v1.Database | Database}. - * 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 `listDatabasesAsync()` - * 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. - */ - listDatabases( - request?: protos.google.spanner.admin.database.v1.IListDatabasesRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.database.v1.IDatabase[], - protos.google.spanner.admin.database.v1.IListDatabasesRequest|null, - protos.google.spanner.admin.database.v1.IListDatabasesResponse - ]>; - listDatabases( - request: protos.google.spanner.admin.database.v1.IListDatabasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabasesRequest, - protos.google.spanner.admin.database.v1.IListDatabasesResponse|null|undefined, - protos.google.spanner.admin.database.v1.IDatabase>): void; - listDatabases( - request: protos.google.spanner.admin.database.v1.IListDatabasesRequest, - callback: PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabasesRequest, - protos.google.spanner.admin.database.v1.IListDatabasesResponse|null|undefined, - protos.google.spanner.admin.database.v1.IDatabase>): void; - listDatabases( - request?: protos.google.spanner.admin.database.v1.IListDatabasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabasesRequest, - protos.google.spanner.admin.database.v1.IListDatabasesResponse|null|undefined, - protos.google.spanner.admin.database.v1.IDatabase>, - callback?: PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabasesRequest, - protos.google.spanner.admin.database.v1.IListDatabasesResponse|null|undefined, - protos.google.spanner.admin.database.v1.IDatabase>): - Promise<[ - protos.google.spanner.admin.database.v1.IDatabase[], - protos.google.spanner.admin.database.v1.IListDatabasesRequest|null, - protos.google.spanner.admin.database.v1.IListDatabasesResponse - ]>|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({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listDatabases(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 instance whose databases should be listed. - * Values are of the form `projects//instances/`. - * @param {number} request.pageSize - * Number of databases to be returned in the response. If 0 or less, - * defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.database.v1.ListDatabasesResponse|ListDatabasesResponse}. - * @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 {@link google.spanner.admin.database.v1.Database | Database} 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 `listDatabasesAsync()` - * 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. - */ - listDatabasesStream( - request?: protos.google.spanner.admin.database.v1.IListDatabasesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDatabases']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDatabases.createStream( - this.innerApiCalls.listDatabases as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listDatabases`, 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 instance whose databases should be listed. - * Values are of the form `projects//instances/`. - * @param {number} request.pageSize - * Number of databases to be returned in the response. If 0 or less, - * defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.database.v1.ListDatabasesResponse|ListDatabasesResponse}. - * @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 - * {@link google.spanner.admin.database.v1.Database | Database}. 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/v1/database_admin.list_databases.js - * region_tag:spanner_v1_generated_DatabaseAdmin_ListDatabases_async - */ - listDatabasesAsync( - request?: protos.google.spanner.admin.database.v1.IListDatabasesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDatabases']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDatabases.asyncIterate( - this.innerApiCalls['listDatabases'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists completed and pending backups. - * Backups returned are ordered by `create_time` in descending order, - * starting from the most recent `create_time`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The instance to list backups from. Values are of the - * form `projects//instances/`. - * @param {string} request.filter - * An expression that filters the list of returned backups. - * - * A filter expression consists of a field name, a comparison operator, and a - * value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.spanner.admin.database.v1.Backup|Backup} are eligible for filtering: - * - * * `name` - * * `database` - * * `state` - * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `size_bytes` - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic, but - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `name:Howl` - The backup's name contains the string "howl". - * * `database:prod` - * - The database's name contains the string "prod". - * * `state:CREATING` - The backup is pending creation. - * * `state:READY` - The backup is fully created and ready for use. - * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` - * - The backup name contains the string "howl" and `create_time` - * of the backup is before 2018-03-28T14:50:00Z. - * * `expire_time < \"2018-03-28T14:50:00Z\"` - * - The backup `expire_time` is before 2018-03-28T14:50:00Z. - * * `size_bytes > 10000000000` - The backup's size is greater than 10GB - * @param {number} request.pageSize - * Number of backups to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListBackupsResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.database.v1.ListBackupsResponse|ListBackupsResponse} to the same `parent` and with the same - * `filter`. - * @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 {@link google.spanner.admin.database.v1.Backup | Backup}. - * 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 `listBackupsAsync()` - * 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. - */ - listBackups( - request?: protos.google.spanner.admin.database.v1.IListBackupsRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.database.v1.IBackup[], - protos.google.spanner.admin.database.v1.IListBackupsRequest|null, - protos.google.spanner.admin.database.v1.IListBackupsResponse - ]>; - listBackups( - request: protos.google.spanner.admin.database.v1.IListBackupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.spanner.admin.database.v1.IListBackupsRequest, - protos.google.spanner.admin.database.v1.IListBackupsResponse|null|undefined, - protos.google.spanner.admin.database.v1.IBackup>): void; - listBackups( - request: protos.google.spanner.admin.database.v1.IListBackupsRequest, - callback: PaginationCallback< - protos.google.spanner.admin.database.v1.IListBackupsRequest, - protos.google.spanner.admin.database.v1.IListBackupsResponse|null|undefined, - protos.google.spanner.admin.database.v1.IBackup>): void; - listBackups( - request?: protos.google.spanner.admin.database.v1.IListBackupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.spanner.admin.database.v1.IListBackupsRequest, - protos.google.spanner.admin.database.v1.IListBackupsResponse|null|undefined, - protos.google.spanner.admin.database.v1.IBackup>, - callback?: PaginationCallback< - protos.google.spanner.admin.database.v1.IListBackupsRequest, - protos.google.spanner.admin.database.v1.IListBackupsResponse|null|undefined, - protos.google.spanner.admin.database.v1.IBackup>): - Promise<[ - protos.google.spanner.admin.database.v1.IBackup[], - protos.google.spanner.admin.database.v1.IListBackupsRequest|null, - protos.google.spanner.admin.database.v1.IListBackupsResponse - ]>|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({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listBackups(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 instance to list backups from. Values are of the - * form `projects//instances/`. - * @param {string} request.filter - * An expression that filters the list of returned backups. - * - * A filter expression consists of a field name, a comparison operator, and a - * value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.spanner.admin.database.v1.Backup|Backup} are eligible for filtering: - * - * * `name` - * * `database` - * * `state` - * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `size_bytes` - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic, but - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `name:Howl` - The backup's name contains the string "howl". - * * `database:prod` - * - The database's name contains the string "prod". - * * `state:CREATING` - The backup is pending creation. - * * `state:READY` - The backup is fully created and ready for use. - * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` - * - The backup name contains the string "howl" and `create_time` - * of the backup is before 2018-03-28T14:50:00Z. - * * `expire_time < \"2018-03-28T14:50:00Z\"` - * - The backup `expire_time` is before 2018-03-28T14:50:00Z. - * * `size_bytes > 10000000000` - The backup's size is greater than 10GB - * @param {number} request.pageSize - * Number of backups to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListBackupsResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.database.v1.ListBackupsResponse|ListBackupsResponse} to the same `parent` and with the same - * `filter`. - * @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 {@link google.spanner.admin.database.v1.Backup | Backup} 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 `listBackupsAsync()` - * 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. - */ - listBackupsStream( - request?: protos.google.spanner.admin.database.v1.IListBackupsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listBackups']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listBackups.createStream( - this.innerApiCalls.listBackups as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listBackups`, 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 instance to list backups from. Values are of the - * form `projects//instances/`. - * @param {string} request.filter - * An expression that filters the list of returned backups. - * - * A filter expression consists of a field name, a comparison operator, and a - * value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.spanner.admin.database.v1.Backup|Backup} are eligible for filtering: - * - * * `name` - * * `database` - * * `state` - * * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `size_bytes` - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic, but - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `name:Howl` - The backup's name contains the string "howl". - * * `database:prod` - * - The database's name contains the string "prod". - * * `state:CREATING` - The backup is pending creation. - * * `state:READY` - The backup is fully created and ready for use. - * * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` - * - The backup name contains the string "howl" and `create_time` - * of the backup is before 2018-03-28T14:50:00Z. - * * `expire_time < \"2018-03-28T14:50:00Z\"` - * - The backup `expire_time` is before 2018-03-28T14:50:00Z. - * * `size_bytes > 10000000000` - The backup's size is greater than 10GB - * @param {number} request.pageSize - * Number of backups to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListBackupsResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.database.v1.ListBackupsResponse|ListBackupsResponse} to the same `parent` and with the same - * `filter`. - * @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 - * {@link google.spanner.admin.database.v1.Backup | Backup}. 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/v1/database_admin.list_backups.js - * region_tag:spanner_v1_generated_DatabaseAdmin_ListBackups_async - */ - listBackupsAsync( - request?: protos.google.spanner.admin.database.v1.IListBackupsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listBackups']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listBackups.asyncIterate( - this.innerApiCalls['listBackups'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists database {@link google.longrunning.Operation|longrunning-operations}. - * A database operation has a name of the form - * `projects//instances//databases//operations/`. - * The long-running operation - * {@link google.longrunning.Operation.metadata|metadata} field type - * `metadata.type_url` describes the type of the metadata. Operations returned - * include those that have completed/failed/canceled within the last 7 days, - * and pending operations. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The instance of the database operations. - * Values are of the form `projects//instances/`. - * @param {string} request.filter - * An expression that filters the list of returned operations. - * - * A filter expression consists of a field name, a - * comparison operator, and a value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.longrunning.Operation|Operation} - * are eligible for filtering: - * - * * `name` - The name of the long-running operation - * * `done` - False if the operation is in progress, else true. - * * `metadata.@type` - the type of metadata. For example, the type string - * for {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata} is - * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. - * * `metadata.` - any field in metadata.value. - * `metadata.@type` must be specified first, if filtering on metadata - * fields. - * * `error` - Error associated with the long-running operation. - * * `response.@type` - the type of response. - * * `response.` - any field in response.value. - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic. However, - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `done:true` - The operation is complete. - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ - * `(metadata.source_type:BACKUP) AND` \ - * `(metadata.backup_info.backup:backup_howl) AND` \ - * `(metadata.name:restored_howl) AND` \ - * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ - * `(error:*)` - Return operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata}. - * * The database is restored from a backup. - * * The backup name contains "backup_howl". - * * The restored database's name contains "restored_howl". - * * The operation started before 2018-03-28T14:50:00Z. - * * The operation resulted in an error. - * @param {number} request.pageSize - * Number of operations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token|next_page_token} - * from a previous {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse|ListDatabaseOperationsResponse} to the - * same `parent` and with the same `filter`. - * @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 {@link google.longrunning.Operation | Operation}. - * 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 `listDatabaseOperationsAsync()` - * 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. - */ - listDatabaseOperations( - request?: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, - options?: CallOptions): - Promise<[ - protos.google.longrunning.IOperation[], - protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest|null, - protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse - ]>; - listDatabaseOperations( - request: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, - protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>): void; - listDatabaseOperations( - request: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, - callback: PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, - protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>): void; - listDatabaseOperations( - request?: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, - protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>, - callback?: PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, - protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>): - Promise<[ - protos.google.longrunning.IOperation[], - protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest|null, - protos.google.spanner.admin.database.v1.IListDatabaseOperationsResponse - ]>|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({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listDatabaseOperations(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 instance of the database operations. - * Values are of the form `projects//instances/`. - * @param {string} request.filter - * An expression that filters the list of returned operations. - * - * A filter expression consists of a field name, a - * comparison operator, and a value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.longrunning.Operation|Operation} - * are eligible for filtering: - * - * * `name` - The name of the long-running operation - * * `done` - False if the operation is in progress, else true. - * * `metadata.@type` - the type of metadata. For example, the type string - * for {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata} is - * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. - * * `metadata.` - any field in metadata.value. - * `metadata.@type` must be specified first, if filtering on metadata - * fields. - * * `error` - Error associated with the long-running operation. - * * `response.@type` - the type of response. - * * `response.` - any field in response.value. - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic. However, - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `done:true` - The operation is complete. - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ - * `(metadata.source_type:BACKUP) AND` \ - * `(metadata.backup_info.backup:backup_howl) AND` \ - * `(metadata.name:restored_howl) AND` \ - * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ - * `(error:*)` - Return operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata}. - * * The database is restored from a backup. - * * The backup name contains "backup_howl". - * * The restored database's name contains "restored_howl". - * * The operation started before 2018-03-28T14:50:00Z. - * * The operation resulted in an error. - * @param {number} request.pageSize - * Number of operations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token|next_page_token} - * from a previous {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse|ListDatabaseOperationsResponse} to the - * same `parent` and with the same `filter`. - * @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 {@link google.longrunning.Operation | Operation} 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 `listDatabaseOperationsAsync()` - * 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. - */ - listDatabaseOperationsStream( - request?: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDatabaseOperations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDatabaseOperations.createStream( - this.innerApiCalls.listDatabaseOperations as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listDatabaseOperations`, 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 instance of the database operations. - * Values are of the form `projects//instances/`. - * @param {string} request.filter - * An expression that filters the list of returned operations. - * - * A filter expression consists of a field name, a - * comparison operator, and a value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.longrunning.Operation|Operation} - * are eligible for filtering: - * - * * `name` - The name of the long-running operation - * * `done` - False if the operation is in progress, else true. - * * `metadata.@type` - the type of metadata. For example, the type string - * for {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata} is - * `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. - * * `metadata.` - any field in metadata.value. - * `metadata.@type` must be specified first, if filtering on metadata - * fields. - * * `error` - Error associated with the long-running operation. - * * `response.@type` - the type of response. - * * `response.` - any field in response.value. - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic. However, - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `done:true` - The operation is complete. - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ - * `(metadata.source_type:BACKUP) AND` \ - * `(metadata.backup_info.backup:backup_howl) AND` \ - * `(metadata.name:restored_howl) AND` \ - * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ - * `(error:*)` - Return operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.RestoreDatabaseMetadata|RestoreDatabaseMetadata}. - * * The database is restored from a backup. - * * The backup name contains "backup_howl". - * * The restored database's name contains "restored_howl". - * * The operation started before 2018-03-28T14:50:00Z. - * * The operation resulted in an error. - * @param {number} request.pageSize - * Number of operations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token|next_page_token} - * from a previous {@link google.spanner.admin.database.v1.ListDatabaseOperationsResponse|ListDatabaseOperationsResponse} to the - * same `parent` and with the same `filter`. - * @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 - * {@link google.longrunning.Operation | Operation}. 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/v1/database_admin.list_database_operations.js - * region_tag:spanner_v1_generated_DatabaseAdmin_ListDatabaseOperations_async - */ - listDatabaseOperationsAsync( - request?: protos.google.spanner.admin.database.v1.IListDatabaseOperationsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDatabaseOperations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDatabaseOperations.asyncIterate( - this.innerApiCalls['listDatabaseOperations'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the backup {@link google.longrunning.Operation|long-running operations} in - * the given instance. A backup operation has a name of the form - * `projects//instances//backups//operations/`. - * The long-running operation - * {@link google.longrunning.Operation.metadata|metadata} field type - * `metadata.type_url` describes the type of the metadata. Operations returned - * include those that have completed/failed/canceled within the last 7 days, - * and pending operations. Operations returned are ordered by - * `operation.metadata.value.progress.start_time` in descending order starting - * from the most recently started operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The instance of the backup operations. Values are of - * the form `projects//instances/`. - * @param {string} request.filter - * An expression that filters the list of returned backup operations. - * - * A filter expression consists of a field name, a - * comparison operator, and a value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.longrunning.Operation|operation} - * are eligible for filtering: - * - * * `name` - The name of the long-running operation - * * `done` - False if the operation is in progress, else true. - * * `metadata.@type` - the type of metadata. For example, the type string - * for {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} is - * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. - * * `metadata.` - any field in metadata.value. - * `metadata.@type` must be specified first if filtering on metadata - * fields. - * * `error` - Error associated with the long-running operation. - * * `response.@type` - the type of response. - * * `response.` - any field in response.value. - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic, but - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `done:true` - The operation is complete. - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - * `metadata.database:prod` - Returns operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. - * * The database the backup was taken from has a name containing the - * string "prod". - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - * `(metadata.name:howl) AND` \ - * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ - * `(error:*)` - Returns operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. - * * The backup name contains the string "howl". - * * The operation started before 2018-03-28T14:50:00Z. - * * The operation resulted in an error. - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ - * `(metadata.source_backup:test) AND` \ - * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ - * `(error:*)` - Returns operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata}. - * * The source backup of the copied backup name contains the string - * "test". - * * The operation started before 2022-01-18T14:50:00Z. - * * The operation resulted in an error. - * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - * `(metadata.database:test_db)) OR` \ - * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) - * AND` \ - * `(metadata.source_backup:test_bkp)) AND` \ - * `(error:*)` - Returns operations where: - * * The operation's metadata matches either of criteria: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} AND the - * database the backup was taken from has name containing string - * "test_db" - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata} AND the - * backup the backup was copied from has name containing string - * "test_bkp" - * * The operation resulted in an error. - * @param {number} request.pageSize - * Number of operations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token|next_page_token} - * from a previous {@link google.spanner.admin.database.v1.ListBackupOperationsResponse|ListBackupOperationsResponse} to the - * same `parent` and with the same `filter`. - * @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 {@link google.longrunning.Operation | Operation}. - * 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 `listBackupOperationsAsync()` - * 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. - */ - listBackupOperations( - request?: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, - options?: CallOptions): - Promise<[ - protos.google.longrunning.IOperation[], - protos.google.spanner.admin.database.v1.IListBackupOperationsRequest|null, - protos.google.spanner.admin.database.v1.IListBackupOperationsResponse - ]>; - listBackupOperations( - request: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, - protos.google.spanner.admin.database.v1.IListBackupOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>): void; - listBackupOperations( - request: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, - callback: PaginationCallback< - protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, - protos.google.spanner.admin.database.v1.IListBackupOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>): void; - listBackupOperations( - request?: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, - protos.google.spanner.admin.database.v1.IListBackupOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>, - callback?: PaginationCallback< - protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, - protos.google.spanner.admin.database.v1.IListBackupOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>): - Promise<[ - protos.google.longrunning.IOperation[], - protos.google.spanner.admin.database.v1.IListBackupOperationsRequest|null, - protos.google.spanner.admin.database.v1.IListBackupOperationsResponse - ]>|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({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listBackupOperations(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 instance of the backup operations. Values are of - * the form `projects//instances/`. - * @param {string} request.filter - * An expression that filters the list of returned backup operations. - * - * A filter expression consists of a field name, a - * comparison operator, and a value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.longrunning.Operation|operation} - * are eligible for filtering: - * - * * `name` - The name of the long-running operation - * * `done` - False if the operation is in progress, else true. - * * `metadata.@type` - the type of metadata. For example, the type string - * for {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} is - * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. - * * `metadata.` - any field in metadata.value. - * `metadata.@type` must be specified first if filtering on metadata - * fields. - * * `error` - Error associated with the long-running operation. - * * `response.@type` - the type of response. - * * `response.` - any field in response.value. - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic, but - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `done:true` - The operation is complete. - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - * `metadata.database:prod` - Returns operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. - * * The database the backup was taken from has a name containing the - * string "prod". - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - * `(metadata.name:howl) AND` \ - * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ - * `(error:*)` - Returns operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. - * * The backup name contains the string "howl". - * * The operation started before 2018-03-28T14:50:00Z. - * * The operation resulted in an error. - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ - * `(metadata.source_backup:test) AND` \ - * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ - * `(error:*)` - Returns operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata}. - * * The source backup of the copied backup name contains the string - * "test". - * * The operation started before 2022-01-18T14:50:00Z. - * * The operation resulted in an error. - * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - * `(metadata.database:test_db)) OR` \ - * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) - * AND` \ - * `(metadata.source_backup:test_bkp)) AND` \ - * `(error:*)` - Returns operations where: - * * The operation's metadata matches either of criteria: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} AND the - * database the backup was taken from has name containing string - * "test_db" - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata} AND the - * backup the backup was copied from has name containing string - * "test_bkp" - * * The operation resulted in an error. - * @param {number} request.pageSize - * Number of operations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token|next_page_token} - * from a previous {@link google.spanner.admin.database.v1.ListBackupOperationsResponse|ListBackupOperationsResponse} to the - * same `parent` and with the same `filter`. - * @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 {@link google.longrunning.Operation | Operation} 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 `listBackupOperationsAsync()` - * 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. - */ - listBackupOperationsStream( - request?: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listBackupOperations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listBackupOperations.createStream( - this.innerApiCalls.listBackupOperations as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listBackupOperations`, 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 instance of the backup operations. Values are of - * the form `projects//instances/`. - * @param {string} request.filter - * An expression that filters the list of returned backup operations. - * - * A filter expression consists of a field name, a - * comparison operator, and a value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.longrunning.Operation|operation} - * are eligible for filtering: - * - * * `name` - The name of the long-running operation - * * `done` - False if the operation is in progress, else true. - * * `metadata.@type` - the type of metadata. For example, the type string - * for {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} is - * `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. - * * `metadata.` - any field in metadata.value. - * `metadata.@type` must be specified first if filtering on metadata - * fields. - * * `error` - Error associated with the long-running operation. - * * `response.@type` - the type of response. - * * `response.` - any field in response.value. - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic, but - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `done:true` - The operation is complete. - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - * `metadata.database:prod` - Returns operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. - * * The database the backup was taken from has a name containing the - * string "prod". - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - * `(metadata.name:howl) AND` \ - * `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ - * `(error:*)` - Returns operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata}. - * * The backup name contains the string "howl". - * * The operation started before 2018-03-28T14:50:00Z. - * * The operation resulted in an error. - * * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ - * `(metadata.source_backup:test) AND` \ - * `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ - * `(error:*)` - Returns operations where: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata}. - * * The source backup of the copied backup name contains the string - * "test". - * * The operation started before 2022-01-18T14:50:00Z. - * * The operation resulted in an error. - * * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ - * `(metadata.database:test_db)) OR` \ - * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) - * AND` \ - * `(metadata.source_backup:test_bkp)) AND` \ - * `(error:*)` - Returns operations where: - * * The operation's metadata matches either of criteria: - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CreateBackupMetadata|CreateBackupMetadata} AND the - * database the backup was taken from has name containing string - * "test_db" - * * The operation's metadata type is {@link google.spanner.admin.database.v1.CopyBackupMetadata|CopyBackupMetadata} AND the - * backup the backup was copied from has name containing string - * "test_bkp" - * * The operation resulted in an error. - * @param {number} request.pageSize - * Number of operations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token|next_page_token} - * from a previous {@link google.spanner.admin.database.v1.ListBackupOperationsResponse|ListBackupOperationsResponse} to the - * same `parent` and with the same `filter`. - * @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 - * {@link google.longrunning.Operation | Operation}. 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/v1/database_admin.list_backup_operations.js - * region_tag:spanner_v1_generated_DatabaseAdmin_ListBackupOperations_async - */ - listBackupOperationsAsync( - request?: protos.google.spanner.admin.database.v1.IListBackupOperationsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listBackupOperations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listBackupOperations.asyncIterate( - this.innerApiCalls['listBackupOperations'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists Cloud Spanner database roles. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The database whose roles should be listed. - * Values are of the form - * `projects//instances//databases//databaseRoles`. - * @param {number} request.pageSize - * Number of database roles to be returned in the response. If 0 or less, - * defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse|ListDatabaseRolesResponse}. - * @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 {@link google.spanner.admin.database.v1.DatabaseRole | DatabaseRole}. - * 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 `listDatabaseRolesAsync()` - * 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. - */ - listDatabaseRoles( - request?: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.database.v1.IDatabaseRole[], - protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest|null, - protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse - ]>; - listDatabaseRoles( - request: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, - protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse|null|undefined, - protos.google.spanner.admin.database.v1.IDatabaseRole>): void; - listDatabaseRoles( - request: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, - callback: PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, - protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse|null|undefined, - protos.google.spanner.admin.database.v1.IDatabaseRole>): void; - listDatabaseRoles( - request?: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, - protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse|null|undefined, - protos.google.spanner.admin.database.v1.IDatabaseRole>, - callback?: PaginationCallback< - protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, - protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse|null|undefined, - protos.google.spanner.admin.database.v1.IDatabaseRole>): - Promise<[ - protos.google.spanner.admin.database.v1.IDatabaseRole[], - protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest|null, - protos.google.spanner.admin.database.v1.IListDatabaseRolesResponse - ]>|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({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listDatabaseRoles(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 database whose roles should be listed. - * Values are of the form - * `projects//instances//databases//databaseRoles`. - * @param {number} request.pageSize - * Number of database roles to be returned in the response. If 0 or less, - * defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse|ListDatabaseRolesResponse}. - * @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 {@link google.spanner.admin.database.v1.DatabaseRole | DatabaseRole} 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 `listDatabaseRolesAsync()` - * 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. - */ - listDatabaseRolesStream( - request?: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDatabaseRoles']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDatabaseRoles.createStream( - this.innerApiCalls.listDatabaseRoles as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listDatabaseRoles`, 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 database whose roles should be listed. - * Values are of the form - * `projects//instances//databases//databaseRoles`. - * @param {number} request.pageSize - * Number of database roles to be returned in the response. If 0 or less, - * defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse.next_page_token|next_page_token} from a - * previous {@link google.spanner.admin.database.v1.ListDatabaseRolesResponse|ListDatabaseRolesResponse}. - * @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 - * {@link google.spanner.admin.database.v1.DatabaseRole | DatabaseRole}. 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/v1/database_admin.list_database_roles.js - * region_tag:spanner_v1_generated_DatabaseAdmin_ListDatabaseRoles_async - */ - listDatabaseRolesAsync( - request?: protos.google.spanner.admin.database.v1.IListDatabaseRolesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDatabaseRoles']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDatabaseRoles.asyncIterate( - this.innerApiCalls['listDatabaseRoles'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified backup resource name string. - * - * @param {string} project - * @param {string} instance - * @param {string} backup - * @returns {string} Resource name string. - */ - backupPath(project:string,instance:string,backup:string) { - return this.pathTemplates.backupPathTemplate.render({ - project: project, - instance: instance, - backup: backup, - }); - } - - /** - * Parse the project from Backup resource. - * - * @param {string} backupName - * A fully-qualified path representing Backup resource. - * @returns {string} A string representing the project. - */ - matchProjectFromBackupName(backupName: string) { - return this.pathTemplates.backupPathTemplate.match(backupName).project; - } - - /** - * Parse the instance from Backup resource. - * - * @param {string} backupName - * A fully-qualified path representing Backup resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromBackupName(backupName: string) { - return this.pathTemplates.backupPathTemplate.match(backupName).instance; - } - - /** - * Parse the backup from Backup resource. - * - * @param {string} backupName - * A fully-qualified path representing Backup resource. - * @returns {string} A string representing the backup. - */ - matchBackupFromBackupName(backupName: string) { - return this.pathTemplates.backupPathTemplate.match(backupName).backup; - } - - /** - * 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 database resource name string. - * - * @param {string} project - * @param {string} instance - * @param {string} database - * @returns {string} Resource name string. - */ - databasePath(project:string,instance:string,database:string) { - return this.pathTemplates.databasePathTemplate.render({ - project: project, - instance: instance, - database: database, - }); - } - - /** - * Parse the project from Database resource. - * - * @param {string} databaseName - * A fully-qualified path representing Database resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDatabaseName(databaseName: string) { - return this.pathTemplates.databasePathTemplate.match(databaseName).project; - } - - /** - * Parse the instance from Database resource. - * - * @param {string} databaseName - * A fully-qualified path representing Database resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromDatabaseName(databaseName: string) { - return this.pathTemplates.databasePathTemplate.match(databaseName).instance; - } - - /** - * Parse the database from Database resource. - * - * @param {string} databaseName - * A fully-qualified path representing Database resource. - * @returns {string} A string representing the database. - */ - matchDatabaseFromDatabaseName(databaseName: string) { - return this.pathTemplates.databasePathTemplate.match(databaseName).database; - } - - /** - * Return a fully-qualified databaseRole resource name string. - * - * @param {string} project - * @param {string} instance - * @param {string} database - * @param {string} role - * @returns {string} Resource name string. - */ - databaseRolePath(project:string,instance:string,database:string,role:string) { - return this.pathTemplates.databaseRolePathTemplate.render({ - project: project, - instance: instance, - database: database, - role: role, - }); - } - - /** - * Parse the project from DatabaseRole resource. - * - * @param {string} databaseRoleName - * A fully-qualified path representing DatabaseRole resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDatabaseRoleName(databaseRoleName: string) { - return this.pathTemplates.databaseRolePathTemplate.match(databaseRoleName).project; - } - - /** - * Parse the instance from DatabaseRole resource. - * - * @param {string} databaseRoleName - * A fully-qualified path representing DatabaseRole resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromDatabaseRoleName(databaseRoleName: string) { - return this.pathTemplates.databaseRolePathTemplate.match(databaseRoleName).instance; - } - - /** - * Parse the database from DatabaseRole resource. - * - * @param {string} databaseRoleName - * A fully-qualified path representing DatabaseRole resource. - * @returns {string} A string representing the database. - */ - matchDatabaseFromDatabaseRoleName(databaseRoleName: string) { - return this.pathTemplates.databaseRolePathTemplate.match(databaseRoleName).database; - } - - /** - * Parse the role from DatabaseRole resource. - * - * @param {string} databaseRoleName - * A fully-qualified path representing DatabaseRole resource. - * @returns {string} A string representing the role. - */ - matchRoleFromDatabaseRoleName(databaseRoleName: string) { - return this.pathTemplates.databaseRolePathTemplate.match(databaseRoleName).role; - } - - /** - * Return a fully-qualified instance resource name string. - * - * @param {string} project - * @param {string} instance - * @returns {string} Resource name string. - */ - instancePath(project:string,instance:string) { - return this.pathTemplates.instancePathTemplate.render({ - project: project, - instance: instance, - }); - } - - /** - * Parse the project from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).project; - } - - /** - * Parse the instance from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).instance; - } - - /** - * 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.databaseAdminStub && !this._terminated) { - return this.databaseAdminStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/admin/database/v1/src/v1/database_admin_client_config.json b/owl-bot-staging/admin/database/v1/src/v1/database_admin_client_config.json deleted file mode 100644 index 035f43bc8..000000000 --- a/owl-bot-staging/admin/database/v1/src/v1/database_admin_client_config.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "interfaces": { - "google.spanner.admin.database.v1.DatabaseAdmin": { - "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 - }, - "e9fafda332ce8a1702dc1575de3ca81c4feb4799": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 32000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListDatabases": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "CreateDatabase": { - "timeout_millis": 3600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetDatabase": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "UpdateDatabaseDdl": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "DropDatabase": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "GetDatabaseDdl": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "SetIamPolicy": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "TestIamPermissions": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateBackup": { - "timeout_millis": 3600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CopyBackup": { - "timeout_millis": 3600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetBackup": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "UpdateBackup": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "DeleteBackup": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "ListBackups": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "RestoreDatabase": { - "timeout_millis": 3600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListDatabaseOperations": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "ListBackupOperations": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "ListDatabaseRoles": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - } - } - } - } -} diff --git a/owl-bot-staging/admin/database/v1/src/v1/database_admin_proto_list.json b/owl-bot-staging/admin/database/v1/src/v1/database_admin_proto_list.json deleted file mode 100644 index c20bcc2fc..000000000 --- a/owl-bot-staging/admin/database/v1/src/v1/database_admin_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/spanner/admin/database/v1/backup.proto", - "../../protos/google/spanner/admin/database/v1/common.proto", - "../../protos/google/spanner/admin/database/v1/spanner_database_admin.proto" -] diff --git a/owl-bot-staging/admin/database/v1/src/v1/gapic_metadata.json b/owl-bot-staging/admin/database/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 95da9430f..000000000 --- a/owl-bot-staging/admin/database/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,233 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.spanner.admin.database.v1", - "libraryPackage": "@google-cloud/spanner", - "services": { - "DatabaseAdmin": { - "clients": { - "grpc": { - "libraryClient": "DatabaseAdminClient", - "rpcs": { - "GetDatabase": { - "methods": [ - "getDatabase" - ] - }, - "DropDatabase": { - "methods": [ - "dropDatabase" - ] - }, - "GetDatabaseDdl": { - "methods": [ - "getDatabaseDdl" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "GetBackup": { - "methods": [ - "getBackup" - ] - }, - "UpdateBackup": { - "methods": [ - "updateBackup" - ] - }, - "DeleteBackup": { - "methods": [ - "deleteBackup" - ] - }, - "CreateDatabase": { - "methods": [ - "createDatabase" - ] - }, - "UpdateDatabaseDdl": { - "methods": [ - "updateDatabaseDdl" - ] - }, - "CreateBackup": { - "methods": [ - "createBackup" - ] - }, - "CopyBackup": { - "methods": [ - "copyBackup" - ] - }, - "RestoreDatabase": { - "methods": [ - "restoreDatabase" - ] - }, - "ListDatabases": { - "methods": [ - "listDatabases", - "listDatabasesStream", - "listDatabasesAsync" - ] - }, - "ListBackups": { - "methods": [ - "listBackups", - "listBackupsStream", - "listBackupsAsync" - ] - }, - "ListDatabaseOperations": { - "methods": [ - "listDatabaseOperations", - "listDatabaseOperationsStream", - "listDatabaseOperationsAsync" - ] - }, - "ListBackupOperations": { - "methods": [ - "listBackupOperations", - "listBackupOperationsStream", - "listBackupOperationsAsync" - ] - }, - "ListDatabaseRoles": { - "methods": [ - "listDatabaseRoles", - "listDatabaseRolesStream", - "listDatabaseRolesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DatabaseAdminClient", - "rpcs": { - "GetDatabase": { - "methods": [ - "getDatabase" - ] - }, - "DropDatabase": { - "methods": [ - "dropDatabase" - ] - }, - "GetDatabaseDdl": { - "methods": [ - "getDatabaseDdl" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "GetBackup": { - "methods": [ - "getBackup" - ] - }, - "UpdateBackup": { - "methods": [ - "updateBackup" - ] - }, - "DeleteBackup": { - "methods": [ - "deleteBackup" - ] - }, - "CreateDatabase": { - "methods": [ - "createDatabase" - ] - }, - "UpdateDatabaseDdl": { - "methods": [ - "updateDatabaseDdl" - ] - }, - "CreateBackup": { - "methods": [ - "createBackup" - ] - }, - "CopyBackup": { - "methods": [ - "copyBackup" - ] - }, - "RestoreDatabase": { - "methods": [ - "restoreDatabase" - ] - }, - "ListDatabases": { - "methods": [ - "listDatabases", - "listDatabasesStream", - "listDatabasesAsync" - ] - }, - "ListBackups": { - "methods": [ - "listBackups", - "listBackupsStream", - "listBackupsAsync" - ] - }, - "ListDatabaseOperations": { - "methods": [ - "listDatabaseOperations", - "listDatabaseOperationsStream", - "listDatabaseOperationsAsync" - ] - }, - "ListBackupOperations": { - "methods": [ - "listBackupOperations", - "listBackupOperationsStream", - "listBackupOperationsAsync" - ] - }, - "ListDatabaseRoles": { - "methods": [ - "listDatabaseRoles", - "listDatabaseRolesStream", - "listDatabaseRolesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/admin/database/v1/src/v1/index.ts b/owl-bot-staging/admin/database/v1/src/v1/index.ts deleted file mode 100644 index 09d882a27..000000000 --- a/owl-bot-staging/admin/database/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 {DatabaseAdminClient} from './database_admin_client'; diff --git a/owl-bot-staging/admin/database/v1/test/gapic_database_admin_v1.ts b/owl-bot-staging/admin/database/v1/test/gapic_database_admin_v1.ts deleted file mode 100644 index 0e6b3f948..000000000 --- a/owl-bot-staging/admin/database/v1/test/gapic_database_admin_v1.ts +++ /dev/null @@ -1,3680 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 databaseadminModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -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('v1.DatabaseAdminClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = databaseadminModule.v1.DatabaseAdminClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = databaseadminModule.v1.DatabaseAdminClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = databaseadminModule.v1.DatabaseAdminClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new databaseadminModule.v1.DatabaseAdminClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.databaseAdminStub, undefined); - await client.initialize(); - assert(client.databaseAdminStub); - }); - - it('has close method for the initialized client', done => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.databaseAdminStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.databaseAdminStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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 databaseadminModule.v1.DatabaseAdminClient({ - 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('getDatabase', () => { - it('invokes getDatabase without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.database.v1.Database() - ); - client.innerApiCalls.getDatabase = stubSimpleCall(expectedResponse); - const [response] = await client.getDatabase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDatabase without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.database.v1.Database() - ); - client.innerApiCalls.getDatabase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDatabase( - request, - (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IDatabase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDatabase with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDatabase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDatabase with closed client', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDatabase(request), expectedError); - }); - }); - - describe('dropDatabase', () => { - it('invokes dropDatabase without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.DropDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.DropDatabaseRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.dropDatabase = stubSimpleCall(expectedResponse); - const [response] = await client.dropDatabase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.dropDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.dropDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes dropDatabase without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.DropDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.DropDatabaseRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.dropDatabase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.dropDatabase( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.dropDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.dropDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes dropDatabase with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.DropDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.DropDatabaseRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.dropDatabase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.dropDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.dropDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.dropDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes dropDatabase with closed client', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.DropDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.DropDatabaseRequest', ['database']); - request.database = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.dropDatabase(request), expectedError); - }); - }); - - describe('getDatabaseDdl', () => { - it('invokes getDatabaseDdl without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseDdlRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetDatabaseDdlResponse() - ); - client.innerApiCalls.getDatabaseDdl = stubSimpleCall(expectedResponse); - const [response] = await client.getDatabaseDdl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDatabaseDdl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabaseDdl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDatabaseDdl without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseDdlRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetDatabaseDdlResponse() - ); - client.innerApiCalls.getDatabaseDdl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDatabaseDdl( - request, - (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IGetDatabaseDdlResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDatabaseDdl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabaseDdl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDatabaseDdl with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseDdlRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDatabaseDdl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDatabaseDdl(request), expectedError); - const actualRequest = (client.innerApiCalls.getDatabaseDdl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabaseDdl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDatabaseDdl with closed client', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetDatabaseDdlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetDatabaseDdlRequest', ['database']); - request.database = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDatabaseDdl(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('getBackup', () => { - it('invokes getBackup without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.database.v1.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); - const [response] = await client.getBackup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBackup without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.database.v1.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackup( - request, - (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IBackup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBackup with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBackup with closed client', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getBackup(request), expectedError); - }); - }); - - describe('updateBackup', () => { - it('invokes updateBackup without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.database.v1.Backup() - ); - client.innerApiCalls.updateBackup = stubSimpleCall(expectedResponse); - const [response] = await client.updateBackup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackup without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.database.v1.Backup() - ); - client.innerApiCalls.updateBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateBackup( - request, - (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IBackup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackup with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBackup with closed client', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateBackup(request), expectedError); - }); - }); - - describe('deleteBackup', () => { - it('invokes deleteBackup without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteBackup = stubSimpleCall(expectedResponse); - const [response] = await client.deleteBackup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackup( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteBackup with closed client', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteBackup(request), expectedError); - }); - }); - - describe('createDatabase', () => { - it('invokes createDatabase without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.createDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDatabase without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDatabase( - 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); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDatabase with call error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDatabase with LRO error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateDatabaseProgress without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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.checkCreateDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateDatabaseProgress with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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.checkCreateDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateDatabaseDdl', () => { - it('invokes updateDatabaseDdl without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateDatabaseDdl = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateDatabaseDdl(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDatabaseDdl without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateDatabaseDdl = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDatabaseDdl( - 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); - const actualRequest = (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDatabaseDdl with call error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDatabaseDdl = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateDatabaseDdl(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDatabaseDdl with LRO error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDatabaseDdl = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateDatabaseDdl(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabaseDdl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateDatabaseDdlProgress without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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.checkUpdateDatabaseDdlProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateDatabaseDdlProgress with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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.checkUpdateDatabaseDdlProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createBackup', () => { - it('invokes createBackup without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.createBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBackup( - 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); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup with call error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createBackup with LRO error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateBackupProgress without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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.checkCreateBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateBackupProgress with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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.checkCreateBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('copyBackup', () => { - it('invokes copyBackup without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CopyBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CopyBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.copyBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.copyBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes copyBackup without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CopyBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CopyBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.copyBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.copyBackup( - 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); - const actualRequest = (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes copyBackup with call error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CopyBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CopyBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.copyBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.copyBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes copyBackup with LRO error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.CopyBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.CopyBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.copyBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.copyBackup(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCopyBackupProgress without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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.checkCopyBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCopyBackupProgress with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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.checkCopyBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('restoreDatabase', () => { - it('invokes restoreDatabase without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.RestoreDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.restoreDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreDatabase without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.RestoreDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.restoreDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restoreDatabase( - 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); - const actualRequest = (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreDatabase with call error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.RestoreDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.restoreDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreDatabase with LRO error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.RestoreDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.RestoreDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.restoreDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRestoreDatabaseProgress without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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.checkRestoreDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRestoreDatabaseProgress with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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.checkRestoreDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listDatabases', () => { - it('invokes listDatabases without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - ]; - client.innerApiCalls.listDatabases = stubSimpleCall(expectedResponse); - const [response] = await client.listDatabases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabases without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - ]; - client.innerApiCalls.listDatabases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDatabases( - request, - (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IDatabase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabases with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDatabases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDatabases(request), expectedError); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabasesStream without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - ]; - client.descriptors.page.listDatabases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDatabasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.admin.database.v1.Database[] = []; - stream.on('data', (response: protos.google.spanner.admin.database.v1.Database) => { - 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.listDatabases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatabases, request)); - assert( - (client.descriptors.page.listDatabases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listDatabasesStream with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatabases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDatabasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.admin.database.v1.Database[] = []; - stream.on('data', (response: protos.google.spanner.admin.database.v1.Database) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDatabases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatabases, request)); - assert( - (client.descriptors.page.listDatabases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDatabases without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Database()), - ]; - client.descriptors.page.listDatabases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.spanner.admin.database.v1.IDatabase[] = []; - const iterable = client.listDatabasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDatabases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatabases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDatabases with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatabases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDatabasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.spanner.admin.database.v1.IDatabase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDatabases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatabases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listBackups', () => { - it('invokes listBackups without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); - const [response] = await client.listBackups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackups without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackups( - request, - (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IBackup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackups with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackups(request), expectedError); - const actualRequest = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackupsStream without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - ]; - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.admin.database.v1.Backup[] = []; - stream.on('data', (response: protos.google.spanner.admin.database.v1.Backup) => { - 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.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listBackupsStream with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.admin.database.v1.Backup[] = []; - stream.on('data', (response: protos.google.spanner.admin.database.v1.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBackups without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.Backup()), - ]; - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.spanner.admin.database.v1.IBackup[] = []; - const iterable = client.listBackupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBackups with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.spanner.admin.database.v1.IBackup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listDatabaseOperations', () => { - it('invokes listDatabaseOperations without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.innerApiCalls.listDatabaseOperations = stubSimpleCall(expectedResponse); - const [response] = await client.listDatabaseOperations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatabaseOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabaseOperations without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.innerApiCalls.listDatabaseOperations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDatabaseOperations( - request, - (err?: Error|null, result?: protos.google.longrunning.IOperation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatabaseOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabaseOperations with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDatabaseOperations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDatabaseOperations(request), expectedError); - const actualRequest = (client.innerApiCalls.listDatabaseOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabaseOperationsStream without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.descriptors.page.listDatabaseOperations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDatabaseOperationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.longrunning.Operation[] = []; - stream.on('data', (response: protos.google.longrunning.Operation) => { - 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.listDatabaseOperations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatabaseOperations, request)); - assert( - (client.descriptors.page.listDatabaseOperations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listDatabaseOperationsStream with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatabaseOperations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDatabaseOperationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.longrunning.Operation[] = []; - stream.on('data', (response: protos.google.longrunning.Operation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDatabaseOperations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatabaseOperations, request)); - assert( - (client.descriptors.page.listDatabaseOperations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDatabaseOperations without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.descriptors.page.listDatabaseOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.longrunning.IOperation[] = []; - const iterable = client.listDatabaseOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDatabaseOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatabaseOperations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDatabaseOperations with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatabaseOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDatabaseOperationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDatabaseOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatabaseOperations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listBackupOperations', () => { - it('invokes listBackupOperations without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.innerApiCalls.listBackupOperations = stubSimpleCall(expectedResponse); - const [response] = await client.listBackupOperations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackupOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackupOperations without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.innerApiCalls.listBackupOperations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackupOperations( - request, - (err?: Error|null, result?: protos.google.longrunning.IOperation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBackupOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackupOperations with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackupOperations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackupOperations(request), expectedError); - const actualRequest = (client.innerApiCalls.listBackupOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBackupOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBackupOperationsStream without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.descriptors.page.listBackupOperations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupOperationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.longrunning.Operation[] = []; - stream.on('data', (response: protos.google.longrunning.Operation) => { - 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.listBackupOperations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackupOperations, request)); - assert( - (client.descriptors.page.listBackupOperations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listBackupOperationsStream with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackupOperations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupOperationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.longrunning.Operation[] = []; - stream.on('data', (response: protos.google.longrunning.Operation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackupOperations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackupOperations, request)); - assert( - (client.descriptors.page.listBackupOperations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBackupOperations without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.descriptors.page.listBackupOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.longrunning.IOperation[] = []; - const iterable = client.listBackupOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackupOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackupOperations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBackupOperations with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListBackupOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListBackupOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listBackupOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupOperationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackupOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBackupOperations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listDatabaseRoles', () => { - it('invokes listDatabaseRoles without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - ]; - client.innerApiCalls.listDatabaseRoles = stubSimpleCall(expectedResponse); - const [response] = await client.listDatabaseRoles(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatabaseRoles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseRoles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabaseRoles without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - ]; - client.innerApiCalls.listDatabaseRoles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDatabaseRoles( - request, - (err?: Error|null, result?: protos.google.spanner.admin.database.v1.IDatabaseRole[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatabaseRoles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseRoles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabaseRoles with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDatabaseRoles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDatabaseRoles(request), expectedError); - const actualRequest = (client.innerApiCalls.listDatabaseRoles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabaseRoles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatabaseRolesStream without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - ]; - client.descriptors.page.listDatabaseRoles.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDatabaseRolesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.admin.database.v1.DatabaseRole[] = []; - stream.on('data', (response: protos.google.spanner.admin.database.v1.DatabaseRole) => { - 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.listDatabaseRoles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatabaseRoles, request)); - assert( - (client.descriptors.page.listDatabaseRoles.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listDatabaseRolesStream with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatabaseRoles.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDatabaseRolesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.admin.database.v1.DatabaseRole[] = []; - stream.on('data', (response: protos.google.spanner.admin.database.v1.DatabaseRole) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDatabaseRoles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatabaseRoles, request)); - assert( - (client.descriptors.page.listDatabaseRoles.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDatabaseRoles without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - generateSampleMessage(new protos.google.spanner.admin.database.v1.DatabaseRole()), - ]; - client.descriptors.page.listDatabaseRoles.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.spanner.admin.database.v1.IDatabaseRole[] = []; - const iterable = client.listDatabaseRolesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDatabaseRoles with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.database.v1.ListDatabaseRolesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.database.v1.ListDatabaseRolesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatabaseRoles.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDatabaseRolesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.spanner.admin.database.v1.IDatabaseRole[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatabaseRoles.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('backup', () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - backup: "backupValue", - }; - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "instanceValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromBackupName', () => { - const result = client.matchInstanceFromBackupName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('cryptoKey', () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new databaseadminModule.v1.DatabaseAdminClient({ - 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('database', () => { - const fakePath = "/rendered/path/database"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - database: "databaseValue", - }; - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.databasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.databasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('databasePath', () => { - const result = client.databasePath("projectValue", "instanceValue", "databaseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.databasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDatabaseName', () => { - const result = client.matchProjectFromDatabaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromDatabaseName', () => { - const result = client.matchInstanceFromDatabaseName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatabaseFromDatabaseName', () => { - const result = client.matchDatabaseFromDatabaseName(fakePath); - assert.strictEqual(result, "databaseValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('databaseRole', () => { - const fakePath = "/rendered/path/databaseRole"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - database: "databaseValue", - role: "roleValue", - }; - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.databaseRolePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.databaseRolePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('databaseRolePath', () => { - const result = client.databaseRolePath("projectValue", "instanceValue", "databaseValue", "roleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.databaseRolePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDatabaseRoleName', () => { - const result = client.matchProjectFromDatabaseRoleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.databaseRolePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromDatabaseRoleName', () => { - const result = client.matchInstanceFromDatabaseRoleName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.databaseRolePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatabaseFromDatabaseRoleName', () => { - const result = client.matchDatabaseFromDatabaseRoleName(fakePath); - assert.strictEqual(result, "databaseValue"); - assert((client.pathTemplates.databaseRolePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRoleFromDatabaseRoleName', () => { - const result = client.matchRoleFromDatabaseRoleName(fakePath); - assert.strictEqual(result, "roleValue"); - assert((client.pathTemplates.databaseRolePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('instance', () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - }; - const client = new databaseadminModule.v1.DatabaseAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/admin/database/v1/tsconfig.json b/owl-bot-staging/admin/database/v1/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/admin/database/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/admin/database/v1/webpack.config.js b/owl-bot-staging/admin/database/v1/webpack.config.js deleted file mode 100644 index ef04209ca..000000000 --- a/owl-bot-staging/admin/database/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'DatabaseAdmin', - filename: './database-admin.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/admin/instance/v1/.eslintignore b/owl-bot-staging/admin/instance/v1/.eslintignore deleted file mode 100644 index cfc348ec4..000000000 --- a/owl-bot-staging/admin/instance/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/admin/instance/v1/.eslintrc.json b/owl-bot-staging/admin/instance/v1/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/admin/instance/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/admin/instance/v1/.gitignore b/owl-bot-staging/admin/instance/v1/.gitignore deleted file mode 100644 index d4f03a0df..000000000 --- a/owl-bot-staging/admin/instance/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/admin/instance/v1/.jsdoc.js b/owl-bot-staging/admin/instance/v1/.jsdoc.js deleted file mode 100644 index e37e0473a..000000000 --- a/owl-bot-staging/admin/instance/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 2023 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/spanner', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/admin/instance/v1/.mocharc.js b/owl-bot-staging/admin/instance/v1/.mocharc.js deleted file mode 100644 index 1a38f257d..000000000 --- a/owl-bot-staging/admin/instance/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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/admin/instance/v1/.prettierrc.js b/owl-bot-staging/admin/instance/v1/.prettierrc.js deleted file mode 100644 index 55639e70f..000000000 --- a/owl-bot-staging/admin/instance/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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/admin/instance/v1/README.md b/owl-bot-staging/admin/instance/v1/README.md deleted file mode 100644 index 91e6e9efe..000000000 --- a/owl-bot-staging/admin/instance/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Instance: Nodejs Client diff --git a/owl-bot-staging/admin/instance/v1/linkinator.config.json b/owl-bot-staging/admin/instance/v1/linkinator.config.json deleted file mode 100644 index befd23c86..000000000 --- a/owl-bot-staging/admin/instance/v1/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/admin/instance/v1/package.json b/owl-bot-staging/admin/instance/v1/package.json deleted file mode 100644 index 8425e4680..000000000 --- a/owl-bot-staging/admin/instance/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/spanner", - "version": "0.1.0", - "description": "Instance client for Node.js", - "repository": "googleapis/nodejs-instance", - "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 instance", - "instance", - "instance admin" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "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.5.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/common.proto b/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/common.proto deleted file mode 100644 index e93b33476..000000000 --- a/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/common.proto +++ /dev/null @@ -1,42 +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.spanner.admin.instance.v1; - -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.Admin.Instance.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/admin/instance/v1;instance"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.spanner.admin.instance.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Instance\\V1"; -option ruby_package = "Google::Cloud::Spanner::Admin::Instance::V1"; - -// Encapsulates progress related information for a Cloud Spanner long -// running instance operations. -message OperationProgress { - // Percent completion of the operation. - // Values are between 0 and 100 inclusive. - int32 progress_percent = 1; - - // Time the request was received. - google.protobuf.Timestamp start_time = 2; - - // If set, the time at which this operation failed or was completed - // successfully. - google.protobuf.Timestamp end_time = 3; -} diff --git a/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto b/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto deleted file mode 100644 index 85b041134..000000000 --- a/owl-bot-staging/admin/instance/v1/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +++ /dev/null @@ -1,1081 +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.spanner.admin.instance.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/spanner/admin/instance/v1/common.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.Admin.Instance.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/admin/instance/v1;instance"; -option java_multiple_files = true; -option java_outer_classname = "SpannerInstanceAdminProto"; -option java_package = "com.google.spanner.admin.instance.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Instance\\V1"; -option ruby_package = "Google::Cloud::Spanner::Admin::Instance::V1"; - -// Cloud Spanner Instance Admin API -// -// The Cloud Spanner Instance Admin API can be used to create, delete, -// modify and list instances. Instances are dedicated Cloud Spanner serving -// and storage resources to be used by Cloud Spanner databases. -// -// Each instance has a "configuration", which dictates where the -// serving resources for the Cloud Spanner instance are located (e.g., -// US-central, Europe). Configurations are created by Google based on -// resource availability. -// -// Cloud Spanner billing is based on the instances that exist and their -// sizes. After an instance exists, there are no additional -// per-database or per-operation charges for use of the instance -// (though there may be additional network bandwidth charges). -// Instances offer isolation: problems with databases in one instance -// will not affect other instances. However, within an instance -// databases can affect each other. For example, if one database in an -// instance receives a lot of requests and consumes most of the -// instance resources, fewer resources are available for other -// databases in that instance, and their performance may suffer. -service InstanceAdmin { - option (google.api.default_host) = "spanner.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/spanner.admin"; - - // Lists the supported instance configurations for a given project. - rpc ListInstanceConfigs(ListInstanceConfigsRequest) - returns (ListInstanceConfigsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/instanceConfigs" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information about a particular instance configuration. - rpc GetInstanceConfig(GetInstanceConfigRequest) returns (InstanceConfig) { - option (google.api.http) = { - get: "/v1/{name=projects/*/instanceConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates an instance config and begins preparing it to be used. The - // returned [long-running operation][google.longrunning.Operation] - // can be used to track the progress of preparing the new - // instance config. The instance config name is assigned by the caller. If the - // named instance config already exists, `CreateInstanceConfig` returns - // `ALREADY_EXISTS`. - // - // Immediately after the request returns: - // - // * The instance config is readable via the API, with all requested - // attributes. The instance config's - // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] - // field is set to true. Its state is `CREATING`. - // - // While the operation is pending: - // - // * Cancelling the operation renders the instance config immediately - // unreadable via the API. - // * Except for deleting the creating resource, all other attempts to modify - // the instance config are rejected. - // - // Upon completion of the returned operation: - // - // * Instances can be created using the instance configuration. - // * The instance config's - // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] - // field becomes false. Its state becomes `READY`. - // - // The returned [long-running operation][google.longrunning.Operation] will - // have a name of the format - // `/operations/` and can be used to track - // creation of the instance config. The - // [metadata][google.longrunning.Operation.metadata] field type is - // [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. - // The [response][google.longrunning.Operation.response] field type is - // [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if - // successful. - // - // Authorization requires `spanner.instanceConfigs.create` permission on - // the resource - // [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent]. - rpc CreateInstanceConfig(CreateInstanceConfigRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/instanceConfigs" - body: "*" - }; - option (google.api.method_signature) = - "parent,instance_config,instance_config_id"; - option (google.longrunning.operation_info) = { - response_type: "google.spanner.admin.instance.v1.InstanceConfig" - metadata_type: "google.spanner.admin.instance.v1.CreateInstanceConfigMetadata" - }; - } - - // Updates an instance config. The returned - // [long-running operation][google.longrunning.Operation] can be used to track - // the progress of updating the instance. If the named instance config does - // not exist, returns `NOT_FOUND`. - // - // Only user managed configurations can be updated. - // - // Immediately after the request returns: - // - // * The instance config's - // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] - // field is set to true. - // - // While the operation is pending: - // - // * Cancelling the operation sets its metadata's - // [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time]. - // The operation is guaranteed to succeed at undoing all changes, after - // which point it terminates with a `CANCELLED` status. - // * All other attempts to modify the instance config are rejected. - // * Reading the instance config via the API continues to give the - // pre-request values. - // - // Upon completion of the returned operation: - // - // * Creating instances using the instance configuration uses the new - // values. - // * The instance config's new values are readable via the API. - // * The instance config's - // [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] - // field becomes false. - // - // The returned [long-running operation][google.longrunning.Operation] will - // have a name of the format - // `/operations/` and can be used to track - // the instance config modification. The - // [metadata][google.longrunning.Operation.metadata] field type is - // [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata]. - // The [response][google.longrunning.Operation.response] field type is - // [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if - // successful. - // - // Authorization requires `spanner.instanceConfigs.update` permission on - // the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. - rpc UpdateInstanceConfig(UpdateInstanceConfigRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{instance_config.name=projects/*/instanceConfigs/*}" - body: "*" - }; - option (google.api.method_signature) = "instance_config,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "google.spanner.admin.instance.v1.InstanceConfig" - metadata_type: "google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata" - }; - } - - // Deletes the instance config. Deletion is only allowed when no - // instances are using the configuration. If any instances are using - // the config, returns `FAILED_PRECONDITION`. - // - // Only user managed configurations can be deleted. - // - // Authorization requires `spanner.instanceConfigs.delete` permission on - // the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. - rpc DeleteInstanceConfig(DeleteInstanceConfigRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/instanceConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists the user-managed instance config [long-running - // operations][google.longrunning.Operation] in the given project. An instance - // config operation has a name of the form - // `projects//instanceConfigs//operations/`. - // The long-running operation - // [metadata][google.longrunning.Operation.metadata] field type - // `metadata.type_url` describes the type of the metadata. Operations returned - // include those that have completed/failed/canceled within the last 7 days, - // and pending operations. Operations returned are ordered by - // `operation.metadata.value.start_time` in descending order starting - // from the most recently started operation. - rpc ListInstanceConfigOperations(ListInstanceConfigOperationsRequest) - returns (ListInstanceConfigOperationsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/instanceConfigOperations" - }; - option (google.api.method_signature) = "parent"; - } - - // Lists all instances in the given project. - rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/instances" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information about a particular instance. - rpc GetInstance(GetInstanceRequest) returns (Instance) { - option (google.api.http) = { - get: "/v1/{name=projects/*/instances/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates an instance and begins preparing it to begin serving. The - // returned [long-running operation][google.longrunning.Operation] - // can be used to track the progress of preparing the new - // instance. The instance name is assigned by the caller. If the - // named instance already exists, `CreateInstance` returns - // `ALREADY_EXISTS`. - // - // Immediately upon completion of this request: - // - // * The instance is readable via the API, with all requested attributes - // but no allocated resources. Its state is `CREATING`. - // - // Until completion of the returned operation: - // - // * Cancelling the operation renders the instance immediately unreadable - // via the API. - // * The instance can be deleted. - // * All other attempts to modify the instance are rejected. - // - // Upon completion of the returned operation: - // - // * Billing for all successfully-allocated resources begins (some types - // may have lower than the requested levels). - // * Databases can be created in the instance. - // * The instance's allocated resource levels are readable via the API. - // * The instance's state becomes `READY`. - // - // The returned [long-running operation][google.longrunning.Operation] will - // have a name of the format `/operations/` and - // can be used to track creation of the instance. The - // [metadata][google.longrunning.Operation.metadata] field type is - // [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. - // The [response][google.longrunning.Operation.response] field type is - // [Instance][google.spanner.admin.instance.v1.Instance], if successful. - rpc CreateInstance(CreateInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/instances" - body: "*" - }; - option (google.api.method_signature) = "parent,instance_id,instance"; - option (google.longrunning.operation_info) = { - response_type: "google.spanner.admin.instance.v1.Instance" - metadata_type: "google.spanner.admin.instance.v1.CreateInstanceMetadata" - }; - } - - // Updates an instance, and begins allocating or releasing resources - // as requested. The returned [long-running - // operation][google.longrunning.Operation] can be used to track the - // progress of updating the instance. If the named instance does not - // exist, returns `NOT_FOUND`. - // - // Immediately upon completion of this request: - // - // * For resource types for which a decrease in the instance's allocation - // has been requested, billing is based on the newly-requested level. - // - // Until completion of the returned operation: - // - // * Cancelling the operation sets its metadata's - // [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], - // and begins restoring resources to their pre-request values. The - // operation is guaranteed to succeed at undoing all resource changes, - // after which point it terminates with a `CANCELLED` status. - // * All other attempts to modify the instance are rejected. - // * Reading the instance via the API continues to give the pre-request - // resource levels. - // - // Upon completion of the returned operation: - // - // * Billing begins for all successfully-allocated resources (some types - // may have lower than the requested levels). - // * All newly-reserved resources are available for serving the instance's - // tables. - // * The instance's new resource levels are readable via the API. - // - // The returned [long-running operation][google.longrunning.Operation] will - // have a name of the format `/operations/` and - // can be used to track the instance modification. The - // [metadata][google.longrunning.Operation.metadata] field type is - // [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. - // The [response][google.longrunning.Operation.response] field type is - // [Instance][google.spanner.admin.instance.v1.Instance], if successful. - // - // Authorization requires `spanner.instances.update` permission on - // the resource [name][google.spanner.admin.instance.v1.Instance.name]. - rpc UpdateInstance(UpdateInstanceRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{instance.name=projects/*/instances/*}" - body: "*" - }; - option (google.api.method_signature) = "instance,field_mask"; - option (google.longrunning.operation_info) = { - response_type: "google.spanner.admin.instance.v1.Instance" - metadata_type: "google.spanner.admin.instance.v1.UpdateInstanceMetadata" - }; - } - - // Deletes an instance. - // - // Immediately upon completion of the request: - // - // * Billing ceases for all of the instance's reserved resources. - // - // Soon afterward: - // - // * The instance and *all of its databases* immediately and - // irrevocably disappear from the API. All data in the databases - // is permanently deleted. - rpc DeleteInstance(DeleteInstanceRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/instances/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Sets the access control policy on an instance resource. Replaces any - // existing policy. - // - // Authorization requires `spanner.instances.setIamPolicy` on - // [resource][google.iam.v1.SetIamPolicyRequest.resource]. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/instances/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Gets the access control policy for an instance resource. Returns an empty - // policy if an instance exists but does not have a policy set. - // - // Authorization requires `spanner.instances.getIamPolicy` on - // [resource][google.iam.v1.GetIamPolicyRequest.resource]. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) - returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/instances/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Returns permissions that the caller has on the specified instance resource. - // - // Attempting this RPC on a non-existent Cloud Spanner instance resource will - // result in a NOT_FOUND error if the user has `spanner.instances.list` - // permission on the containing Google Cloud Project. Otherwise returns an - // empty set of permissions. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) - returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/instances/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -message ReplicaInfo { - // Indicates the type of replica. See the [replica types - // documentation](https://cloud.google.com/spanner/docs/replication#replica_types) - // for more details. - enum ReplicaType { - // Not specified. - TYPE_UNSPECIFIED = 0; - - // Read-write replicas support both reads and writes. These replicas: - // - // * Maintain a full copy of your data. - // * Serve reads. - // * Can vote whether to commit a write. - // * Participate in leadership election. - // * Are eligible to become a leader. - READ_WRITE = 1; - - // Read-only replicas only support reads (not writes). Read-only replicas: - // - // * Maintain a full copy of your data. - // * Serve reads. - // * Do not participate in voting to commit writes. - // * Are not eligible to become a leader. - READ_ONLY = 2; - - // Witness replicas don't support reads but do participate in voting to - // commit writes. Witness replicas: - // - // * Do not maintain a full copy of data. - // * Do not serve reads. - // * Vote whether to commit writes. - // * Participate in leader election but are not eligible to become leader. - WITNESS = 3; - } - - // The location of the serving resources, e.g. "us-central1". - string location = 1; - - // The type of replica. - ReplicaType type = 2; - - // If true, this location is designated as the default leader location where - // leader replicas are placed. See the [region types - // documentation](https://cloud.google.com/spanner/docs/instances#region_types) - // for more details. - bool default_leader_location = 3; -} - -// A possible configuration for a Cloud Spanner instance. Configurations -// define the geographic placement of nodes and their replication. -message InstanceConfig { - option (google.api.resource) = { - type: "spanner.googleapis.com/InstanceConfig" - pattern: "projects/{project}/instanceConfigs/{instance_config}" - }; - - // The type of this configuration. - enum Type { - // Unspecified. - TYPE_UNSPECIFIED = 0; - - // Google managed configuration. - GOOGLE_MANAGED = 1; - - // User managed configuration. - USER_MANAGED = 2; - } - - // Indicates the current state of the instance config. - enum State { - // Not specified. - STATE_UNSPECIFIED = 0; - - // The instance config is still being created. - CREATING = 1; - - // The instance config is fully created and ready to be used to create - // instances. - READY = 2; - } - - // A unique identifier for the instance configuration. Values - // are of the form - // `projects//instanceConfigs/[a-z][-a-z0-9]*`. - string name = 1; - - // The name of this instance configuration as it appears in UIs. - string display_name = 2; - - // Output only. Whether this instance config is a Google or User Managed - // Configuration. - Type config_type = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The geographic placement of nodes in this instance configuration and their - // replication properties. - repeated ReplicaInfo replicas = 3; - - // Output only. The available optional replicas to choose from for user - // managed configurations. Populated for Google managed configurations. - repeated ReplicaInfo optional_replicas = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Base configuration name, e.g. projects//instanceConfigs/nam3, - // based on which this configuration is created. Only set for user managed - // configurations. `base_config` must refer to a configuration of type - // GOOGLE_MANAGED in the same project as this configuration. - string base_config = 7 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/InstanceConfig" - }]; - - // Cloud Labels are a flexible and lightweight mechanism for organizing cloud - // resources into groups that reflect a customer's organizational needs and - // deployment strategies. Cloud Labels can be used to filter collections of - // resources. They can be used to control how resource metrics are aggregated. - // And they can be used as arguments to policy management rules (e.g. route, - // firewall, load balancing, etc.). - // - // * Label keys must be between 1 and 63 characters long and must conform to - // the following regular expression: `[a-z][a-z0-9_-]{0,62}`. - // * Label values must be between 0 and 63 characters long and must conform - // to the regular expression `[a-z0-9_-]{0,63}`. - // * No more than 64 labels can be associated with a given resource. - // - // See https://goo.gl/xmQnxf for more information on and examples of labels. - // - // If you plan to use labels in your own code, please note that additional - // characters may be allowed in the future. Therefore, you are advised to use - // an internal label representation, such as JSON, which doesn't rely upon - // specific characters being disallowed. For example, representing labels - // as the string: name + "_" + value would prove problematic if we were to - // allow "_" in a future release. - map labels = 8; - - // etag is used for optimistic concurrency control as a way - // to help prevent simultaneous updates of a instance config from overwriting - // each other. It is strongly suggested that systems make use of the etag in - // the read-modify-write cycle to perform instance config updates in order to - // avoid race conditions: An etag is returned in the response which contains - // instance configs, and systems are expected to put that etag in the request - // to update instance config to ensure that their change will be applied to - // the same version of the instance config. - // If no etag is provided in the call to update instance config, then the - // existing instance config is overwritten blindly. - string etag = 9; - - // Allowed values of the "default_leader" schema option for databases in - // instances that use this instance configuration. - repeated string leader_options = 4; - - // Output only. If true, the instance config is being created or updated. If - // false, there are no ongoing operations for the instance config. - bool reconciling = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The current instance config state. - State state = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// An isolated set of Cloud Spanner resources on which databases can be hosted. -message Instance { - option (google.api.resource) = { - type: "spanner.googleapis.com/Instance" - pattern: "projects/{project}/instances/{instance}" - }; - - // Indicates the current state of the instance. - enum State { - // Not specified. - STATE_UNSPECIFIED = 0; - - // The instance is still being created. Resources may not be - // available yet, and operations such as database creation may not - // work. - CREATING = 1; - - // The instance is fully created and ready to do work such as - // creating databases. - READY = 2; - } - - // Required. A unique identifier for the instance, which cannot be changed - // after the instance is created. Values are of the form - // `projects//instances/[a-z][-a-z0-9]*[a-z0-9]`. The final - // segment of the name must be between 2 and 64 characters in length. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The name of the instance's configuration. Values are of the form - // `projects//instanceConfigs/`. See - // also [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and - // [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. - string config = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/InstanceConfig" - } - ]; - - // Required. The descriptive name for this instance as it appears in UIs. - // Must be unique per project and between 4 and 30 characters in length. - string display_name = 3 [(google.api.field_behavior) = REQUIRED]; - - // The number of nodes allocated to this instance. At most one of either - // node_count or processing_units should be present in the message. This - // may be zero in API responses for instances that are not yet in state - // `READY`. - // - // See [the - // documentation](https://cloud.google.com/spanner/docs/compute-capacity) - // for more information about nodes and processing units. - int32 node_count = 5; - - // The number of processing units allocated to this instance. At most one of - // processing_units or node_count should be present in the message. This may - // be zero in API responses for instances that are not yet in state `READY`. - // - // See [the - // documentation](https://cloud.google.com/spanner/docs/compute-capacity) - // for more information about nodes and processing units. - int32 processing_units = 9; - - // Output only. The current instance state. For - // [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], - // the state must be either omitted or set to `CREATING`. For - // [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance], - // the state must be either omitted or set to `READY`. - State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Cloud Labels are a flexible and lightweight mechanism for organizing cloud - // resources into groups that reflect a customer's organizational needs and - // deployment strategies. Cloud Labels can be used to filter collections of - // resources. They can be used to control how resource metrics are aggregated. - // And they can be used as arguments to policy management rules (e.g. route, - // firewall, load balancing, etc.). - // - // * Label keys must be between 1 and 63 characters long and must conform to - // the following regular expression: `[a-z][a-z0-9_-]{0,62}`. - // * Label values must be between 0 and 63 characters long and must conform - // to the regular expression `[a-z0-9_-]{0,63}`. - // * No more than 64 labels can be associated with a given resource. - // - // See https://goo.gl/xmQnxf for more information on and examples of labels. - // - // If you plan to use labels in your own code, please note that additional - // characters may be allowed in the future. And so you are advised to use an - // internal label representation, such as JSON, which doesn't rely upon - // specific characters being disallowed. For example, representing labels - // as the string: name + "_" + value would prove problematic if we were to - // allow "_" in a future release. - map labels = 7; - - // Deprecated. This field is not populated. - repeated string endpoint_uris = 8; - - // Output only. The time at which the instance was created. - google.protobuf.Timestamp create_time = 11 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time at which the instance was most recently updated. - google.protobuf.Timestamp update_time = 12 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The request for -// [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. -message ListInstanceConfigsRequest { - // Required. The name of the project for which a list of supported instance - // configurations is requested. Values are of the form - // `projects/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Number of instance configurations to be returned in the response. If 0 or - // less, defaults to the server's maximum allowed page size. - int32 page_size = 2; - - // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token] - // from a previous - // [ListInstanceConfigsResponse][google.spanner.admin.instance.v1.ListInstanceConfigsResponse]. - string page_token = 3; -} - -// The response for -// [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. -message ListInstanceConfigsResponse { - // The list of requested instance configurations. - repeated InstanceConfig instance_configs = 1; - - // `next_page_token` can be sent in a subsequent - // [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs] - // call to fetch more of the matching instance configurations. - string next_page_token = 2; -} - -// The request for -// [GetInstanceConfigRequest][google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceConfig]. -message GetInstanceConfigRequest { - // Required. The name of the requested instance configuration. Values are of - // the form `projects//instanceConfigs/`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/InstanceConfig" - } - ]; -} - -// The request for -// [CreateInstanceConfigRequest][InstanceAdmin.CreateInstanceConfigRequest]. -message CreateInstanceConfigRequest { - // Required. The name of the project in which to create the instance config. - // Values are of the form `projects/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The ID of the instance config to create. Valid identifiers are - // of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 - // characters in length. The `custom-` prefix is required to avoid name - // conflicts with Google managed configurations. - string instance_config_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The InstanceConfig proto of the configuration to create. - // instance_config.name must be - // `/instanceConfigs/`. - // instance_config.base_config must be a Google managed configuration name, - // e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. - InstanceConfig instance_config = 3 [(google.api.field_behavior) = REQUIRED]; - - // An option to validate, but not actually execute, a request, - // and provide the same response. - bool validate_only = 4; -} - -// The request for -// [UpdateInstanceConfigRequest][InstanceAdmin.UpdateInstanceConfigRequest]. -message UpdateInstanceConfigRequest { - // Required. The user instance config to update, which must always include the - // instance config name. Otherwise, only fields mentioned in - // [update_mask][google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask] - // need be included. To prevent conflicts of concurrent updates, - // [etag][google.spanner.admin.instance.v1.InstanceConfig.reconciling] can - // be used. - InstanceConfig instance_config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A mask specifying which fields in - // [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] should be - // updated. The field mask must always be specified; this prevents any future - // fields in [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] - // from being erased accidentally by clients that do not know about them. Only - // display_name and labels can be updated. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = REQUIRED]; - - // An option to validate, but not actually execute, a request, - // and provide the same response. - bool validate_only = 3; -} - -// The request for -// [DeleteInstanceConfigRequest][InstanceAdmin.DeleteInstanceConfigRequest]. -message DeleteInstanceConfigRequest { - // Required. The name of the instance configuration to be deleted. - // Values are of the form - // `projects//instanceConfigs/` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/InstanceConfig" - } - ]; - - // Used for optimistic concurrency control as a way to help prevent - // simultaneous deletes of an instance config from overwriting each - // other. If not empty, the API - // only deletes the instance config when the etag provided matches the current - // status of the requested instance config. Otherwise, deletes the instance - // config without checking the current status of the requested instance - // config. - string etag = 2; - - // An option to validate, but not actually execute, a request, - // and provide the same response. - bool validate_only = 3; -} - -// The request for -// [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations]. -message ListInstanceConfigOperationsRequest { - // Required. The project of the instance config operations. - // Values are of the form `projects/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // An expression that filters the list of returned operations. - // - // A filter expression consists of a field name, a - // comparison operator, and a value for filtering. - // The value must be a string, a number, or a boolean. The comparison operator - // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - // Colon `:` is the contains operator. Filter rules are not case sensitive. - // - // The following fields in the [Operation][google.longrunning.Operation] - // are eligible for filtering: - // - // * `name` - The name of the long-running operation - // * `done` - False if the operation is in progress, else true. - // * `metadata.@type` - the type of metadata. For example, the type string - // for - // [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata] - // is - // `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. - // * `metadata.` - any field in metadata.value. - // `metadata.@type` must be specified first, if filtering on metadata - // fields. - // * `error` - Error associated with the long-running operation. - // * `response.@type` - the type of response. - // * `response.` - any field in response.value. - // - // You can combine multiple expressions by enclosing each expression in - // parentheses. By default, expressions are combined with AND logic. However, - // you can specify AND, OR, and NOT logic explicitly. - // - // Here are a few examples: - // - // * `done:true` - The operation is complete. - // * `(metadata.@type=` \ - // `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) - // AND` \ - // `(metadata.instance_config.name:custom-config) AND` \ - // `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ - // `(error:*)` - Return operations where: - // * The operation's metadata type is - // [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. - // * The instance config name contains "custom-config". - // * The operation started before 2021-03-28T14:50:00Z. - // * The operation resulted in an error. - string filter = 2; - - // Number of operations to be returned in the response. If 0 or - // less, defaults to the server's maximum allowed page size. - int32 page_size = 3; - - // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token] - // from a previous - // [ListInstanceConfigOperationsResponse][google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse] - // to the same `parent` and with the same `filter`. - string page_token = 4; -} - -// The response for -// [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations]. -message ListInstanceConfigOperationsResponse { - // The list of matching instance config [long-running - // operations][google.longrunning.Operation]. Each operation's name will be - // prefixed by the instance config's name. The operation's - // [metadata][google.longrunning.Operation.metadata] field type - // `metadata.type_url` describes the type of the metadata. - repeated google.longrunning.Operation operations = 1; - - // `next_page_token` can be sent in a subsequent - // [ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations] - // call to fetch more of the matching metadata. - string next_page_token = 2; -} - -// The request for -// [GetInstance][google.spanner.admin.instance.v1.InstanceAdmin.GetInstance]. -message GetInstanceRequest { - // Required. The name of the requested instance. Values are of the form - // `projects//instances/`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Instance" - } - ]; - - // If field_mask is present, specifies the subset of - // [Instance][google.spanner.admin.instance.v1.Instance] fields that should be - // returned. If absent, all - // [Instance][google.spanner.admin.instance.v1.Instance] fields are returned. - google.protobuf.FieldMask field_mask = 2; -} - -// The request for -// [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance]. -message CreateInstanceRequest { - // Required. The name of the project in which to create the instance. Values - // are of the form `projects/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The ID of the instance to create. Valid identifiers are of the - // form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in - // length. - string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The instance to create. The name may be omitted, but if - // specified must be `/instances/`. - Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// The request for -// [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances]. -message ListInstancesRequest { - // Required. The name of the project for which a list of instances is - // requested. Values are of the form `projects/`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Number of instances to be returned in the response. If 0 or less, defaults - // to the server's maximum allowed page size. - int32 page_size = 2; - - // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token] - // from a previous - // [ListInstancesResponse][google.spanner.admin.instance.v1.ListInstancesResponse]. - string page_token = 3; - - // An expression for filtering the results of the request. Filter rules are - // case insensitive. The fields eligible for filtering are: - // - // * `name` - // * `display_name` - // * `labels.key` where key is the name of a label - // - // Some examples of using filters are: - // - // * `name:*` --> The instance has a name. - // * `name:Howl` --> The instance's name contains the string "howl". - // * `name:HOWL` --> Equivalent to above. - // * `NAME:howl` --> Equivalent to above. - // * `labels.env:*` --> The instance has the label "env". - // * `labels.env:dev` --> The instance has the label "env" and the value of - // the label contains the string "dev". - // * `name:howl labels.env:dev` --> The instance's name contains "howl" and - // it has the label "env" with its value - // containing "dev". - string filter = 4; -} - -// The response for -// [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances]. -message ListInstancesResponse { - // The list of requested instances. - repeated Instance instances = 1; - - // `next_page_token` can be sent in a subsequent - // [ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances] - // call to fetch more of the matching instances. - string next_page_token = 2; -} - -// The request for -// [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance]. -message UpdateInstanceRequest { - // Required. The instance to update, which must always include the instance - // name. Otherwise, only fields mentioned in - // [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] - // need be included. - Instance instance = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. A mask specifying which fields in - // [Instance][google.spanner.admin.instance.v1.Instance] should be updated. - // The field mask must always be specified; this prevents any future fields in - // [Instance][google.spanner.admin.instance.v1.Instance] from being erased - // accidentally by clients that do not know about them. - google.protobuf.FieldMask field_mask = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// The request for -// [DeleteInstance][google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance]. -message DeleteInstanceRequest { - // Required. The name of the instance to be deleted. Values are of the form - // `projects//instances/` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Instance" - } - ]; -} - -// Metadata type for the operation returned by -// [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance]. -message CreateInstanceMetadata { - // The instance being created. - Instance instance = 1; - - // The time at which the - // [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance] - // request was received. - google.protobuf.Timestamp start_time = 2; - - // The time at which this operation was cancelled. If set, this operation is - // in the process of undoing itself (which is guaranteed to succeed) and - // cannot be cancelled again. - google.protobuf.Timestamp cancel_time = 3; - - // The time at which this operation failed or was completed successfully. - google.protobuf.Timestamp end_time = 4; -} - -// Metadata type for the operation returned by -// [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance]. -message UpdateInstanceMetadata { - // The desired end state of the update. - Instance instance = 1; - - // The time at which - // [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance] - // request was received. - google.protobuf.Timestamp start_time = 2; - - // The time at which this operation was cancelled. If set, this operation is - // in the process of undoing itself (which is guaranteed to succeed) and - // cannot be cancelled again. - google.protobuf.Timestamp cancel_time = 3; - - // The time at which this operation failed or was completed successfully. - google.protobuf.Timestamp end_time = 4; -} - -// Metadata type for the operation returned by -// [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig]. -message CreateInstanceConfigMetadata { - // The target instance config end state. - InstanceConfig instance_config = 1; - - // The progress of the - // [CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig] - // operation. - OperationProgress progress = 2; - - // The time at which this operation was cancelled. - google.protobuf.Timestamp cancel_time = 3; -} - -// Metadata type for the operation returned by -// [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig]. -message UpdateInstanceConfigMetadata { - // The desired instance config after updating. - InstanceConfig instance_config = 1; - - // The progress of the - // [UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig] - // operation. - OperationProgress progress = 2; - - // The time at which this operation was cancelled. - google.protobuf.Timestamp cancel_time = 3; -} diff --git a/owl-bot-staging/admin/instance/v1/src/index.ts b/owl-bot-staging/admin/instance/v1/src/index.ts deleted file mode 100644 index f535f33cd..000000000 --- a/owl-bot-staging/admin/instance/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const InstanceAdminClient = v1.InstanceAdminClient; -type InstanceAdminClient = v1.InstanceAdminClient; -export {v1, InstanceAdminClient}; -export default {v1, InstanceAdminClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/admin/instance/v1/src/v1/gapic_metadata.json b/owl-bot-staging/admin/instance/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 4a890f403..000000000 --- a/owl-bot-staging/admin/instance/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,175 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.spanner.admin.instance.v1", - "libraryPackage": "@google-cloud/spanner", - "services": { - "InstanceAdmin": { - "clients": { - "grpc": { - "libraryClient": "InstanceAdminClient", - "rpcs": { - "GetInstanceConfig": { - "methods": [ - "getInstanceConfig" - ] - }, - "DeleteInstanceConfig": { - "methods": [ - "deleteInstanceConfig" - ] - }, - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateInstanceConfig": { - "methods": [ - "createInstanceConfig" - ] - }, - "UpdateInstanceConfig": { - "methods": [ - "updateInstanceConfig" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "UpdateInstance": { - "methods": [ - "updateInstance" - ] - }, - "ListInstanceConfigs": { - "methods": [ - "listInstanceConfigs", - "listInstanceConfigsStream", - "listInstanceConfigsAsync" - ] - }, - "ListInstanceConfigOperations": { - "methods": [ - "listInstanceConfigOperations", - "listInstanceConfigOperationsStream", - "listInstanceConfigOperationsAsync" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "InstanceAdminClient", - "rpcs": { - "GetInstanceConfig": { - "methods": [ - "getInstanceConfig" - ] - }, - "DeleteInstanceConfig": { - "methods": [ - "deleteInstanceConfig" - ] - }, - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateInstanceConfig": { - "methods": [ - "createInstanceConfig" - ] - }, - "UpdateInstanceConfig": { - "methods": [ - "updateInstanceConfig" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "UpdateInstance": { - "methods": [ - "updateInstance" - ] - }, - "ListInstanceConfigs": { - "methods": [ - "listInstanceConfigs", - "listInstanceConfigsStream", - "listInstanceConfigsAsync" - ] - }, - "ListInstanceConfigOperations": { - "methods": [ - "listInstanceConfigOperations", - "listInstanceConfigOperationsStream", - "listInstanceConfigOperationsAsync" - ] - }, - "ListInstances": { - "methods": [ - "listInstances", - "listInstancesStream", - "listInstancesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/admin/instance/v1/src/v1/index.ts b/owl-bot-staging/admin/instance/v1/src/v1/index.ts deleted file mode 100644 index 172b60cb1..000000000 --- a/owl-bot-staging/admin/instance/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 {InstanceAdminClient} from './instance_admin_client'; diff --git a/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client.ts b/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client.ts deleted file mode 100644 index df33d5075..000000000 --- a/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client.ts +++ /dev/null @@ -1,2419 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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/v1/instance_admin_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './instance_admin_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Spanner Instance Admin API - * - * The Cloud Spanner Instance Admin API can be used to create, delete, - * modify and list instances. Instances are dedicated Cloud Spanner serving - * and storage resources to be used by Cloud Spanner databases. - * - * Each instance has a "configuration", which dictates where the - * serving resources for the Cloud Spanner instance are located (e.g., - * US-central, Europe). Configurations are created by Google based on - * resource availability. - * - * Cloud Spanner billing is based on the instances that exist and their - * sizes. After an instance exists, there are no additional - * per-database or per-operation charges for use of the instance - * (though there may be additional network bandwidth charges). - * Instances offer isolation: problems with databases in one instance - * will not affect other instances. However, within an instance - * databases can affect each other. For example, if one database in an - * instance receives a lot of requests and consumes most of the - * instance resources, fewer resources are available for other - * databases in that instance, and their performance may suffer. - * @class - * @memberof v1 - */ -export class InstanceAdminClient { - 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; - instanceAdminStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of InstanceAdminClient. - * - * @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 InstanceAdminClient({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 InstanceAdminClient; - 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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 = { - instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}' - ), - instanceConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instanceConfigs/{instance_config}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listInstanceConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instanceConfigs'), - listInstanceConfigOperations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'operations'), - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances') - }; - - 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.GetOperation',get: '/v1/{name=projects/*/instances/*/databases/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/instances/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/instances/*/databases/*/operations}',additional_bindings: [{get: '/v1/{name=projects/*/instances/*/operations}',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel',additional_bindings: [{post: '/v1/{name=projects/*/instances/*/operations/*}:cancel',}], - },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/instances/*/databases/*/operations/*}',additional_bindings: [{delete: '/v1/{name=projects/*/instances/*/operations/*}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createInstanceConfigResponse = protoFilesRoot.lookup( - '.google.spanner.admin.instance.v1.InstanceConfig') as gax.protobuf.Type; - const createInstanceConfigMetadata = protoFilesRoot.lookup( - '.google.spanner.admin.instance.v1.CreateInstanceConfigMetadata') as gax.protobuf.Type; - const updateInstanceConfigResponse = protoFilesRoot.lookup( - '.google.spanner.admin.instance.v1.InstanceConfig') as gax.protobuf.Type; - const updateInstanceConfigMetadata = protoFilesRoot.lookup( - '.google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata') as gax.protobuf.Type; - const createInstanceResponse = protoFilesRoot.lookup( - '.google.spanner.admin.instance.v1.Instance') as gax.protobuf.Type; - const createInstanceMetadata = protoFilesRoot.lookup( - '.google.spanner.admin.instance.v1.CreateInstanceMetadata') as gax.protobuf.Type; - const updateInstanceResponse = protoFilesRoot.lookup( - '.google.spanner.admin.instance.v1.Instance') as gax.protobuf.Type; - const updateInstanceMetadata = protoFilesRoot.lookup( - '.google.spanner.admin.instance.v1.UpdateInstanceMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createInstanceConfig: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createInstanceConfigResponse.decode.bind(createInstanceConfigResponse), - createInstanceConfigMetadata.decode.bind(createInstanceConfigMetadata)), - updateInstanceConfig: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateInstanceConfigResponse.decode.bind(updateInstanceConfigResponse), - updateInstanceConfigMetadata.decode.bind(updateInstanceConfigMetadata)), - createInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), - updateInstance: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateInstanceResponse.decode.bind(updateInstanceResponse), - updateInstanceMetadata.decode.bind(updateInstanceMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.spanner.admin.instance.v1.InstanceAdmin', 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.instanceAdminStub) { - return this.instanceAdminStub; - } - - // Put together the "service stub" for - // google.spanner.admin.instance.v1.InstanceAdmin. - this.instanceAdminStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.spanner.admin.instance.v1.InstanceAdmin') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.spanner.admin.instance.v1.InstanceAdmin, - 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 instanceAdminStubMethods = - ['listInstanceConfigs', 'getInstanceConfig', 'createInstanceConfig', 'updateInstanceConfig', 'deleteInstanceConfig', 'listInstanceConfigOperations', 'listInstances', 'getInstance', 'createInstance', 'updateInstance', 'deleteInstance', 'setIamPolicy', 'getIamPolicy', 'testIamPermissions']; - for (const methodName of instanceAdminStubMethods) { - const callPromise = this.instanceAdminStub.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.instanceAdminStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'spanner.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 'spanner.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', - 'https://www.googleapis.com/auth/spanner.admin' - ]; - } - - 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 particular instance configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the requested instance configuration. Values are of - * the form `projects//instanceConfigs/`. - * @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 {@link google.spanner.admin.instance.v1.InstanceConfig | InstanceConfig}. - * 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/v1/instance_admin.get_instance_config.js - * region_tag:spanner_v1_generated_InstanceAdmin_GetInstanceConfig_async - */ - getInstanceConfig( - request?: protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.instance.v1.IInstanceConfig, - protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|undefined, {}|undefined - ]>; - getInstanceConfig( - request: protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.admin.instance.v1.IInstanceConfig, - protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|null|undefined, - {}|null|undefined>): void; - getInstanceConfig( - request: protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest, - callback: Callback< - protos.google.spanner.admin.instance.v1.IInstanceConfig, - protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|null|undefined, - {}|null|undefined>): void; - getInstanceConfig( - request?: protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.admin.instance.v1.IInstanceConfig, - protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.admin.instance.v1.IInstanceConfig, - protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.admin.instance.v1.IInstanceConfig, - protos.google.spanner.admin.instance.v1.IGetInstanceConfigRequest|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({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInstanceConfig(request, options, callback); - } -/** - * Deletes the instance config. Deletion is only allowed when no - * instances are using the configuration. If any instances are using - * the config, returns `FAILED_PRECONDITION`. - * - * Only user managed configurations can be deleted. - * - * Authorization requires `spanner.instanceConfigs.delete` permission on - * the resource {@link google.spanner.admin.instance.v1.InstanceConfig.name|name}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the instance configuration to be deleted. - * Values are of the form - * `projects//instanceConfigs/` - * @param {string} request.etag - * Used for optimistic concurrency control as a way to help prevent - * simultaneous deletes of an instance config from overwriting each - * other. If not empty, the API - * only deletes the instance config when the etag provided matches the current - * status of the requested instance config. Otherwise, deletes the instance - * config without checking the current status of the requested instance - * config. - * @param {boolean} request.validateOnly - * An option to validate, but not actually execute, a request, - * and provide the same response. - * @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 {@link google.protobuf.Empty | Empty}. - * 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/v1/instance_admin.delete_instance_config.js - * region_tag:spanner_v1_generated_InstanceAdmin_DeleteInstanceConfig_async - */ - deleteInstanceConfig( - request?: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|undefined, {}|undefined - ]>; - deleteInstanceConfig( - request: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteInstanceConfig( - request: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteInstanceConfig( - request?: protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceConfigRequest|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({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteInstanceConfig(request, options, callback); - } -/** - * Gets information about a particular instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the requested instance. Values are of the form - * `projects//instances/`. - * @param {google.protobuf.FieldMask} request.fieldMask - * If field_mask is present, specifies the subset of - * {@link google.spanner.admin.instance.v1.Instance|Instance} fields that should be - * returned. If absent, all - * {@link google.spanner.admin.instance.v1.Instance|Instance} fields are returned. - * @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 {@link google.spanner.admin.instance.v1.Instance | Instance}. - * 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/v1/instance_admin.get_instance.js - * region_tag:spanner_v1_generated_InstanceAdmin_GetInstance_async - */ - getInstance( - request?: protos.google.spanner.admin.instance.v1.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.instance.v1.IInstance, - protos.google.spanner.admin.instance.v1.IGetInstanceRequest|undefined, {}|undefined - ]>; - getInstance( - request: protos.google.spanner.admin.instance.v1.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.admin.instance.v1.IInstance, - protos.google.spanner.admin.instance.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request: protos.google.spanner.admin.instance.v1.IGetInstanceRequest, - callback: Callback< - protos.google.spanner.admin.instance.v1.IInstance, - protos.google.spanner.admin.instance.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; - getInstance( - request?: protos.google.spanner.admin.instance.v1.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.admin.instance.v1.IInstance, - protos.google.spanner.admin.instance.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.admin.instance.v1.IInstance, - protos.google.spanner.admin.instance.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.admin.instance.v1.IInstance, - protos.google.spanner.admin.instance.v1.IGetInstanceRequest|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({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getInstance(request, options, callback); - } -/** - * Deletes an instance. - * - * Immediately upon completion of the request: - * - * * Billing ceases for all of the instance's reserved resources. - * - * Soon afterward: - * - * * The instance and *all of its databases* immediately and - * irrevocably disappear from the API. All data in the databases - * is permanently deleted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the instance to be deleted. Values are of the form - * `projects//instances/` - * @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 {@link google.protobuf.Empty | Empty}. - * 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/v1/instance_admin.delete_instance.js - * region_tag:spanner_v1_generated_InstanceAdmin_DeleteInstance_async - */ - deleteInstance( - request?: protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|undefined, {}|undefined - ]>; - deleteInstance( - request: protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request: protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|null|undefined, - {}|null|undefined>): void; - deleteInstance( - request?: protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.admin.instance.v1.IDeleteInstanceRequest|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({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteInstance(request, options, callback); - } -/** - * Sets the access control policy on an instance resource. Replaces any - * existing policy. - * - * Authorization requires `spanner.instances.setIamPolicy` on - * {@link google.iam.v1.SetIamPolicyRequest.resource|resource}. - * - * @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 {@link google.iam.v1.Policy | 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/v1/instance_admin.set_iam_policy.js - * region_tag:spanner_v1_generated_InstanceAdmin_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); - } -/** - * Gets the access control policy for an instance resource. Returns an empty - * policy if an instance exists but does not have a policy set. - * - * Authorization requires `spanner.instances.getIamPolicy` on - * {@link google.iam.v1.GetIamPolicyRequest.resource|resource}. - * - * @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 {@link google.iam.v1.Policy | 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/v1/instance_admin.get_iam_policy.js - * region_tag:spanner_v1_generated_InstanceAdmin_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); - } -/** - * Returns permissions that the caller has on the specified instance resource. - * - * Attempting this RPC on a non-existent Cloud Spanner instance resource will - * result in a NOT_FOUND error if the user has `spanner.instances.list` - * permission on the containing Google Cloud Project. Otherwise returns an - * empty set of permissions. - * - * @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 {@link google.iam.v1.TestIamPermissionsResponse | 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/v1/instance_admin.test_iam_permissions.js - * region_tag:spanner_v1_generated_InstanceAdmin_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 an instance config and begins preparing it to be used. The - * returned {@link google.longrunning.Operation|long-running operation} - * can be used to track the progress of preparing the new - * instance config. The instance config name is assigned by the caller. If the - * named instance config already exists, `CreateInstanceConfig` returns - * `ALREADY_EXISTS`. - * - * Immediately after the request returns: - * - * * The instance config is readable via the API, with all requested - * attributes. The instance config's - * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} - * field is set to true. Its state is `CREATING`. - * - * While the operation is pending: - * - * * Cancelling the operation renders the instance config immediately - * unreadable via the API. - * * Except for deleting the creating resource, all other attempts to modify - * the instance config are rejected. - * - * Upon completion of the returned operation: - * - * * Instances can be created using the instance configuration. - * * The instance config's - * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} - * field becomes false. Its state becomes `READY`. - * - * The returned {@link google.longrunning.Operation|long-running operation} will - * have a name of the format - * `/operations/` and can be used to track - * creation of the instance config. The - * {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. - * The {@link google.longrunning.Operation.response|response} field type is - * {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig}, if - * successful. - * - * Authorization requires `spanner.instanceConfigs.create` permission on - * the resource - * {@link google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent|parent}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which to create the instance config. - * Values are of the form `projects/`. - * @param {string} request.instanceConfigId - * Required. The ID of the instance config to create. Valid identifiers are - * of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 - * characters in length. The `custom-` prefix is required to avoid name - * conflicts with Google managed configurations. - * @param {google.spanner.admin.instance.v1.InstanceConfig} request.instanceConfig - * Required. The InstanceConfig proto of the configuration to create. - * instance_config.name must be - * `/instanceConfigs/`. - * instance_config.base_config must be a Google managed configuration name, - * e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3. - * @param {boolean} request.validateOnly - * An option to validate, but not actually execute, a request, - * and provide the same response. - * @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/v1/instance_admin.create_instance_config.js - * region_tag:spanner_v1_generated_InstanceAdmin_CreateInstanceConfig_async - */ - createInstanceConfig( - request?: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createInstanceConfig( - request: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstanceConfig( - request: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstanceConfig( - request?: protos.google.spanner.admin.instance.v1.ICreateInstanceConfigRequest, - 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 || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createInstanceConfig(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createInstanceConfig()`. - * @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/v1/instance_admin.create_instance_config.js - * region_tag:spanner_v1_generated_InstanceAdmin_CreateInstanceConfig_async - */ - async checkCreateInstanceConfigProgress(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.createInstanceConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates an instance config. The returned - * {@link google.longrunning.Operation|long-running operation} can be used to track - * the progress of updating the instance. If the named instance config does - * not exist, returns `NOT_FOUND`. - * - * Only user managed configurations can be updated. - * - * Immediately after the request returns: - * - * * The instance config's - * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} - * field is set to true. - * - * While the operation is pending: - * - * * Cancelling the operation sets its metadata's - * {@link google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time|cancel_time}. - * The operation is guaranteed to succeed at undoing all changes, after - * which point it terminates with a `CANCELLED` status. - * * All other attempts to modify the instance config are rejected. - * * Reading the instance config via the API continues to give the - * pre-request values. - * - * Upon completion of the returned operation: - * - * * Creating instances using the instance configuration uses the new - * values. - * * The instance config's new values are readable via the API. - * * The instance config's - * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|reconciling} - * field becomes false. - * - * The returned {@link google.longrunning.Operation|long-running operation} will - * have a name of the format - * `/operations/` and can be used to track - * the instance config modification. The - * {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata|UpdateInstanceConfigMetadata}. - * The {@link google.longrunning.Operation.response|response} field type is - * {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig}, if - * successful. - * - * Authorization requires `spanner.instanceConfigs.update` permission on - * the resource {@link google.spanner.admin.instance.v1.InstanceConfig.name|name}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.spanner.admin.instance.v1.InstanceConfig} request.instanceConfig - * Required. The user instance config to update, which must always include the - * instance config name. Otherwise, only fields mentioned in - * {@link google.spanner.admin.instance.v1.UpdateInstanceConfigRequest.update_mask|update_mask} - * need be included. To prevent conflicts of concurrent updates, - * {@link google.spanner.admin.instance.v1.InstanceConfig.reconciling|etag} can - * be used. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A mask specifying which fields in - * {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig} should be - * updated. The field mask must always be specified; this prevents any future - * fields in {@link google.spanner.admin.instance.v1.InstanceConfig|InstanceConfig} - * from being erased accidentally by clients that do not know about them. Only - * display_name and labels can be updated. - * @param {boolean} request.validateOnly - * An option to validate, but not actually execute, a request, - * and provide the same response. - * @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/v1/instance_admin.update_instance_config.js - * region_tag:spanner_v1_generated_InstanceAdmin_UpdateInstanceConfig_async - */ - updateInstanceConfig( - request?: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateInstanceConfig( - request: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstanceConfig( - request: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstanceConfig( - request?: protos.google.spanner.admin.instance.v1.IUpdateInstanceConfigRequest, - 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 || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'instance_config.name': request.instanceConfig!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateInstanceConfig(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateInstanceConfig()`. - * @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/v1/instance_admin.update_instance_config.js - * region_tag:spanner_v1_generated_InstanceAdmin_UpdateInstanceConfig_async - */ - async checkUpdateInstanceConfigProgress(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.updateInstanceConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates an instance and begins preparing it to begin serving. The - * returned {@link google.longrunning.Operation|long-running operation} - * can be used to track the progress of preparing the new - * instance. The instance name is assigned by the caller. If the - * named instance already exists, `CreateInstance` returns - * `ALREADY_EXISTS`. - * - * Immediately upon completion of this request: - * - * * The instance is readable via the API, with all requested attributes - * but no allocated resources. Its state is `CREATING`. - * - * Until completion of the returned operation: - * - * * Cancelling the operation renders the instance immediately unreadable - * via the API. - * * The instance can be deleted. - * * All other attempts to modify the instance are rejected. - * - * Upon completion of the returned operation: - * - * * Billing for all successfully-allocated resources begins (some types - * may have lower than the requested levels). - * * Databases can be created in the instance. - * * The instance's allocated resource levels are readable via the API. - * * The instance's state becomes `READY`. - * - * The returned {@link google.longrunning.Operation|long-running operation} will - * have a name of the format `/operations/` and - * can be used to track creation of the instance. The - * {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.spanner.admin.instance.v1.CreateInstanceMetadata|CreateInstanceMetadata}. - * The {@link google.longrunning.Operation.response|response} field type is - * {@link google.spanner.admin.instance.v1.Instance|Instance}, if successful. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which to create the instance. Values - * are of the form `projects/`. - * @param {string} request.instanceId - * Required. The ID of the instance to create. Valid identifiers are of the - * form `{@link -a-z0-9|a-z}*[a-z0-9]` and must be between 2 and 64 characters in - * length. - * @param {google.spanner.admin.instance.v1.Instance} request.instance - * Required. The instance to create. The name may be omitted, but if - * specified must be `/instances/`. - * @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/v1/instance_admin.create_instance.js - * region_tag:spanner_v1_generated_InstanceAdmin_CreateInstance_async - */ - createInstance( - request?: protos.google.spanner.admin.instance.v1.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createInstance( - request: protos.google.spanner.admin.instance.v1.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request: protos.google.spanner.admin.instance.v1.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createInstance( - request?: protos.google.spanner.admin.instance.v1.ICreateInstanceRequest, - 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 || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @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/v1/instance_admin.create_instance.js - * region_tag:spanner_v1_generated_InstanceAdmin_CreateInstance_async - */ - async checkCreateInstanceProgress(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.createInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates an instance, and begins allocating or releasing resources - * as requested. The returned [long-running - * operation][google.longrunning.Operation] can be used to track the - * progress of updating the instance. If the named instance does not - * exist, returns `NOT_FOUND`. - * - * Immediately upon completion of this request: - * - * * For resource types for which a decrease in the instance's allocation - * has been requested, billing is based on the newly-requested level. - * - * Until completion of the returned operation: - * - * * Cancelling the operation sets its metadata's - * {@link google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time|cancel_time}, - * and begins restoring resources to their pre-request values. The - * operation is guaranteed to succeed at undoing all resource changes, - * after which point it terminates with a `CANCELLED` status. - * * All other attempts to modify the instance are rejected. - * * Reading the instance via the API continues to give the pre-request - * resource levels. - * - * Upon completion of the returned operation: - * - * * Billing begins for all successfully-allocated resources (some types - * may have lower than the requested levels). - * * All newly-reserved resources are available for serving the instance's - * tables. - * * The instance's new resource levels are readable via the API. - * - * The returned {@link google.longrunning.Operation|long-running operation} will - * have a name of the format `/operations/` and - * can be used to track the instance modification. The - * {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.spanner.admin.instance.v1.UpdateInstanceMetadata|UpdateInstanceMetadata}. - * The {@link google.longrunning.Operation.response|response} field type is - * {@link google.spanner.admin.instance.v1.Instance|Instance}, if successful. - * - * Authorization requires `spanner.instances.update` permission on - * the resource {@link google.spanner.admin.instance.v1.Instance.name|name}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.spanner.admin.instance.v1.Instance} request.instance - * Required. The instance to update, which must always include the instance - * name. Otherwise, only fields mentioned in - * {@link google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask|field_mask} - * need be included. - * @param {google.protobuf.FieldMask} request.fieldMask - * Required. A mask specifying which fields in - * {@link google.spanner.admin.instance.v1.Instance|Instance} should be updated. - * The field mask must always be specified; this prevents any future fields in - * {@link google.spanner.admin.instance.v1.Instance|Instance} from being erased - * accidentally by clients that do not know about them. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1/instance_admin.update_instance.js - * region_tag:spanner_v1_generated_InstanceAdmin_UpdateInstance_async - */ - updateInstance( - request?: protos.google.spanner.admin.instance.v1.IUpdateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateInstance( - request: protos.google.spanner.admin.instance.v1.IUpdateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstance( - request: protos.google.spanner.admin.instance.v1.IUpdateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateInstance( - request?: protos.google.spanner.admin.instance.v1.IUpdateInstanceRequest, - 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 || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'instance.name': request.instance!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateInstance(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateInstance()`. - * @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/v1/instance_admin.update_instance.js - * region_tag:spanner_v1_generated_InstanceAdmin_UpdateInstance_async - */ - async checkUpdateInstanceProgress(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.updateInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the supported instance configurations for a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project for which a list of supported instance - * configurations is requested. Values are of the form - * `projects/`. - * @param {number} request.pageSize - * Number of instance configurations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token|next_page_token} - * from a previous - * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. - * @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 {@link google.spanner.admin.instance.v1.InstanceConfig | InstanceConfig}. - * 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 `listInstanceConfigsAsync()` - * 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. - */ - listInstanceConfigs( - request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.instance.v1.IInstanceConfig[], - protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest|null, - protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse - ]>; - listInstanceConfigs( - request: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, - protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse|null|undefined, - protos.google.spanner.admin.instance.v1.IInstanceConfig>): void; - listInstanceConfigs( - request: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, - callback: PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, - protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse|null|undefined, - protos.google.spanner.admin.instance.v1.IInstanceConfig>): void; - listInstanceConfigs( - request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, - protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse|null|undefined, - protos.google.spanner.admin.instance.v1.IInstanceConfig>, - callback?: PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, - protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse|null|undefined, - protos.google.spanner.admin.instance.v1.IInstanceConfig>): - Promise<[ - protos.google.spanner.admin.instance.v1.IInstanceConfig[], - protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest|null, - protos.google.spanner.admin.instance.v1.IListInstanceConfigsResponse - ]>|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({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInstanceConfigs(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project for which a list of supported instance - * configurations is requested. Values are of the form - * `projects/`. - * @param {number} request.pageSize - * Number of instance configurations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token|next_page_token} - * from a previous - * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. - * @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 {@link google.spanner.admin.instance.v1.InstanceConfig | InstanceConfig} 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 `listInstanceConfigsAsync()` - * 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. - */ - listInstanceConfigsStream( - request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listInstanceConfigs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstanceConfigs.createStream( - this.innerApiCalls.listInstanceConfigs as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInstanceConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project for which a list of supported instance - * configurations is requested. Values are of the form - * `projects/`. - * @param {number} request.pageSize - * Number of instance configurations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token|next_page_token} - * from a previous - * {@link google.spanner.admin.instance.v1.ListInstanceConfigsResponse|ListInstanceConfigsResponse}. - * @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 - * {@link google.spanner.admin.instance.v1.InstanceConfig | InstanceConfig}. 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/v1/instance_admin.list_instance_configs.js - * region_tag:spanner_v1_generated_InstanceAdmin_ListInstanceConfigs_async - */ - listInstanceConfigsAsync( - request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listInstanceConfigs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstanceConfigs.asyncIterate( - this.innerApiCalls['listInstanceConfigs'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the user-managed instance config [long-running - * operations][google.longrunning.Operation] in the given project. An instance - * config operation has a name of the form - * `projects//instanceConfigs//operations/`. - * The long-running operation - * {@link google.longrunning.Operation.metadata|metadata} field type - * `metadata.type_url` describes the type of the metadata. Operations returned - * include those that have completed/failed/canceled within the last 7 days, - * and pending operations. Operations returned are ordered by - * `operation.metadata.value.start_time` in descending order starting - * from the most recently started operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project of the instance config operations. - * Values are of the form `projects/`. - * @param {string} request.filter - * An expression that filters the list of returned operations. - * - * A filter expression consists of a field name, a - * comparison operator, and a value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.longrunning.Operation|Operation} - * are eligible for filtering: - * - * * `name` - The name of the long-running operation - * * `done` - False if the operation is in progress, else true. - * * `metadata.@type` - the type of metadata. For example, the type string - * for - * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata} - * is - * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. - * * `metadata.` - any field in metadata.value. - * `metadata.@type` must be specified first, if filtering on metadata - * fields. - * * `error` - Error associated with the long-running operation. - * * `response.@type` - the type of response. - * * `response.` - any field in response.value. - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic. However, - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `done:true` - The operation is complete. - * * `(metadata.@type=` \ - * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) - * AND` \ - * `(metadata.instance_config.name:custom-config) AND` \ - * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ - * `(error:*)` - Return operations where: - * * The operation's metadata type is - * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. - * * The instance config name contains "custom-config". - * * The operation started before 2021-03-28T14:50:00Z. - * * The operation resulted in an error. - * @param {number} request.pageSize - * Number of operations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token|next_page_token} - * from a previous - * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse|ListInstanceConfigOperationsResponse} - * to the same `parent` and with the same `filter`. - * @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 {@link google.longrunning.Operation | Operation}. - * 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 `listInstanceConfigOperationsAsync()` - * 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. - */ - listInstanceConfigOperations( - request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, - options?: CallOptions): - Promise<[ - protos.google.longrunning.IOperation[], - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest|null, - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse - ]>; - listInstanceConfigOperations( - request: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>): void; - listInstanceConfigOperations( - request: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, - callback: PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>): void; - listInstanceConfigOperations( - request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>, - callback?: PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse|null|undefined, - protos.google.longrunning.IOperation>): - Promise<[ - protos.google.longrunning.IOperation[], - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest|null, - protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse - ]>|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({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInstanceConfigOperations(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 project of the instance config operations. - * Values are of the form `projects/`. - * @param {string} request.filter - * An expression that filters the list of returned operations. - * - * A filter expression consists of a field name, a - * comparison operator, and a value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.longrunning.Operation|Operation} - * are eligible for filtering: - * - * * `name` - The name of the long-running operation - * * `done` - False if the operation is in progress, else true. - * * `metadata.@type` - the type of metadata. For example, the type string - * for - * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata} - * is - * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. - * * `metadata.` - any field in metadata.value. - * `metadata.@type` must be specified first, if filtering on metadata - * fields. - * * `error` - Error associated with the long-running operation. - * * `response.@type` - the type of response. - * * `response.` - any field in response.value. - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic. However, - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `done:true` - The operation is complete. - * * `(metadata.@type=` \ - * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) - * AND` \ - * `(metadata.instance_config.name:custom-config) AND` \ - * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ - * `(error:*)` - Return operations where: - * * The operation's metadata type is - * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. - * * The instance config name contains "custom-config". - * * The operation started before 2021-03-28T14:50:00Z. - * * The operation resulted in an error. - * @param {number} request.pageSize - * Number of operations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token|next_page_token} - * from a previous - * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse|ListInstanceConfigOperationsResponse} - * to the same `parent` and with the same `filter`. - * @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 {@link google.longrunning.Operation | Operation} 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 `listInstanceConfigOperationsAsync()` - * 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. - */ - listInstanceConfigOperationsStream( - request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listInstanceConfigOperations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstanceConfigOperations.createStream( - this.innerApiCalls.listInstanceConfigOperations as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInstanceConfigOperations`, 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 project of the instance config operations. - * Values are of the form `projects/`. - * @param {string} request.filter - * An expression that filters the list of returned operations. - * - * A filter expression consists of a field name, a - * comparison operator, and a value for filtering. - * The value must be a string, a number, or a boolean. The comparison operator - * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. - * Colon `:` is the contains operator. Filter rules are not case sensitive. - * - * The following fields in the {@link google.longrunning.Operation|Operation} - * are eligible for filtering: - * - * * `name` - The name of the long-running operation - * * `done` - False if the operation is in progress, else true. - * * `metadata.@type` - the type of metadata. For example, the type string - * for - * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata} - * is - * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. - * * `metadata.` - any field in metadata.value. - * `metadata.@type` must be specified first, if filtering on metadata - * fields. - * * `error` - Error associated with the long-running operation. - * * `response.@type` - the type of response. - * * `response.` - any field in response.value. - * - * You can combine multiple expressions by enclosing each expression in - * parentheses. By default, expressions are combined with AND logic. However, - * you can specify AND, OR, and NOT logic explicitly. - * - * Here are a few examples: - * - * * `done:true` - The operation is complete. - * * `(metadata.@type=` \ - * `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) - * AND` \ - * `(metadata.instance_config.name:custom-config) AND` \ - * `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ - * `(error:*)` - Return operations where: - * * The operation's metadata type is - * {@link google.spanner.admin.instance.v1.CreateInstanceConfigMetadata|CreateInstanceConfigMetadata}. - * * The instance config name contains "custom-config". - * * The operation started before 2021-03-28T14:50:00Z. - * * The operation resulted in an error. - * @param {number} request.pageSize - * Number of operations to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse.next_page_token|next_page_token} - * from a previous - * {@link google.spanner.admin.instance.v1.ListInstanceConfigOperationsResponse|ListInstanceConfigOperationsResponse} - * to the same `parent` and with the same `filter`. - * @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 - * {@link google.longrunning.Operation | Operation}. 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/v1/instance_admin.list_instance_config_operations.js - * region_tag:spanner_v1_generated_InstanceAdmin_ListInstanceConfigOperations_async - */ - listInstanceConfigOperationsAsync( - request?: protos.google.spanner.admin.instance.v1.IListInstanceConfigOperationsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listInstanceConfigOperations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstanceConfigOperations.asyncIterate( - this.innerApiCalls['listInstanceConfigOperations'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists all instances in the given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project for which a list of instances is - * requested. Values are of the form `projects/`. - * @param {number} request.pageSize - * Number of instances to be returned in the response. If 0 or less, defaults - * to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} - * from a previous - * {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. - * @param {string} request.filter - * An expression for filtering the results of the request. Filter rules are - * case insensitive. The fields eligible for filtering are: - * - * * `name` - * * `display_name` - * * `labels.key` where key is the name of a label - * - * Some examples of using filters are: - * - * * `name:*` --> The instance has a name. - * * `name:Howl` --> The instance's name contains the string "howl". - * * `name:HOWL` --> Equivalent to above. - * * `NAME:howl` --> Equivalent to above. - * * `labels.env:*` --> The instance has the label "env". - * * `labels.env:dev` --> The instance has the label "env" and the value of - * the label contains the string "dev". - * * `name:howl labels.env:dev` --> The instance's name contains "howl" and - * it has the label "env" with its value - * containing "dev". - * @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 {@link google.spanner.admin.instance.v1.Instance | Instance}. - * 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 `listInstancesAsync()` - * 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. - */ - listInstances( - request?: protos.google.spanner.admin.instance.v1.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.admin.instance.v1.IInstance[], - protos.google.spanner.admin.instance.v1.IListInstancesRequest|null, - protos.google.spanner.admin.instance.v1.IListInstancesResponse - ]>; - listInstances( - request: protos.google.spanner.admin.instance.v1.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstancesRequest, - protos.google.spanner.admin.instance.v1.IListInstancesResponse|null|undefined, - protos.google.spanner.admin.instance.v1.IInstance>): void; - listInstances( - request: protos.google.spanner.admin.instance.v1.IListInstancesRequest, - callback: PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstancesRequest, - protos.google.spanner.admin.instance.v1.IListInstancesResponse|null|undefined, - protos.google.spanner.admin.instance.v1.IInstance>): void; - listInstances( - request?: protos.google.spanner.admin.instance.v1.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstancesRequest, - protos.google.spanner.admin.instance.v1.IListInstancesResponse|null|undefined, - protos.google.spanner.admin.instance.v1.IInstance>, - callback?: PaginationCallback< - protos.google.spanner.admin.instance.v1.IListInstancesRequest, - protos.google.spanner.admin.instance.v1.IListInstancesResponse|null|undefined, - protos.google.spanner.admin.instance.v1.IInstance>): - Promise<[ - protos.google.spanner.admin.instance.v1.IInstance[], - protos.google.spanner.admin.instance.v1.IListInstancesRequest|null, - protos.google.spanner.admin.instance.v1.IListInstancesResponse - ]>|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({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listInstances(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project for which a list of instances is - * requested. Values are of the form `projects/`. - * @param {number} request.pageSize - * Number of instances to be returned in the response. If 0 or less, defaults - * to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} - * from a previous - * {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. - * @param {string} request.filter - * An expression for filtering the results of the request. Filter rules are - * case insensitive. The fields eligible for filtering are: - * - * * `name` - * * `display_name` - * * `labels.key` where key is the name of a label - * - * Some examples of using filters are: - * - * * `name:*` --> The instance has a name. - * * `name:Howl` --> The instance's name contains the string "howl". - * * `name:HOWL` --> Equivalent to above. - * * `NAME:howl` --> Equivalent to above. - * * `labels.env:*` --> The instance has the label "env". - * * `labels.env:dev` --> The instance has the label "env" and the value of - * the label contains the string "dev". - * * `name:howl labels.env:dev` --> The instance's name contains "howl" and - * it has the label "env" with its value - * containing "dev". - * @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 {@link google.spanner.admin.instance.v1.Instance | Instance} 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 `listInstancesAsync()` - * 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. - */ - listInstancesStream( - request?: protos.google.spanner.admin.instance.v1.IListInstancesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.createStream( - this.innerApiCalls.listInstances as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project for which a list of instances is - * requested. Values are of the form `projects/`. - * @param {number} request.pageSize - * Number of instances to be returned in the response. If 0 or less, defaults - * to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token|next_page_token} - * from a previous - * {@link google.spanner.admin.instance.v1.ListInstancesResponse|ListInstancesResponse}. - * @param {string} request.filter - * An expression for filtering the results of the request. Filter rules are - * case insensitive. The fields eligible for filtering are: - * - * * `name` - * * `display_name` - * * `labels.key` where key is the name of a label - * - * Some examples of using filters are: - * - * * `name:*` --> The instance has a name. - * * `name:Howl` --> The instance's name contains the string "howl". - * * `name:HOWL` --> Equivalent to above. - * * `NAME:howl` --> Equivalent to above. - * * `labels.env:*` --> The instance has the label "env". - * * `labels.env:dev` --> The instance has the label "env" and the value of - * the label contains the string "dev". - * * `name:howl labels.env:dev` --> The instance's name contains "howl" and - * it has the label "env" with its value - * containing "dev". - * @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 - * {@link google.spanner.admin.instance.v1.Instance | Instance}. 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/v1/instance_admin.list_instances.js - * region_tag:spanner_v1_generated_InstanceAdmin_ListInstances_async - */ - listInstancesAsync( - request?: protos.google.spanner.admin.instance.v1.IListInstancesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listInstances']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listInstances.asyncIterate( - this.innerApiCalls['listInstances'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified instance resource name string. - * - * @param {string} project - * @param {string} instance - * @returns {string} Resource name string. - */ - instancePath(project:string,instance:string) { - return this.pathTemplates.instancePathTemplate.render({ - project: project, - instance: instance, - }); - } - - /** - * Parse the project from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).project; - } - - /** - * Parse the instance from Instance resource. - * - * @param {string} instanceName - * A fully-qualified path representing Instance resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromInstanceName(instanceName: string) { - return this.pathTemplates.instancePathTemplate.match(instanceName).instance; - } - - /** - * Return a fully-qualified instanceConfig resource name string. - * - * @param {string} project - * @param {string} instance_config - * @returns {string} Resource name string. - */ - instanceConfigPath(project:string,instanceConfig:string) { - return this.pathTemplates.instanceConfigPathTemplate.render({ - project: project, - instance_config: instanceConfig, - }); - } - - /** - * Parse the project from InstanceConfig resource. - * - * @param {string} instanceConfigName - * A fully-qualified path representing InstanceConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromInstanceConfigName(instanceConfigName: string) { - return this.pathTemplates.instanceConfigPathTemplate.match(instanceConfigName).project; - } - - /** - * Parse the instance_config from InstanceConfig resource. - * - * @param {string} instanceConfigName - * A fully-qualified path representing InstanceConfig resource. - * @returns {string} A string representing the instance_config. - */ - matchInstanceConfigFromInstanceConfigName(instanceConfigName: string) { - return this.pathTemplates.instanceConfigPathTemplate.match(instanceConfigName).instance_config; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.instanceAdminStub && !this._terminated) { - return this.instanceAdminStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client_config.json b/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client_config.json deleted file mode 100644 index 3f41e629d..000000000 --- a/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_client_config.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "interfaces": { - "google.spanner.admin.instance.v1.InstanceAdmin": { - "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 - }, - "e9fafda332ce8a1702dc1575de3ca81c4feb4799": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 32000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListInstanceConfigs": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "GetInstanceConfig": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "CreateInstanceConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateInstanceConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteInstanceConfig": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListInstanceConfigOperations": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListInstances": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "GetInstance": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "CreateInstance": { - "timeout_millis": 3600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateInstance": { - "timeout_millis": 3600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteInstance": { - "timeout_millis": 3600000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "SetIamPolicy": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799" - }, - "TestIamPermissions": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_proto_list.json b/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_proto_list.json deleted file mode 100644 index ce2400d42..000000000 --- a/owl-bot-staging/admin/instance/v1/src/v1/instance_admin_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/spanner/admin/instance/v1/common.proto", - "../../protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto" -] diff --git a/owl-bot-staging/admin/instance/v1/test/gapic_instance_admin_v1.ts b/owl-bot-staging/admin/instance/v1/test/gapic_instance_admin_v1.ts deleted file mode 100644 index 677ffbc81..000000000 --- a/owl-bot-staging/admin/instance/v1/test/gapic_instance_admin_v1.ts +++ /dev/null @@ -1,2437 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 instanceadminModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -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('v1.InstanceAdminClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = instanceadminModule.v1.InstanceAdminClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = instanceadminModule.v1.InstanceAdminClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = instanceadminModule.v1.InstanceAdminClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new instanceadminModule.v1.InstanceAdminClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.instanceAdminStub, undefined); - await client.initialize(); - assert(client.instanceAdminStub); - }); - - it('has close method for the initialized client', done => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.instanceAdminStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.instanceAdminStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new instanceadminModule.v1.InstanceAdminClient({ - 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 instanceadminModule.v1.InstanceAdminClient({ - 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('getInstanceConfig', () => { - it('invokes getInstanceConfig without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.InstanceConfig() - ); - client.innerApiCalls.getInstanceConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getInstanceConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceConfig without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.InstanceConfig() - ); - client.innerApiCalls.getInstanceConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstanceConfig( - request, - (err?: Error|null, result?: protos.google.spanner.admin.instance.v1.IInstanceConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceConfig with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstanceConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstanceConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstanceConfig with closed client', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.GetInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstanceConfig(request), expectedError); - }); - }); - - describe('deleteInstanceConfig', () => { - it('invokes deleteInstanceConfig without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteInstanceConfig = stubSimpleCall(expectedResponse); - const [response] = await client.deleteInstanceConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstanceConfig without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteInstanceConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstanceConfig( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstanceConfig with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstanceConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteInstanceConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstanceConfig with closed client', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteInstanceConfig(request), expectedError); - }); - }); - - describe('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.spanner.admin.instance.v1.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getInstance with closed client', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstance(request), expectedError); - }); - }); - - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteInstance = stubSimpleCall(expectedResponse); - const [response] = await client.deleteInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteInstance with closed client', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.DeleteInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.DeleteInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteInstance(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createInstanceConfig', () => { - it('invokes createInstanceConfig without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstanceConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstanceConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstanceConfig without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstanceConfig( - 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); - const actualRequest = (client.innerApiCalls.createInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstanceConfig with call error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstanceConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstanceConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstanceConfig with LRO error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstanceConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstanceConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateInstanceConfigProgress without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - 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.checkCreateInstanceConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateInstanceConfigProgress with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - 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.checkCreateInstanceConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateInstanceConfig', () => { - it('invokes updateInstanceConfig without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() - ); - request.instanceConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest', ['instanceConfig', 'name']); - request.instanceConfig.name = defaultValue1; - const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstanceConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceConfig without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() - ); - request.instanceConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest', ['instanceConfig', 'name']); - request.instanceConfig.name = defaultValue1; - const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstanceConfig( - 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); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceConfig with call error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() - ); - request.instanceConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest', ['instanceConfig', 'name']); - request.instanceConfig.name = defaultValue1; - const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstanceConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstanceConfig with LRO error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest() - ); - request.instanceConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceConfigRequest', ['instanceConfig', 'name']); - request.instanceConfig.name = defaultValue1; - const expectedHeaderRequestParams = `instance_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstanceConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstanceConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstanceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateInstanceConfigProgress without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - 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.checkUpdateInstanceConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateInstanceConfigProgress with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - 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.checkUpdateInstanceConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - 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); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with call error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createInstance with LRO error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.CreateInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.CreateInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - 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.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - 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.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstance( - 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); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance with call error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateInstance with LRO error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.UpdateInstanceRequest() - ); - request.instance ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.UpdateInstanceRequest', ['instance', 'name']); - request.instance.name = defaultValue1; - const expectedHeaderRequestParams = `instance.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateInstanceProgress without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - 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.checkUpdateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateInstanceProgress with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - 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.checkUpdateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listInstanceConfigs', () => { - it('invokes listInstanceConfigs without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - ]; - client.innerApiCalls.listInstanceConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listInstanceConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstanceConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstanceConfigs without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - ]; - client.innerApiCalls.listInstanceConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstanceConfigs( - request, - (err?: Error|null, result?: protos.google.spanner.admin.instance.v1.IInstanceConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstanceConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstanceConfigs with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstanceConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstanceConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstanceConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstanceConfigsStream without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - ]; - client.descriptors.page.listInstanceConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstanceConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.admin.instance.v1.InstanceConfig[] = []; - stream.on('data', (response: protos.google.spanner.admin.instance.v1.InstanceConfig) => { - 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.listInstanceConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstanceConfigs, request)); - assert( - (client.descriptors.page.listInstanceConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInstanceConfigsStream with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstanceConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstanceConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.admin.instance.v1.InstanceConfig[] = []; - stream.on('data', (response: protos.google.spanner.admin.instance.v1.InstanceConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstanceConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstanceConfigs, request)); - assert( - (client.descriptors.page.listInstanceConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstanceConfigs without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.InstanceConfig()), - ]; - client.descriptors.page.listInstanceConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.spanner.admin.instance.v1.IInstanceConfig[] = []; - const iterable = client.listInstanceConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstanceConfigs with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstanceConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstanceConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.spanner.admin.instance.v1.IInstanceConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstanceConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listInstanceConfigOperations', () => { - it('invokes listInstanceConfigOperations without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.innerApiCalls.listInstanceConfigOperations = stubSimpleCall(expectedResponse); - const [response] = await client.listInstanceConfigOperations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstanceConfigOperations without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.innerApiCalls.listInstanceConfigOperations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstanceConfigOperations( - request, - (err?: Error|null, result?: protos.google.longrunning.IOperation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstanceConfigOperations with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstanceConfigOperations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstanceConfigOperations(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstanceConfigOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstanceConfigOperationsStream without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.descriptors.page.listInstanceConfigOperations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstanceConfigOperationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.longrunning.Operation[] = []; - stream.on('data', (response: protos.google.longrunning.Operation) => { - 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.listInstanceConfigOperations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstanceConfigOperations, request)); - assert( - (client.descriptors.page.listInstanceConfigOperations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInstanceConfigOperationsStream with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstanceConfigOperations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstanceConfigOperationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.longrunning.Operation[] = []; - stream.on('data', (response: protos.google.longrunning.Operation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstanceConfigOperations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstanceConfigOperations, request)); - assert( - (client.descriptors.page.listInstanceConfigOperations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstanceConfigOperations without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - generateSampleMessage(new protos.google.longrunning.Operation()), - ]; - client.descriptors.page.listInstanceConfigOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.longrunning.IOperation[] = []; - const iterable = client.listInstanceConfigOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstanceConfigOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstanceConfigOperations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstanceConfigOperations with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstanceConfigOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstanceConfigOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstanceConfigOperationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstanceConfigOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstanceConfigOperations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances without error using callback', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.spanner.admin.instance.v1.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstances with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listInstancesStream without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.admin.instance.v1.Instance[] = []; - stream.on('data', (response: protos.google.spanner.admin.instance.v1.Instance) => { - 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.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listInstancesStream with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.admin.instance.v1.Instance[] = []; - stream.on('data', (response: protos.google.spanner.admin.instance.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances without error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - generateSampleMessage(new protos.google.spanner.admin.instance.v1.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.spanner.admin.instance.v1.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances with error', async () => { - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.admin.instance.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.admin.instance.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.spanner.admin.instance.v1.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('instance', () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - }; - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('instanceConfig', () => { - const fakePath = "/rendered/path/instanceConfig"; - const expectedParameters = { - project: "projectValue", - instance_config: "instanceConfigValue", - }; - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instanceConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instanceConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instanceConfigPath', () => { - const result = client.instanceConfigPath("projectValue", "instanceConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instanceConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceConfigName', () => { - const result = client.matchProjectFromInstanceConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instanceConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceConfigFromInstanceConfigName', () => { - const result = client.matchInstanceConfigFromInstanceConfigName(fakePath); - assert.strictEqual(result, "instanceConfigValue"); - assert((client.pathTemplates.instanceConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new instanceadminModule.v1.InstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/admin/instance/v1/tsconfig.json b/owl-bot-staging/admin/instance/v1/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/admin/instance/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/admin/instance/v1/webpack.config.js b/owl-bot-staging/admin/instance/v1/webpack.config.js deleted file mode 100644 index 9d3569000..000000000 --- a/owl-bot-staging/admin/instance/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'InstanceAdmin', - filename: './instance-admin.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index cfc348ec4..000000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index d4f03a0df..000000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -/.coverage -/coverage -/.nyc_output -/docs/ -/out/ -/build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index e37e0473a..000000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 2023 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/spanner', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 1a38f257d..000000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 55639e70f..000000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index f6214cb02..000000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Spanner: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index befd23c86..000000000 --- a/owl-bot-staging/v1/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/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 02afe451f..000000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/spanner", - "version": "0.1.0", - "description": "Spanner client for Node.js", - "repository": "googleapis/nodejs-spanner", - "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 spanner", - "spanner", - "spanner" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "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.5.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/commit_response.proto b/owl-bot-staging/v1/protos/google/spanner/v1/commit_response.proto deleted file mode 100644 index 69e073092..000000000 --- a/owl-bot-staging/v1/protos/google/spanner/v1/commit_response.proto +++ /dev/null @@ -1,50 +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.spanner.v1; - -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; -option java_multiple_files = true; -option java_outer_classname = "CommitResponseProto"; -option java_package = "com.google.spanner.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\V1"; -option ruby_package = "Google::Cloud::Spanner::V1"; - -// The response for [Commit][google.spanner.v1.Spanner.Commit]. -message CommitResponse { - // Additional statistics about a commit. - message CommitStats { - // The total number of mutations for the transaction. Knowing the - // `mutation_count` value can help you maximize the number of mutations - // in a transaction and minimize the number of API round trips. You can - // also monitor this value to prevent transactions from exceeding the system - // [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data). - // If the number of mutations exceeds the limit, the server returns - // [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT). - int64 mutation_count = 1; - } - - // The Cloud Spanner timestamp at which the transaction committed. - google.protobuf.Timestamp commit_timestamp = 1; - - // The statistics about this Commit. Not returned by default. - // For more information, see - // [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats]. - CommitStats commit_stats = 2; -} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/keys.proto b/owl-bot-staging/v1/protos/google/spanner/v1/keys.proto deleted file mode 100644 index df3607aa4..000000000 --- a/owl-bot-staging/v1/protos/google/spanner/v1/keys.proto +++ /dev/null @@ -1,163 +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.spanner.v1; - -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; -option java_multiple_files = true; -option java_outer_classname = "KeysProto"; -option java_package = "com.google.spanner.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\V1"; -option ruby_package = "Google::Cloud::Spanner::V1"; - -// KeyRange represents a range of rows in a table or index. -// -// A range has a start key and an end key. These keys can be open or -// closed, indicating if the range includes rows with that key. -// -// Keys are represented by lists, where the ith value in the list -// corresponds to the ith component of the table or index primary key. -// Individual values are encoded as described -// [here][google.spanner.v1.TypeCode]. -// -// For example, consider the following table definition: -// -// CREATE TABLE UserEvents ( -// UserName STRING(MAX), -// EventDate STRING(10) -// ) PRIMARY KEY(UserName, EventDate); -// -// The following keys name rows in this table: -// -// ["Bob", "2014-09-23"] -// ["Alfred", "2015-06-12"] -// -// Since the `UserEvents` table's `PRIMARY KEY` clause names two -// columns, each `UserEvents` key has two elements; the first is the -// `UserName`, and the second is the `EventDate`. -// -// Key ranges with multiple components are interpreted -// lexicographically by component using the table or index key's declared -// sort order. For example, the following range returns all events for -// user `"Bob"` that occurred in the year 2015: -// -// "start_closed": ["Bob", "2015-01-01"] -// "end_closed": ["Bob", "2015-12-31"] -// -// Start and end keys can omit trailing key components. This affects the -// inclusion and exclusion of rows that exactly match the provided key -// components: if the key is closed, then rows that exactly match the -// provided components are included; if the key is open, then rows -// that exactly match are not included. -// -// For example, the following range includes all events for `"Bob"` that -// occurred during and after the year 2000: -// -// "start_closed": ["Bob", "2000-01-01"] -// "end_closed": ["Bob"] -// -// The next example retrieves all events for `"Bob"`: -// -// "start_closed": ["Bob"] -// "end_closed": ["Bob"] -// -// To retrieve events before the year 2000: -// -// "start_closed": ["Bob"] -// "end_open": ["Bob", "2000-01-01"] -// -// The following range includes all rows in the table: -// -// "start_closed": [] -// "end_closed": [] -// -// This range returns all users whose `UserName` begins with any -// character from A to C: -// -// "start_closed": ["A"] -// "end_open": ["D"] -// -// This range returns all users whose `UserName` begins with B: -// -// "start_closed": ["B"] -// "end_open": ["C"] -// -// Key ranges honor column sort order. For example, suppose a table is -// defined as follows: -// -// CREATE TABLE DescendingSortedTable { -// Key INT64, -// ... -// ) PRIMARY KEY(Key DESC); -// -// The following range retrieves all rows with key values between 1 -// and 100 inclusive: -// -// "start_closed": ["100"] -// "end_closed": ["1"] -// -// Note that 100 is passed as the start, and 1 is passed as the end, -// because `Key` is a descending column in the schema. -message KeyRange { - // The start key must be provided. It can be either closed or open. - oneof start_key_type { - // If the start is closed, then the range includes all rows whose - // first `len(start_closed)` key columns exactly match `start_closed`. - google.protobuf.ListValue start_closed = 1; - - // If the start is open, then the range excludes rows whose first - // `len(start_open)` key columns exactly match `start_open`. - google.protobuf.ListValue start_open = 2; - } - - // The end key must be provided. It can be either closed or open. - oneof end_key_type { - // If the end is closed, then the range includes all rows whose - // first `len(end_closed)` key columns exactly match `end_closed`. - google.protobuf.ListValue end_closed = 3; - - // If the end is open, then the range excludes rows whose first - // `len(end_open)` key columns exactly match `end_open`. - google.protobuf.ListValue end_open = 4; - } -} - -// `KeySet` defines a collection of Cloud Spanner keys and/or key ranges. All -// the keys are expected to be in the same table or index. The keys need -// not be sorted in any particular way. -// -// If the same key is specified multiple times in the set (for example -// if two ranges, two keys, or a key and a range overlap), Cloud Spanner -// behaves as if the key were only specified once. -message KeySet { - // A list of specific keys. Entries in `keys` should have exactly as - // many elements as there are columns in the primary or index key - // with which this `KeySet` is used. Individual key values are - // encoded as described [here][google.spanner.v1.TypeCode]. - repeated google.protobuf.ListValue keys = 1; - - // A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about - // key range specifications. - repeated KeyRange ranges = 2; - - // For convenience `all` can be set to `true` to indicate that this - // `KeySet` matches all keys in the table or index. Note that any keys - // specified in `keys` or `ranges` are only yielded once. - bool all = 3; -} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/mutation.proto b/owl-bot-staging/v1/protos/google/spanner/v1/mutation.proto deleted file mode 100644 index eae0af72d..000000000 --- a/owl-bot-staging/v1/protos/google/spanner/v1/mutation.proto +++ /dev/null @@ -1,107 +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.spanner.v1; - -import "google/api/field_behavior.proto"; -import "google/protobuf/struct.proto"; -import "google/spanner/v1/keys.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; -option java_multiple_files = true; -option java_outer_classname = "MutationProto"; -option java_package = "com.google.spanner.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\V1"; -option ruby_package = "Google::Cloud::Spanner::V1"; - -// A modification to one or more Cloud Spanner rows. Mutations can be -// applied to a Cloud Spanner database by sending them in a -// [Commit][google.spanner.v1.Spanner.Commit] call. -message Mutation { - // Arguments to [insert][google.spanner.v1.Mutation.insert], [update][google.spanner.v1.Mutation.update], [insert_or_update][google.spanner.v1.Mutation.insert_or_update], and - // [replace][google.spanner.v1.Mutation.replace] operations. - message Write { - // Required. The table whose rows will be written. - string table = 1 [(google.api.field_behavior) = REQUIRED]; - - // The names of the columns in [table][google.spanner.v1.Mutation.Write.table] to be written. - // - // The list of columns must contain enough columns to allow - // Cloud Spanner to derive values for all primary key columns in the - // row(s) to be modified. - repeated string columns = 2; - - // The values to be written. `values` can contain more than one - // list of values. If it does, then multiple rows are written, one - // for each entry in `values`. Each list in `values` must have - // exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] - // above. Sending multiple lists is equivalent to sending multiple - // `Mutation`s, each containing one `values` entry and repeating - // [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are - // encoded as described [here][google.spanner.v1.TypeCode]. - repeated google.protobuf.ListValue values = 3; - } - - // Arguments to [delete][google.spanner.v1.Mutation.delete] operations. - message Delete { - // Required. The table whose rows will be deleted. - string table = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. The - // primary keys must be specified in the order in which they appear in the - // `PRIMARY KEY()` clause of the table's equivalent DDL statement (the DDL - // statement used to create the table). - // Delete is idempotent. The transaction will succeed even if some or all - // rows do not exist. - KeySet key_set = 2 [(google.api.field_behavior) = REQUIRED]; - } - - // Required. The operation to perform. - oneof operation { - // Insert new rows in a table. If any of the rows already exist, - // the write or transaction fails with error `ALREADY_EXISTS`. - Write insert = 1; - - // Update existing rows in a table. If any of the rows does not - // already exist, the transaction fails with error `NOT_FOUND`. - Write update = 2; - - // Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, then - // its column values are overwritten with the ones provided. Any - // column values not explicitly written are preserved. - // - // When using [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as when using [insert][google.spanner.v1.Mutation.insert], all `NOT - // NULL` columns in the table must be given a value. This holds true - // even when the row already exists and will therefore actually be updated. - Write insert_or_update = 3; - - // Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is - // deleted, and the column values provided are inserted - // instead. Unlike [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this means any values not - // explicitly written become `NULL`. - // - // In an interleaved table, if you create the child table with the - // `ON DELETE CASCADE` annotation, then replacing a parent row - // also deletes the child rows. Otherwise, you must delete the - // child rows before you replace the parent row. - Write replace = 4; - - // Delete rows from a table. Succeeds whether or not the named - // rows were present. - Delete delete = 5; - } -} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/query_plan.proto b/owl-bot-staging/v1/protos/google/spanner/v1/query_plan.proto deleted file mode 100644 index 9ea40fe4a..000000000 --- a/owl-bot-staging/v1/protos/google/spanner/v1/query_plan.proto +++ /dev/null @@ -1,128 +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.spanner.v1; - -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; -option java_multiple_files = true; -option java_outer_classname = "QueryPlanProto"; -option java_package = "com.google.spanner.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\V1"; -option ruby_package = "Google::Cloud::Spanner::V1"; - -// Node information for nodes appearing in a [QueryPlan.plan_nodes][google.spanner.v1.QueryPlan.plan_nodes]. -message PlanNode { - // The kind of [PlanNode][google.spanner.v1.PlanNode]. Distinguishes between the two different kinds of - // nodes that can appear in a query plan. - enum Kind { - // Not specified. - KIND_UNSPECIFIED = 0; - - // Denotes a Relational operator node in the expression tree. Relational - // operators represent iterative processing of rows during query execution. - // For example, a `TableScan` operation that reads rows from a table. - RELATIONAL = 1; - - // Denotes a Scalar node in the expression tree. Scalar nodes represent - // non-iterable entities in the query plan. For example, constants or - // arithmetic operators appearing inside predicate expressions or references - // to column names. - SCALAR = 2; - } - - // Metadata associated with a parent-child relationship appearing in a - // [PlanNode][google.spanner.v1.PlanNode]. - message ChildLink { - // The node to which the link points. - int32 child_index = 1; - - // The type of the link. For example, in Hash Joins this could be used to - // distinguish between the build child and the probe child, or in the case - // of the child being an output variable, to represent the tag associated - // with the output variable. - string type = 2; - - // Only present if the child node is [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds - // to an output variable of the parent node. The field carries the name of - // the output variable. - // For example, a `TableScan` operator that reads rows from a table will - // have child links to the `SCALAR` nodes representing the output variables - // created for each column that is read by the operator. The corresponding - // `variable` fields will be set to the variable names assigned to the - // columns. - string variable = 3; - } - - // Condensed representation of a node and its subtree. Only present for - // `SCALAR` [PlanNode(s)][google.spanner.v1.PlanNode]. - message ShortRepresentation { - // A string representation of the expression subtree rooted at this node. - string description = 1; - - // A mapping of (subquery variable name) -> (subquery node id) for cases - // where the `description` string of this node references a `SCALAR` - // subquery contained in the expression subtree rooted at this node. The - // referenced `SCALAR` subquery may not necessarily be a direct child of - // this node. - map subqueries = 2; - } - - // The `PlanNode`'s index in [node list][google.spanner.v1.QueryPlan.plan_nodes]. - int32 index = 1; - - // Used to determine the type of node. May be needed for visualizing - // different kinds of nodes differently. For example, If the node is a - // [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a condensed representation - // which can be used to directly embed a description of the node in its - // parent. - Kind kind = 2; - - // The display name for the node. - string display_name = 3; - - // List of child node `index`es and their relationship to this parent. - repeated ChildLink child_links = 4; - - // Condensed representation for [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes. - ShortRepresentation short_representation = 5; - - // Attributes relevant to the node contained in a group of key-value pairs. - // For example, a Parameter Reference node could have the following - // information in its metadata: - // - // { - // "parameter_reference": "param1", - // "parameter_type": "array" - // } - google.protobuf.Struct metadata = 6; - - // The execution statistics associated with the node, contained in a group of - // key-value pairs. Only present if the plan was returned as a result of a - // profile query. For example, number of executions, number of rows/time per - // execution etc. - google.protobuf.Struct execution_stats = 7; -} - -// Contains an ordered list of nodes appearing in the query plan. -message QueryPlan { - // The nodes in the query plan. Plan nodes are returned in pre-order starting - // with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id` corresponds to its index in - // `plan_nodes`. - repeated PlanNode plan_nodes = 1; -} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/result_set.proto b/owl-bot-staging/v1/protos/google/spanner/v1/result_set.proto deleted file mode 100644 index 36df232bc..000000000 --- a/owl-bot-staging/v1/protos/google/spanner/v1/result_set.proto +++ /dev/null @@ -1,216 +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.spanner.v1; - -import "google/protobuf/struct.proto"; -import "google/spanner/v1/query_plan.proto"; -import "google/spanner/v1/transaction.proto"; -import "google/spanner/v1/type.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.Cloud.Spanner.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; -option java_multiple_files = true; -option java_outer_classname = "ResultSetProto"; -option java_package = "com.google.spanner.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\V1"; -option ruby_package = "Google::Cloud::Spanner::V1"; - -// Results from [Read][google.spanner.v1.Spanner.Read] or -// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. -message ResultSet { - // Metadata about the result set, such as row type information. - ResultSetMetadata metadata = 1; - - // Each element in `rows` is a row whose format is defined by - // [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith element - // in each row matches the ith field in - // [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements are - // encoded based on type as described - // [here][google.spanner.v1.TypeCode]. - repeated google.protobuf.ListValue rows = 2; - - // Query plan and execution statistics for the SQL statement that - // produced this result set. These can be requested by setting - // [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. - // DML statements always produce stats containing the number of rows - // modified, unless executed using the - // [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN] [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. - // Other fields may or may not be populated, based on the - // [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]. - ResultSetStats stats = 3; -} - -// Partial results from a streaming read or SQL query. Streaming reads and -// SQL queries better tolerate large result sets, large rows, and large -// values, but are a little trickier to consume. -message PartialResultSet { - // Metadata about the result set, such as row type information. - // Only present in the first response. - ResultSetMetadata metadata = 1; - - // A streamed result set consists of a stream of values, which might - // be split into many `PartialResultSet` messages to accommodate - // large rows and/or large values. Every N complete values defines a - // row, where N is equal to the number of entries in - // [metadata.row_type.fields][google.spanner.v1.StructType.fields]. - // - // Most values are encoded based on type as described - // [here][google.spanner.v1.TypeCode]. - // - // It is possible that the last value in values is "chunked", - // meaning that the rest of the value is sent in subsequent - // `PartialResultSet`(s). This is denoted by the [chunked_value][google.spanner.v1.PartialResultSet.chunked_value] - // field. Two or more chunked values can be merged to form a - // complete value as follows: - // - // * `bool/number/null`: cannot be chunked - // * `string`: concatenate the strings - // * `list`: concatenate the lists. If the last element in a list is a - // `string`, `list`, or `object`, merge it with the first element in - // the next list by applying these rules recursively. - // * `object`: concatenate the (field name, field value) pairs. If a - // field name is duplicated, then apply these rules recursively - // to merge the field values. - // - // Some examples of merging: - // - // # Strings are concatenated. - // "foo", "bar" => "foobar" - // - // # Lists of non-strings are concatenated. - // [2, 3], [4] => [2, 3, 4] - // - // # Lists are concatenated, but the last and first elements are merged - // # because they are strings. - // ["a", "b"], ["c", "d"] => ["a", "bc", "d"] - // - // # Lists are concatenated, but the last and first elements are merged - // # because they are lists. Recursively, the last and first elements - // # of the inner lists are merged because they are strings. - // ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"] - // - // # Non-overlapping object fields are combined. - // {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"} - // - // # Overlapping object fields are merged. - // {"a": "1"}, {"a": "2"} => {"a": "12"} - // - // # Examples of merging objects containing lists of strings. - // {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]} - // - // For a more complete example, suppose a streaming SQL query is - // yielding a result set whose rows contain a single string - // field. The following `PartialResultSet`s might be yielded: - // - // { - // "metadata": { ... } - // "values": ["Hello", "W"] - // "chunked_value": true - // "resume_token": "Af65..." - // } - // { - // "values": ["orl"] - // "chunked_value": true - // "resume_token": "Bqp2..." - // } - // { - // "values": ["d"] - // "resume_token": "Zx1B..." - // } - // - // This sequence of `PartialResultSet`s encodes two rows, one - // containing the field value `"Hello"`, and a second containing the - // field value `"World" = "W" + "orl" + "d"`. - repeated google.protobuf.Value values = 2; - - // If true, then the final value in [values][google.spanner.v1.PartialResultSet.values] is chunked, and must - // be combined with more values from subsequent `PartialResultSet`s - // to obtain a complete field value. - bool chunked_value = 3; - - // Streaming calls might be interrupted for a variety of reasons, such - // as TCP connection loss. If this occurs, the stream of results can - // be resumed by re-sending the original request and including - // `resume_token`. Note that executing any other transaction in the - // same session invalidates the token. - bytes resume_token = 4; - - // Query plan and execution statistics for the statement that produced this - // streaming result set. These can be requested by setting - // [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] and are sent - // only once with the last response in the stream. - // This field will also be present in the last response for DML - // statements. - ResultSetStats stats = 5; -} - -// Metadata about a [ResultSet][google.spanner.v1.ResultSet] or [PartialResultSet][google.spanner.v1.PartialResultSet]. -message ResultSetMetadata { - // Indicates the field names and types for the rows in the result - // set. For example, a SQL query like `"SELECT UserId, UserName FROM - // Users"` could return a `row_type` value like: - // - // "fields": [ - // { "name": "UserId", "type": { "code": "INT64" } }, - // { "name": "UserName", "type": { "code": "STRING" } }, - // ] - StructType row_type = 1; - - // If the read or SQL query began a transaction as a side-effect, the - // information about the new transaction is yielded here. - Transaction transaction = 2; - - // A SQL query can be parameterized. In PLAN mode, these parameters can be - // undeclared. This indicates the field names and types for those undeclared - // parameters in the SQL query. For example, a SQL query like `"SELECT * FROM - // Users where UserId = @userId and UserName = @userName "` could return a - // `undeclared_parameters` value like: - // - // "fields": [ - // { "name": "UserId", "type": { "code": "INT64" } }, - // { "name": "UserName", "type": { "code": "STRING" } }, - // ] - StructType undeclared_parameters = 3; -} - -// Additional statistics about a [ResultSet][google.spanner.v1.ResultSet] or [PartialResultSet][google.spanner.v1.PartialResultSet]. -message ResultSetStats { - // [QueryPlan][google.spanner.v1.QueryPlan] for the query associated with this result. - QueryPlan query_plan = 1; - - // Aggregated statistics from the execution of the query. Only present when - // the query is profiled. For example, a query could return the statistics as - // follows: - // - // { - // "rows_returned": "3", - // "elapsed_time": "1.22 secs", - // "cpu_time": "1.19 secs" - // } - google.protobuf.Struct query_stats = 2; - - // The number of rows modified by the DML statement. - oneof row_count { - // Standard DML returns an exact count of rows that were modified. - int64 row_count_exact = 3; - - // Partitioned DML does not offer exactly-once semantics, so it - // returns a lower bound of the rows modified. - int64 row_count_lower_bound = 4; - } -} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/spanner.proto b/owl-bot-staging/v1/protos/google/spanner/v1/spanner.proto deleted file mode 100644 index 77a1f0e47..000000000 --- a/owl-bot-staging/v1/protos/google/spanner/v1/spanner.proto +++ /dev/null @@ -1,1042 +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.spanner.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import public "google/spanner/v1/commit_response.proto"; -import "google/spanner/v1/keys.proto"; -import "google/spanner/v1/mutation.proto"; -import "google/spanner/v1/result_set.proto"; -import "google/spanner/v1/transaction.proto"; -import "google/spanner/v1/type.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; -option java_multiple_files = true; -option java_outer_classname = "SpannerProto"; -option java_package = "com.google.spanner.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\V1"; -option ruby_package = "Google::Cloud::Spanner::V1"; -option (google.api.resource_definition) = { - type: "spanner.googleapis.com/Database" - pattern: "projects/{project}/instances/{instance}/databases/{database}" -}; - -// Cloud Spanner API -// -// The Cloud Spanner API can be used to manage sessions and execute -// transactions on data stored in Cloud Spanner databases. -service Spanner { - option (google.api.default_host) = "spanner.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/spanner.data"; - - // Creates a new session. A session can be used to perform - // transactions that read and/or modify data in a Cloud Spanner database. - // Sessions are meant to be reused for many consecutive - // transactions. - // - // Sessions can only execute one transaction at a time. To execute - // multiple concurrent read-write/write-only transactions, create - // multiple sessions. Note that standalone reads and queries use a - // transaction internally, and count toward the one transaction - // limit. - // - // Active sessions use additional server resources, so it is a good idea to - // delete idle and unneeded sessions. - // Aside from explicit deletes, Cloud Spanner may delete sessions for which no - // operations are sent for more than an hour. If a session is deleted, - // requests to it return `NOT_FOUND`. - // - // Idle sessions can be kept alive by sending a trivial SQL query - // periodically, e.g., `"SELECT 1"`. - rpc CreateSession(CreateSessionRequest) returns (Session) { - option (google.api.http) = { - post: "/v1/{database=projects/*/instances/*/databases/*}/sessions" - body: "*" - }; - option (google.api.method_signature) = "database"; - } - - // Creates multiple new sessions. - // - // This API can be used to initialize a session cache on the clients. - // See https://goo.gl/TgSFN2 for best practices on session cache management. - rpc BatchCreateSessions(BatchCreateSessionsRequest) returns (BatchCreateSessionsResponse) { - option (google.api.http) = { - post: "/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate" - body: "*" - }; - option (google.api.method_signature) = "database,session_count"; - } - - // Gets a session. Returns `NOT_FOUND` if the session does not exist. - // This is mainly useful for determining whether a session is still - // alive. - rpc GetSession(GetSessionRequest) returns (Session) { - option (google.api.http) = { - get: "/v1/{name=projects/*/instances/*/databases/*/sessions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all sessions in a given database. - rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse) { - option (google.api.http) = { - get: "/v1/{database=projects/*/instances/*/databases/*}/sessions" - }; - option (google.api.method_signature) = "database"; - } - - // Ends a session, releasing server resources associated with it. This will - // asynchronously trigger cancellation of any operations that are running with - // this session. - rpc DeleteSession(DeleteSessionRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/instances/*/databases/*/sessions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Executes an SQL statement, returning all results in a single reply. This - // method cannot be used to return a result set larger than 10 MiB; - // if the query yields more data than that, the query fails with - // a `FAILED_PRECONDITION` error. - // - // Operations inside read-write transactions might return `ABORTED`. If - // this occurs, the application should restart the transaction from - // the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. - // - // Larger result sets can be fetched in streaming fashion by calling - // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. - rpc ExecuteSql(ExecuteSqlRequest) returns (ResultSet) { - option (google.api.http) = { - post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql" - body: "*" - }; - } - - // Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the result - // set as a stream. Unlike [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there - // is no limit on the size of the returned result set. However, no - // individual row in the result set can exceed 100 MiB, and no - // column value can exceed 10 MiB. - rpc ExecuteStreamingSql(ExecuteSqlRequest) returns (stream PartialResultSet) { - option (google.api.http) = { - post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql" - body: "*" - }; - } - - // Executes a batch of SQL DML statements. This method allows many statements - // to be run with lower latency than submitting them sequentially with - // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. - // - // Statements are executed in sequential order. A request can succeed even if - // a statement fails. The [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] field in the - // response provides information about the statement that failed. Clients must - // inspect this field to determine whether an error occurred. - // - // Execution stops after the first failed statement; the remaining statements - // are not executed. - rpc ExecuteBatchDml(ExecuteBatchDmlRequest) returns (ExecuteBatchDmlResponse) { - option (google.api.http) = { - post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml" - body: "*" - }; - } - - // Reads rows from the database using key lookups and scans, as a - // simple key/value style alternative to - // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be used to - // return a result set larger than 10 MiB; if the read matches more - // data than that, the read fails with a `FAILED_PRECONDITION` - // error. - // - // Reads inside read-write transactions might return `ABORTED`. If - // this occurs, the application should restart the transaction from - // the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. - // - // Larger result sets can be yielded in streaming fashion by calling - // [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. - rpc Read(ReadRequest) returns (ResultSet) { - option (google.api.http) = { - post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read" - body: "*" - }; - } - - // Like [Read][google.spanner.v1.Spanner.Read], except returns the result set as a - // stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no limit on the - // size of the returned result set. However, no individual row in - // the result set can exceed 100 MiB, and no column value can exceed - // 10 MiB. - rpc StreamingRead(ReadRequest) returns (stream PartialResultSet) { - option (google.api.http) = { - post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead" - body: "*" - }; - } - - // Begins a new transaction. This step can often be skipped: - // [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and - // [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a - // side-effect. - rpc BeginTransaction(BeginTransactionRequest) returns (Transaction) { - option (google.api.http) = { - post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction" - body: "*" - }; - option (google.api.method_signature) = "session,options"; - } - - // Commits a transaction. The request includes the mutations to be - // applied to rows in the database. - // - // `Commit` might return an `ABORTED` error. This can occur at any time; - // commonly, the cause is conflicts with concurrent - // transactions. However, it can also happen for a variety of other - // reasons. If `Commit` returns `ABORTED`, the caller should re-attempt - // the transaction from the beginning, re-using the same session. - // - // On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, - // for example, if the client job experiences a 1+ hour networking failure. - // At that point, Cloud Spanner has lost track of the transaction outcome and - // we recommend that you perform another read from the database to see the - // state of things as they are now. - rpc Commit(CommitRequest) returns (CommitResponse) { - option (google.api.http) = { - post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit" - body: "*" - }; - option (google.api.method_signature) = "session,transaction_id,mutations"; - option (google.api.method_signature) = "session,single_use_transaction,mutations"; - } - - // Rolls back a transaction, releasing any locks it holds. It is a good - // idea to call this for any transaction that includes one or more - // [Read][google.spanner.v1.Spanner.Read] or [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and - // ultimately decides not to commit. - // - // `Rollback` returns `OK` if it successfully aborts the transaction, the - // transaction was already aborted, or the transaction is not - // found. `Rollback` never returns `ABORTED`. - rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback" - body: "*" - }; - option (google.api.method_signature) = "session,transaction_id"; - } - - // Creates a set of partition tokens that can be used to execute a query - // operation in parallel. Each of the returned partition tokens can be used - // by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to specify a subset - // of the query result to read. The same session and read-only transaction - // must be used by the PartitionQueryRequest used to create the - // partition tokens and the ExecuteSqlRequests that use the partition tokens. - // - // Partition tokens become invalid when the session used to create them - // is deleted, is idle for too long, begins a new transaction, or becomes too - // old. When any of these happen, it is not possible to resume the query, and - // the whole operation must be restarted from the beginning. - rpc PartitionQuery(PartitionQueryRequest) returns (PartitionResponse) { - option (google.api.http) = { - post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery" - body: "*" - }; - } - - // Creates a set of partition tokens that can be used to execute a read - // operation in parallel. Each of the returned partition tokens can be used - // by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a subset of the read - // result to read. The same session and read-only transaction must be used by - // the PartitionReadRequest used to create the partition tokens and the - // ReadRequests that use the partition tokens. There are no ordering - // guarantees on rows returned among the returned partition tokens, or even - // within each individual StreamingRead call issued with a partition_token. - // - // Partition tokens become invalid when the session used to create them - // is deleted, is idle for too long, begins a new transaction, or becomes too - // old. When any of these happen, it is not possible to resume the read, and - // the whole operation must be restarted from the beginning. - rpc PartitionRead(PartitionReadRequest) returns (PartitionResponse) { - option (google.api.http) = { - post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionRead" - body: "*" - }; - } -} - -// The request for [CreateSession][google.spanner.v1.Spanner.CreateSession]. -message CreateSessionRequest { - // Required. The database in which the new session is created. - string database = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - } - ]; - - // Required. The session to create. - Session session = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The request for [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. -message BatchCreateSessionsRequest { - // Required. The database in which the new sessions are created. - string database = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - } - ]; - - // Parameters to be applied to each created session. - Session session_template = 2; - - // Required. The number of sessions to be created in this batch call. - // The API may return fewer than the requested number of sessions. If a - // specific number of sessions are desired, the client can make additional - // calls to BatchCreateSessions (adjusting - // [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary). - int32 session_count = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// The response for [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. -message BatchCreateSessionsResponse { - // The freshly created sessions. - repeated Session session = 1; -} - -// A session in the Cloud Spanner API. -message Session { - option (google.api.resource) = { - type: "spanner.googleapis.com/Session" - pattern: "projects/{project}/instances/{instance}/databases/{database}/sessions/{session}" - }; - - // Output only. The name of the session. This is always system-assigned. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The labels for the session. - // - // * Label keys must be between 1 and 63 characters long and must conform to - // the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`. - // * Label values must be between 0 and 63 characters long and must conform - // to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. - // * No more than 64 labels can be associated with a given session. - // - // See https://goo.gl/xmQnxf for more information on and examples of labels. - map labels = 2; - - // Output only. The timestamp when the session is created. - google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The approximate timestamp when the session is last used. It is - // typically earlier than the actual last use time. - google.protobuf.Timestamp approximate_last_use_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The database role which created this session. - string creator_role = 5; -} - -// The request for [GetSession][google.spanner.v1.Spanner.GetSession]. -message GetSessionRequest { - // Required. The name of the session to retrieve. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Session" - } - ]; -} - -// The request for [ListSessions][google.spanner.v1.Spanner.ListSessions]. -message ListSessionsRequest { - // Required. The database in which to list sessions. - string database = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - } - ]; - - // Number of sessions to be returned in the response. If 0 or less, defaults - // to the server's maximum allowed page size. - int32 page_size = 2; - - // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token] from a previous - // [ListSessionsResponse][google.spanner.v1.ListSessionsResponse]. - string page_token = 3; - - // An expression for filtering the results of the request. Filter rules are - // case insensitive. The fields eligible for filtering are: - // - // * `labels.key` where key is the name of a label - // - // Some examples of using filters are: - // - // * `labels.env:*` --> The session has the label "env". - // * `labels.env:dev` --> The session has the label "env" and the value of - // the label contains the string "dev". - string filter = 4; -} - -// The response for [ListSessions][google.spanner.v1.Spanner.ListSessions]. -message ListSessionsResponse { - // The list of requested sessions. - repeated Session sessions = 1; - - // `next_page_token` can be sent in a subsequent - // [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more of the matching - // sessions. - string next_page_token = 2; -} - -// The request for [DeleteSession][google.spanner.v1.Spanner.DeleteSession]. -message DeleteSessionRequest { - // Required. The name of the session to delete. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Session" - } - ]; -} - -// Common request options for various APIs. -message RequestOptions { - // The relative priority for requests. Note that priority is not applicable - // for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction]. - // - // The priority acts as a hint to the Cloud Spanner scheduler and does not - // guarantee priority or order of execution. For example: - // - // * Some parts of a write operation always execute at `PRIORITY_HIGH`, - // regardless of the specified priority. This may cause you to see an - // increase in high priority workload even when executing a low priority - // request. This can also potentially cause a priority inversion where a - // lower priority request will be fulfilled ahead of a higher priority - // request. - // * If a transaction contains multiple operations with different priorities, - // Cloud Spanner does not guarantee to process the higher priority - // operations first. There may be other constraints to satisfy, such as - // order of operations. - enum Priority { - // `PRIORITY_UNSPECIFIED` is equivalent to `PRIORITY_HIGH`. - PRIORITY_UNSPECIFIED = 0; - - // This specifies that the request is low priority. - PRIORITY_LOW = 1; - - // This specifies that the request is medium priority. - PRIORITY_MEDIUM = 2; - - // This specifies that the request is high priority. - PRIORITY_HIGH = 3; - } - - // Priority for the request. - Priority priority = 1; - - // A per-request tag which can be applied to queries or reads, used for - // statistics collection. - // Both request_tag and transaction_tag can be specified for a read or query - // that belongs to a transaction. - // This field is ignored for requests where it's not applicable (e.g. - // CommitRequest). - // Legal characters for `request_tag` values are all printable characters - // (ASCII 32 - 126) and the length of a request_tag is limited to 50 - // characters. Values that exceed this limit are truncated. - // Any leading underscore (_) characters will be removed from the string. - string request_tag = 2; - - // A tag used for statistics collection about this transaction. - // Both request_tag and transaction_tag can be specified for a read or query - // that belongs to a transaction. - // The value of transaction_tag should be the same for all requests belonging - // to the same transaction. - // If this request doesn't belong to any transaction, transaction_tag will be - // ignored. - // Legal characters for `transaction_tag` values are all printable characters - // (ASCII 32 - 126) and the length of a transaction_tag is limited to 50 - // characters. Values that exceed this limit are truncated. - // Any leading underscore (_) characters will be removed from the string. - string transaction_tag = 3; -} - -// The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and -// [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql]. -message ExecuteSqlRequest { - // Mode in which the statement must be processed. - enum QueryMode { - // The default mode. Only the statement results are returned. - NORMAL = 0; - - // This mode returns only the query plan, without any results or - // execution statistics information. - PLAN = 1; - - // This mode returns both the query plan and the execution statistics along - // with the results. - PROFILE = 2; - } - - // Query optimizer configuration. - message QueryOptions { - // An option to control the selection of optimizer version. - // - // This parameter allows individual queries to pick different query - // optimizer versions. - // - // Specifying `latest` as a value instructs Cloud Spanner to use the - // latest supported query optimizer version. If not specified, Cloud Spanner - // uses the optimizer version set at the database level options. Any other - // positive integer (from the list of supported optimizer versions) - // overrides the default optimizer version for query execution. - // - // The list of supported optimizer versions can be queried from - // SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS. - // - // Executing a SQL statement with an invalid optimizer version fails with - // an `INVALID_ARGUMENT` error. - // - // See - // https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer - // for more information on managing the query optimizer. - // - // The `optimizer_version` statement hint has precedence over this setting. - string optimizer_version = 1; - - // An option to control the selection of optimizer statistics package. - // - // This parameter allows individual queries to use a different query - // optimizer statistics package. - // - // Specifying `latest` as a value instructs Cloud Spanner to use the latest - // generated statistics package. If not specified, Cloud Spanner uses - // the statistics package set at the database level options, or the latest - // package if the database option is not set. - // - // The statistics package requested by the query has to be exempt from - // garbage collection. This can be achieved with the following DDL - // statement: - // - // ``` - // ALTER STATISTICS SET OPTIONS (allow_gc=false) - // ``` - // - // The list of available statistics packages can be queried from - // `INFORMATION_SCHEMA.SPANNER_STATISTICS`. - // - // Executing a SQL statement with an invalid optimizer statistics package - // or with a statistics package that allows garbage collection fails with - // an `INVALID_ARGUMENT` error. - string optimizer_statistics_package = 2; - } - - // Required. The session in which the SQL query should be performed. - string session = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Session" - } - ]; - - // The transaction to use. - // - // For queries, if none is provided, the default is a temporary read-only - // transaction with strong concurrency. - // - // Standard DML statements require a read-write transaction. To protect - // against replays, single-use transactions are not supported. The caller - // must either supply an existing transaction ID or begin a new transaction. - // - // Partitioned DML requires an existing Partitioned DML transaction ID. - TransactionSelector transaction = 2; - - // Required. The SQL string. - string sql = 3 [(google.api.field_behavior) = REQUIRED]; - - // Parameter names and values that bind to placeholders in the SQL string. - // - // A parameter placeholder consists of the `@` character followed by the - // parameter name (for example, `@firstName`). Parameter names must conform - // to the naming requirements of identifiers as specified at - // https://cloud.google.com/spanner/docs/lexical#identifiers. - // - // Parameters can appear anywhere that a literal value is expected. The same - // parameter name can be used more than once, for example: - // - // `"WHERE id > @msg_id AND id < @msg_id + 100"` - // - // It is an error to execute a SQL statement with unbound parameters. - google.protobuf.Struct params = 4; - - // It is not always possible for Cloud Spanner to infer the right SQL type - // from a JSON value. For example, values of type `BYTES` and values - // of type `STRING` both appear in [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings. - // - // In these cases, `param_types` can be used to specify the exact - // SQL type for some or all of the SQL statement parameters. See the - // definition of [Type][google.spanner.v1.Type] for more information - // about SQL types. - map param_types = 5; - - // If this request is resuming a previously interrupted SQL statement - // execution, `resume_token` should be copied from the last - // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the interruption. Doing this - // enables the new SQL statement execution to resume where the last one left - // off. The rest of the request parameters must exactly match the - // request that yielded this token. - bytes resume_token = 6; - - // Used to control the amount of debugging information returned in - // [ResultSetStats][google.spanner.v1.ResultSetStats]. If [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only - // be set to [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]. - QueryMode query_mode = 7; - - // If present, results will be restricted to the specified partition - // previously created using PartitionQuery(). There must be an exact - // match for the values of fields common to this message and the - // PartitionQueryRequest message used to create this partition_token. - bytes partition_token = 8; - - // A per-transaction sequence number used to identify this request. This field - // makes each request idempotent such that if the request is received multiple - // times, at most one will succeed. - // - // The sequence number must be monotonically increasing within the - // transaction. If a request arrives for the first time with an out-of-order - // sequence number, the transaction may be aborted. Replays of previously - // handled requests will yield the same response as the first execution. - // - // Required for DML statements. Ignored for queries. - int64 seqno = 9; - - // Query optimizer configuration to use for the given query. - QueryOptions query_options = 10; - - // Common options for this request. - RequestOptions request_options = 11; - - // If this is for a partitioned read and this field is set to `true`, the - // request will be executed via Spanner independent compute resources. - // - // If the field is set to `true` but the request does not set - // `partition_token`, the API will return an `INVALID_ARGUMENT` error. - bool data_boost_enabled = 15; -} - -// The request for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. -message ExecuteBatchDmlRequest { - // A single DML statement. - message Statement { - // Required. The DML string. - string sql = 1 [(google.api.field_behavior) = REQUIRED]; - - // Parameter names and values that bind to placeholders in the DML string. - // - // A parameter placeholder consists of the `@` character followed by the - // parameter name (for example, `@firstName`). Parameter names can contain - // letters, numbers, and underscores. - // - // Parameters can appear anywhere that a literal value is expected. The - // same parameter name can be used more than once, for example: - // - // `"WHERE id > @msg_id AND id < @msg_id + 100"` - // - // It is an error to execute a SQL statement with unbound parameters. - google.protobuf.Struct params = 2; - - // It is not always possible for Cloud Spanner to infer the right SQL type - // from a JSON value. For example, values of type `BYTES` and values - // of type `STRING` both appear in [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as JSON strings. - // - // In these cases, `param_types` can be used to specify the exact - // SQL type for some or all of the SQL statement parameters. See the - // definition of [Type][google.spanner.v1.Type] for more information - // about SQL types. - map param_types = 3; - } - - // Required. The session in which the DML statements should be performed. - string session = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Session" - } - ]; - - // Required. The transaction to use. Must be a read-write transaction. - // - // To protect against replays, single-use transactions are not supported. The - // caller must either supply an existing transaction ID or begin a new - // transaction. - TransactionSelector transaction = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The list of statements to execute in this batch. Statements are executed - // serially, such that the effects of statement `i` are visible to statement - // `i+1`. Each statement must be a DML statement. Execution stops at the - // first failed statement; the remaining statements are not executed. - // - // Callers must provide at least one statement. - repeated Statement statements = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. A per-transaction sequence number used to identify this request. This field - // makes each request idempotent such that if the request is received multiple - // times, at most one will succeed. - // - // The sequence number must be monotonically increasing within the - // transaction. If a request arrives for the first time with an out-of-order - // sequence number, the transaction may be aborted. Replays of previously - // handled requests will yield the same response as the first execution. - int64 seqno = 4 [(google.api.field_behavior) = REQUIRED]; - - // Common options for this request. - RequestOptions request_options = 5; -} - -// The response for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list -// of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML statement that has successfully -// executed, in the same order as the statements in the request. If a statement -// fails, the status in the response body identifies the cause of the failure. -// -// To check for DML statements that failed, use the following approach: -// -// 1. Check the status in the response message. The [google.rpc.Code][google.rpc.Code] enum -// value `OK` indicates that all statements were executed successfully. -// 2. If the status was not `OK`, check the number of result sets in the -// response. If the response contains `N` [ResultSet][google.spanner.v1.ResultSet] messages, then -// statement `N+1` in the request failed. -// -// Example 1: -// -// * Request: 5 DML statements, all executed successfully. -// * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the status `OK`. -// -// Example 2: -// -// * Request: 5 DML statements. The third statement has a syntax error. -// * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax error (`INVALID_ARGUMENT`) -// status. The number of [ResultSet][google.spanner.v1.ResultSet] messages indicates that the third -// statement failed, and the fourth and fifth statements were not executed. -message ExecuteBatchDmlResponse { - // One [ResultSet][google.spanner.v1.ResultSet] for each statement in the request that ran successfully, - // in the same order as the statements in the request. Each [ResultSet][google.spanner.v1.ResultSet] does - // not contain any rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each [ResultSet][google.spanner.v1.ResultSet] contain - // the number of rows modified by the statement. - // - // Only the first [ResultSet][google.spanner.v1.ResultSet] in the response contains valid - // [ResultSetMetadata][google.spanner.v1.ResultSetMetadata]. - repeated ResultSet result_sets = 1; - - // If all DML statements are executed successfully, the status is `OK`. - // Otherwise, the error status of the first failed statement. - google.rpc.Status status = 2; -} - -// Options for a PartitionQueryRequest and -// PartitionReadRequest. -message PartitionOptions { - // **Note:** This hint is currently ignored by PartitionQuery and - // PartitionRead requests. - // - // The desired data size for each partition generated. The default for this - // option is currently 1 GiB. This is only a hint. The actual size of each - // partition may be smaller or larger than this size request. - int64 partition_size_bytes = 1; - - // **Note:** This hint is currently ignored by PartitionQuery and - // PartitionRead requests. - // - // The desired maximum number of partitions to return. For example, this may - // be set to the number of workers available. The default for this option - // is currently 10,000. The maximum value is currently 200,000. This is only - // a hint. The actual number of partitions returned may be smaller or larger - // than this maximum count request. - int64 max_partitions = 2; -} - -// The request for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery] -message PartitionQueryRequest { - // Required. The session used to create the partitions. - string session = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Session" - } - ]; - - // Read only snapshot transactions are supported, read/write and single use - // transactions are not. - TransactionSelector transaction = 2; - - // Required. The query request to generate partitions for. The request will fail if - // the query is not root partitionable. The query plan of a root - // partitionable query has a single distributed union operator. A distributed - // union operator conceptually divides one or more tables into multiple - // splits, remotely evaluates a subquery independently on each split, and - // then unions all results. - // - // This must not contain DML commands, such as INSERT, UPDATE, or - // DELETE. Use [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a - // PartitionedDml transaction for large, partition-friendly DML operations. - string sql = 3 [(google.api.field_behavior) = REQUIRED]; - - // Parameter names and values that bind to placeholders in the SQL string. - // - // A parameter placeholder consists of the `@` character followed by the - // parameter name (for example, `@firstName`). Parameter names can contain - // letters, numbers, and underscores. - // - // Parameters can appear anywhere that a literal value is expected. The same - // parameter name can be used more than once, for example: - // - // `"WHERE id > @msg_id AND id < @msg_id + 100"` - // - // It is an error to execute a SQL statement with unbound parameters. - google.protobuf.Struct params = 4; - - // It is not always possible for Cloud Spanner to infer the right SQL type - // from a JSON value. For example, values of type `BYTES` and values - // of type `STRING` both appear in [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings. - // - // In these cases, `param_types` can be used to specify the exact - // SQL type for some or all of the SQL query parameters. See the - // definition of [Type][google.spanner.v1.Type] for more information - // about SQL types. - map param_types = 5; - - // Additional options that affect how many partitions are created. - PartitionOptions partition_options = 6; -} - -// The request for [PartitionRead][google.spanner.v1.Spanner.PartitionRead] -message PartitionReadRequest { - // Required. The session used to create the partitions. - string session = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Session" - } - ]; - - // Read only snapshot transactions are supported, read/write and single use - // transactions are not. - TransactionSelector transaction = 2; - - // Required. The name of the table in the database to be read. - string table = 3 [(google.api.field_behavior) = REQUIRED]; - - // If non-empty, the name of an index on [table][google.spanner.v1.PartitionReadRequest.table]. This index is - // used instead of the table primary key when interpreting [key_set][google.spanner.v1.PartitionReadRequest.key_set] - // and sorting result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set] for further information. - string index = 4; - - // The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be returned for each row matching - // this request. - repeated string columns = 5; - - // Required. `key_set` identifies the rows to be yielded. `key_set` names the - // primary keys of the rows in [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless [index][google.spanner.v1.PartitionReadRequest.index] - // is present. If [index][google.spanner.v1.PartitionReadRequest.index] is present, then [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names - // index keys in [index][google.spanner.v1.PartitionReadRequest.index]. - // - // It is not an error for the `key_set` to name rows that do not - // exist in the database. Read yields nothing for nonexistent rows. - KeySet key_set = 6 [(google.api.field_behavior) = REQUIRED]; - - // Additional options that affect how many partitions are created. - PartitionOptions partition_options = 9; -} - -// Information returned for each partition returned in a -// PartitionResponse. -message Partition { - // This token can be passed to Read, StreamingRead, ExecuteSql, or - // ExecuteStreamingSql requests to restrict the results to those identified by - // this partition token. - bytes partition_token = 1; -} - -// The response for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery] -// or [PartitionRead][google.spanner.v1.Spanner.PartitionRead] -message PartitionResponse { - // Partitions created by this request. - repeated Partition partitions = 1; - - // Transaction created by this request. - Transaction transaction = 2; -} - -// The request for [Read][google.spanner.v1.Spanner.Read] and -// [StreamingRead][google.spanner.v1.Spanner.StreamingRead]. -message ReadRequest { - // Required. The session in which the read should be performed. - string session = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Session" - } - ]; - - // The transaction to use. If none is provided, the default is a - // temporary read-only transaction with strong concurrency. - TransactionSelector transaction = 2; - - // Required. The name of the table in the database to be read. - string table = 3 [(google.api.field_behavior) = REQUIRED]; - - // If non-empty, the name of an index on [table][google.spanner.v1.ReadRequest.table]. This index is - // used instead of the table primary key when interpreting [key_set][google.spanner.v1.ReadRequest.key_set] - // and sorting result rows. See [key_set][google.spanner.v1.ReadRequest.key_set] for further information. - string index = 4; - - // Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be returned for each row matching - // this request. - repeated string columns = 5 [(google.api.field_behavior) = REQUIRED]; - - // Required. `key_set` identifies the rows to be yielded. `key_set` names the - // primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to be yielded, unless [index][google.spanner.v1.ReadRequest.index] - // is present. If [index][google.spanner.v1.ReadRequest.index] is present, then [key_set][google.spanner.v1.ReadRequest.key_set] instead names - // index keys in [index][google.spanner.v1.ReadRequest.index]. - // - // If the [partition_token][google.spanner.v1.ReadRequest.partition_token] field is empty, rows are yielded - // in table primary key order (if [index][google.spanner.v1.ReadRequest.index] is empty) or index key order - // (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the [partition_token][google.spanner.v1.ReadRequest.partition_token] field is not - // empty, rows will be yielded in an unspecified order. - // - // It is not an error for the `key_set` to name rows that do not - // exist in the database. Read yields nothing for nonexistent rows. - KeySet key_set = 6 [(google.api.field_behavior) = REQUIRED]; - - // If greater than zero, only the first `limit` rows are yielded. If `limit` - // is zero, the default is no limit. A limit cannot be specified if - // `partition_token` is set. - int64 limit = 8; - - // If this request is resuming a previously interrupted read, - // `resume_token` should be copied from the last - // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the interruption. Doing this - // enables the new read to resume where the last read left off. The - // rest of the request parameters must exactly match the request - // that yielded this token. - bytes resume_token = 9; - - // If present, results will be restricted to the specified partition - // previously created using PartitionRead(). There must be an exact - // match for the values of fields common to this message and the - // PartitionReadRequest message used to create this partition_token. - bytes partition_token = 10; - - // Common options for this request. - RequestOptions request_options = 11; - - // If this is for a partitioned query and this field is set to `true`, the - // request will be executed via Spanner independent compute resources. - // - // If the field is set to `true` but the request does not set - // `partition_token`, the API will return an `INVALID_ARGUMENT` error. - bool data_boost_enabled = 16; -} - -// The request for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction]. -message BeginTransactionRequest { - // Required. The session in which the transaction runs. - string session = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Session" - } - ]; - - // Required. Options for the new transaction. - TransactionOptions options = 2 [(google.api.field_behavior) = REQUIRED]; - - // Common options for this request. - // Priority is ignored for this request. Setting the priority in this - // request_options struct will not do anything. To set the priority for a - // transaction, set it on the reads and writes that are part of this - // transaction instead. - RequestOptions request_options = 3; -} - -// The request for [Commit][google.spanner.v1.Spanner.Commit]. -message CommitRequest { - // Required. The session in which the transaction to be committed is running. - string session = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Session" - } - ]; - - // Required. The transaction in which to commit. - oneof transaction { - // Commit a previously-started transaction. - bytes transaction_id = 2; - - // Execute mutations in a temporary transaction. Note that unlike - // commit of a previously-started transaction, commit with a - // temporary transaction is non-idempotent. That is, if the - // `CommitRequest` is sent to Cloud Spanner more than once (for - // instance, due to retries in the application, or in the - // transport library), it is possible that the mutations are - // executed more than once. If this is undesirable, use - // [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and - // [Commit][google.spanner.v1.Spanner.Commit] instead. - TransactionOptions single_use_transaction = 3; - } - - // The mutations to be executed when this transaction commits. All - // mutations are applied atomically, in the order they appear in - // this list. - repeated Mutation mutations = 4; - - // If `true`, then statistics related to the transaction will be included in - // the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats]. Default value is - // `false`. - bool return_commit_stats = 5; - - // Common options for this request. - RequestOptions request_options = 6; -} - -// The request for [Rollback][google.spanner.v1.Spanner.Rollback]. -message RollbackRequest { - // Required. The session in which the transaction to roll back is running. - string session = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "spanner.googleapis.com/Session" - } - ]; - - // Required. The transaction to roll back. - bytes transaction_id = 2 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/transaction.proto b/owl-bot-staging/v1/protos/google/spanner/v1/transaction.proto deleted file mode 100644 index 49ab5cf52..000000000 --- a/owl-bot-staging/v1/protos/google/spanner/v1/transaction.proto +++ /dev/null @@ -1,525 +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.spanner.v1; - -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; -option java_multiple_files = true; -option java_outer_classname = "TransactionProto"; -option java_package = "com.google.spanner.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\V1"; -option ruby_package = "Google::Cloud::Spanner::V1"; - -// Transactions: -// -// Each session can have at most one active transaction at a time (note that -// standalone reads and queries use a transaction internally and do count -// towards the one transaction limit). After the active transaction is -// completed, the session can immediately be re-used for the next transaction. -// It is not necessary to create a new session for each transaction. -// -// Transaction modes: -// -// Cloud Spanner supports three transaction modes: -// -// 1. Locking read-write. This type of transaction is the only way -// to write data into Cloud Spanner. These transactions rely on -// pessimistic locking and, if necessary, two-phase commit. -// Locking read-write transactions may abort, requiring the -// application to retry. -// -// 2. Snapshot read-only. Snapshot read-only transactions provide guaranteed -// consistency across several reads, but do not allow -// writes. Snapshot read-only transactions can be configured to read at -// timestamps in the past, or configured to perform a strong read -// (where Spanner will select a timestamp such that the read is -// guaranteed to see the effects of all transactions that have committed -// before the start of the read). Snapshot read-only transactions do not -// need to be committed. -// -// Queries on change streams must be performed with the snapshot read-only -// transaction mode, specifying a strong read. Please see -// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong] -// for more details. -// -// 3. Partitioned DML. This type of transaction is used to execute -// a single Partitioned DML statement. Partitioned DML partitions -// the key space and runs the DML statement over each partition -// in parallel using separate, internal transactions that commit -// independently. Partitioned DML transactions do not need to be -// committed. -// -// For transactions that only read, snapshot read-only transactions -// provide simpler semantics and are almost always faster. In -// particular, read-only transactions do not take locks, so they do -// not conflict with read-write transactions. As a consequence of not -// taking locks, they also do not abort, so retry loops are not needed. -// -// Transactions may only read-write data in a single database. They -// may, however, read-write data in different tables within that -// database. -// -// Locking read-write transactions: -// -// Locking transactions may be used to atomically read-modify-write -// data anywhere in a database. This type of transaction is externally -// consistent. -// -// Clients should attempt to minimize the amount of time a transaction -// is active. Faster transactions commit with higher probability -// and cause less contention. Cloud Spanner attempts to keep read locks -// active as long as the transaction continues to do reads, and the -// transaction has not been terminated by -// [Commit][google.spanner.v1.Spanner.Commit] or -// [Rollback][google.spanner.v1.Spanner.Rollback]. Long periods of -// inactivity at the client may cause Cloud Spanner to release a -// transaction's locks and abort it. -// -// Conceptually, a read-write transaction consists of zero or more -// reads or SQL statements followed by -// [Commit][google.spanner.v1.Spanner.Commit]. At any time before -// [Commit][google.spanner.v1.Spanner.Commit], the client can send a -// [Rollback][google.spanner.v1.Spanner.Rollback] request to abort the -// transaction. -// -// Semantics: -// -// Cloud Spanner can commit the transaction if all read locks it acquired -// are still valid at commit time, and it is able to acquire write -// locks for all writes. Cloud Spanner can abort the transaction for any -// reason. If a commit attempt returns `ABORTED`, Cloud Spanner guarantees -// that the transaction has not modified any user data in Cloud Spanner. -// -// Unless the transaction commits, Cloud Spanner makes no guarantees about -// how long the transaction's locks were held for. It is an error to -// use Cloud Spanner locks for any sort of mutual exclusion other than -// between Cloud Spanner transactions themselves. -// -// Retrying aborted transactions: -// -// When a transaction aborts, the application can choose to retry the -// whole transaction again. To maximize the chances of successfully -// committing the retry, the client should execute the retry in the -// same session as the original attempt. The original session's lock -// priority increases with each consecutive abort, meaning that each -// attempt has a slightly better chance of success than the previous. -// -// Under some circumstances (for example, many transactions attempting to -// modify the same row(s)), a transaction can abort many times in a -// short period before successfully committing. Thus, it is not a good -// idea to cap the number of retries a transaction can attempt; -// instead, it is better to limit the total amount of time spent -// retrying. -// -// Idle transactions: -// -// A transaction is considered idle if it has no outstanding reads or -// SQL queries and has not started a read or SQL query within the last 10 -// seconds. Idle transactions can be aborted by Cloud Spanner so that they -// don't hold on to locks indefinitely. If an idle transaction is aborted, the -// commit will fail with error `ABORTED`. -// -// If this behavior is undesirable, periodically executing a simple -// SQL query in the transaction (for example, `SELECT 1`) prevents the -// transaction from becoming idle. -// -// Snapshot read-only transactions: -// -// Snapshot read-only transactions provides a simpler method than -// locking read-write transactions for doing several consistent -// reads. However, this type of transaction does not support writes. -// -// Snapshot transactions do not take locks. Instead, they work by -// choosing a Cloud Spanner timestamp, then executing all reads at that -// timestamp. Since they do not acquire locks, they do not block -// concurrent read-write transactions. -// -// Unlike locking read-write transactions, snapshot read-only -// transactions never abort. They can fail if the chosen read -// timestamp is garbage collected; however, the default garbage -// collection policy is generous enough that most applications do not -// need to worry about this in practice. -// -// Snapshot read-only transactions do not need to call -// [Commit][google.spanner.v1.Spanner.Commit] or -// [Rollback][google.spanner.v1.Spanner.Rollback] (and in fact are not -// permitted to do so). -// -// To execute a snapshot transaction, the client specifies a timestamp -// bound, which tells Cloud Spanner how to choose a read timestamp. -// -// The types of timestamp bound are: -// -// - Strong (the default). -// - Bounded staleness. -// - Exact staleness. -// -// If the Cloud Spanner database to be read is geographically distributed, -// stale read-only transactions can execute more quickly than strong -// or read-write transactions, because they are able to execute far -// from the leader replica. -// -// Each type of timestamp bound is discussed in detail below. -// -// Strong: Strong reads are guaranteed to see the effects of all transactions -// that have committed before the start of the read. Furthermore, all -// rows yielded by a single read are consistent with each other -- if -// any part of the read observes a transaction, all parts of the read -// see the transaction. -// -// Strong reads are not repeatable: two consecutive strong read-only -// transactions might return inconsistent results if there are -// concurrent writes. If consistency across reads is required, the -// reads should be executed within a transaction or at an exact read -// timestamp. -// -// Queries on change streams (see below for more details) must also specify -// the strong read timestamp bound. -// -// See -// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong]. -// -// Exact staleness: -// -// These timestamp bounds execute reads at a user-specified -// timestamp. Reads at a timestamp are guaranteed to see a consistent -// prefix of the global transaction history: they observe -// modifications done by all transactions with a commit timestamp less than or -// equal to the read timestamp, and observe none of the modifications done by -// transactions with a larger commit timestamp. They will block until -// all conflicting transactions that may be assigned commit timestamps -// <= the read timestamp have finished. -// -// The timestamp can either be expressed as an absolute Cloud Spanner commit -// timestamp or a staleness relative to the current time. -// -// These modes do not require a "negotiation phase" to pick a -// timestamp. As a result, they execute slightly faster than the -// equivalent boundedly stale concurrency modes. On the other hand, -// boundedly stale reads usually return fresher results. -// -// See -// [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp] -// and -// [TransactionOptions.ReadOnly.exact_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact_staleness]. -// -// Bounded staleness: -// -// Bounded staleness modes allow Cloud Spanner to pick the read timestamp, -// subject to a user-provided staleness bound. Cloud Spanner chooses the -// newest timestamp within the staleness bound that allows execution -// of the reads at the closest available replica without blocking. -// -// All rows yielded are consistent with each other -- if any part of -// the read observes a transaction, all parts of the read see the -// transaction. Boundedly stale reads are not repeatable: two stale -// reads, even if they use the same staleness bound, can execute at -// different timestamps and thus return inconsistent results. -// -// Boundedly stale reads execute in two phases: the first phase -// negotiates a timestamp among all replicas needed to serve the -// read. In the second phase, reads are executed at the negotiated -// timestamp. -// -// As a result of the two phase execution, bounded staleness reads are -// usually a little slower than comparable exact staleness -// reads. However, they are typically able to return fresher -// results, and are more likely to execute at the closest replica. -// -// Because the timestamp negotiation requires up-front knowledge of -// which rows will be read, it can only be used with single-use -// read-only transactions. -// -// See -// [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness] -// and -// [TransactionOptions.ReadOnly.min_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min_read_timestamp]. -// -// Old read timestamps and garbage collection: -// -// Cloud Spanner continuously garbage collects deleted and overwritten data -// in the background to reclaim storage space. This process is known -// as "version GC". By default, version GC reclaims versions after they -// are one hour old. Because of this, Cloud Spanner cannot perform reads -// at read timestamps more than one hour in the past. This -// restriction also applies to in-progress reads and/or SQL queries whose -// timestamp become too old while executing. Reads and SQL queries with -// too-old read timestamps fail with the error `FAILED_PRECONDITION`. -// -// You can configure and extend the `VERSION_RETENTION_PERIOD` of a -// database up to a period as long as one week, which allows Cloud Spanner -// to perform reads up to one week in the past. -// -// Querying change Streams: -// -// A Change Stream is a schema object that can be configured to watch data -// changes on the entire database, a set of tables, or a set of columns -// in a database. -// -// When a change stream is created, Spanner automatically defines a -// corresponding SQL Table-Valued Function (TVF) that can be used to query -// the change records in the associated change stream using the -// ExecuteStreamingSql API. The name of the TVF for a change stream is -// generated from the name of the change stream: READ_. -// -// All queries on change stream TVFs must be executed using the -// ExecuteStreamingSql API with a single-use read-only transaction with a -// strong read-only timestamp_bound. The change stream TVF allows users to -// specify the start_timestamp and end_timestamp for the time range of -// interest. All change records within the retention period is accessible -// using the strong read-only timestamp_bound. All other TransactionOptions -// are invalid for change stream queries. -// -// In addition, if TransactionOptions.read_only.return_read_timestamp is set -// to true, a special value of 2^63 - 2 will be returned in the -// [Transaction][google.spanner.v1.Transaction] message that describes the -// transaction, instead of a valid read timestamp. This special value should be -// discarded and not used for any subsequent queries. -// -// Please see https://cloud.google.com/spanner/docs/change-streams -// for more details on how to query the change stream TVFs. -// -// Partitioned DML transactions: -// -// Partitioned DML transactions are used to execute DML statements with a -// different execution strategy that provides different, and often better, -// scalability properties for large, table-wide operations than DML in a -// ReadWrite transaction. Smaller scoped statements, such as an OLTP workload, -// should prefer using ReadWrite transactions. -// -// Partitioned DML partitions the keyspace and runs the DML statement on each -// partition in separate, internal transactions. These transactions commit -// automatically when complete, and run independently from one another. -// -// To reduce lock contention, this execution strategy only acquires read locks -// on rows that match the WHERE clause of the statement. Additionally, the -// smaller per-partition transactions hold locks for less time. -// -// That said, Partitioned DML is not a drop-in replacement for standard DML used -// in ReadWrite transactions. -// -// - The DML statement must be fully-partitionable. Specifically, the statement -// must be expressible as the union of many statements which each access only -// a single row of the table. -// -// - The statement is not applied atomically to all rows of the table. Rather, -// the statement is applied atomically to partitions of the table, in -// independent transactions. Secondary index rows are updated atomically -// with the base table rows. -// -// - Partitioned DML does not guarantee exactly-once execution semantics -// against a partition. The statement will be applied at least once to each -// partition. It is strongly recommended that the DML statement should be -// idempotent to avoid unexpected results. For instance, it is potentially -// dangerous to run a statement such as -// `UPDATE table SET column = column + 1` as it could be run multiple times -// against some rows. -// -// - The partitions are committed automatically - there is no support for -// Commit or Rollback. If the call returns an error, or if the client issuing -// the ExecuteSql call dies, it is possible that some rows had the statement -// executed on them successfully. It is also possible that statement was -// never executed against other rows. -// -// - Partitioned DML transactions may only contain the execution of a single -// DML statement via ExecuteSql or ExecuteStreamingSql. -// -// - If any error is encountered during the execution of the partitioned DML -// operation (for instance, a UNIQUE INDEX violation, division by zero, or a -// value that cannot be stored due to schema constraints), then the -// operation is stopped at that point and an error is returned. It is -// possible that at this point, some partitions have been committed (or even -// committed multiple times), and other partitions have not been run at all. -// -// Given the above, Partitioned DML is good fit for large, database-wide, -// operations that are idempotent, such as deleting old rows from a very large -// table. -message TransactionOptions { - // Message type to initiate a read-write transaction. Currently this - // transaction type has no options. - message ReadWrite { - // `ReadLockMode` is used to set the read lock mode for read-write - // transactions. - enum ReadLockMode { - // Default value. - // - // If the value is not specified, the pessimistic read lock is used. - READ_LOCK_MODE_UNSPECIFIED = 0; - - // Pessimistic lock mode. - // - // Read locks are acquired immediately on read. - PESSIMISTIC = 1; - - // Optimistic lock mode. - // - // Locks for reads within the transaction are not acquired on read. - // Instead the locks are acquired on a commit to validate that - // read/queried data has not changed since the transaction started. - OPTIMISTIC = 2; - } - - // Read lock mode for the transaction. - ReadLockMode read_lock_mode = 1; - } - - // Message type to initiate a Partitioned DML transaction. - message PartitionedDml {} - - // Message type to initiate a read-only transaction. - message ReadOnly { - // How to choose the timestamp for the read-only transaction. - oneof timestamp_bound { - // Read at a timestamp where all previously committed transactions - // are visible. - bool strong = 1; - - // Executes all reads at a timestamp >= `min_read_timestamp`. - // - // This is useful for requesting fresher data than some previous - // read, or data that is fresh enough to observe the effects of some - // previously committed transaction whose timestamp is known. - // - // Note that this option can only be used in single-use transactions. - // - // A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. - // Example: `"2014-10-02T15:01:23.045123456Z"`. - google.protobuf.Timestamp min_read_timestamp = 2; - - // Read data at a timestamp >= `NOW - max_staleness` - // seconds. Guarantees that all writes that have committed more - // than the specified number of seconds ago are visible. Because - // Cloud Spanner chooses the exact timestamp, this mode works even if - // the client's local clock is substantially skewed from Cloud Spanner - // commit timestamps. - // - // Useful for reading the freshest data available at a nearby - // replica, while bounding the possible staleness if the local - // replica has fallen behind. - // - // Note that this option can only be used in single-use - // transactions. - google.protobuf.Duration max_staleness = 3; - - // Executes all reads at the given timestamp. Unlike other modes, - // reads at a specific timestamp are repeatable; the same read at - // the same timestamp always returns the same data. If the - // timestamp is in the future, the read will block until the - // specified timestamp, modulo the read's deadline. - // - // Useful for large scale consistent reads such as mapreduces, or - // for coordinating many reads against a consistent snapshot of the - // data. - // - // A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. - // Example: `"2014-10-02T15:01:23.045123456Z"`. - google.protobuf.Timestamp read_timestamp = 4; - - // Executes all reads at a timestamp that is `exact_staleness` - // old. The timestamp is chosen soon after the read is started. - // - // Guarantees that all writes that have committed more than the - // specified number of seconds ago are visible. Because Cloud Spanner - // chooses the exact timestamp, this mode works even if the client's - // local clock is substantially skewed from Cloud Spanner commit - // timestamps. - // - // Useful for reading at nearby replicas without the distributed - // timestamp negotiation overhead of `max_staleness`. - google.protobuf.Duration exact_staleness = 5; - } - - // If true, the Cloud Spanner-selected read timestamp is included in - // the [Transaction][google.spanner.v1.Transaction] message that describes - // the transaction. - bool return_read_timestamp = 6; - } - - // Required. The type of transaction. - oneof mode { - // Transaction may write. - // - // Authorization to begin a read-write transaction requires - // `spanner.databases.beginOrRollbackReadWriteTransaction` permission - // on the `session` resource. - ReadWrite read_write = 1; - - // Partitioned DML transaction. - // - // Authorization to begin a Partitioned DML transaction requires - // `spanner.databases.beginPartitionedDmlTransaction` permission - // on the `session` resource. - PartitionedDml partitioned_dml = 3; - - // Transaction will not write. - // - // Authorization to begin a read-only transaction requires - // `spanner.databases.beginReadOnlyTransaction` permission - // on the `session` resource. - ReadOnly read_only = 2; - } -} - -// A transaction. -message Transaction { - // `id` may be used to identify the transaction in subsequent - // [Read][google.spanner.v1.Spanner.Read], - // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], - // [Commit][google.spanner.v1.Spanner.Commit], or - // [Rollback][google.spanner.v1.Spanner.Rollback] calls. - // - // Single-use read-only transactions do not have IDs, because - // single-use transactions do not support multiple requests. - bytes id = 1; - - // For snapshot read-only transactions, the read timestamp chosen - // for the transaction. Not returned by default: see - // [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp]. - // - // A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. - // Example: `"2014-10-02T15:01:23.045123456Z"`. - google.protobuf.Timestamp read_timestamp = 2; -} - -// This message is used to select the transaction in which a -// [Read][google.spanner.v1.Spanner.Read] or -// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs. -// -// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more -// information about transactions. -message TransactionSelector { - // If no fields are set, the default is a single use transaction - // with strong concurrency. - oneof selector { - // Execute the read or SQL query in a temporary transaction. - // This is the most efficient way to execute a transaction that - // consists of a single SQL query. - TransactionOptions single_use = 1; - - // Execute the read or SQL query in a previously-started transaction. - bytes id = 2; - - // Begin a new transaction and execute this read or SQL query in - // it. The transaction ID of the new transaction is returned in - // [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction], - // which is a [Transaction][google.spanner.v1.Transaction]. - TransactionOptions begin = 3; - } -} diff --git a/owl-bot-staging/v1/protos/google/spanner/v1/type.proto b/owl-bot-staging/v1/protos/google/spanner/v1/type.proto deleted file mode 100644 index 712ec187f..000000000 --- a/owl-bot-staging/v1/protos/google/spanner/v1/type.proto +++ /dev/null @@ -1,174 +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.spanner.v1; - -import "google/api/field_behavior.proto"; - -option csharp_namespace = "Google.Cloud.Spanner.V1"; -option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner"; -option java_multiple_files = true; -option java_outer_classname = "TypeProto"; -option java_package = "com.google.spanner.v1"; -option php_namespace = "Google\\Cloud\\Spanner\\V1"; -option ruby_package = "Google::Cloud::Spanner::V1"; - -// `Type` indicates the type of a Cloud Spanner value, as might be stored in a -// table cell or returned from an SQL query. -message Type { - // Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. - TypeCode code = 1 [(google.api.field_behavior) = REQUIRED]; - - // If [code][google.spanner.v1.Type.code] == [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` - // is the type of the array elements. - Type array_element_type = 2; - - // If [code][google.spanner.v1.Type.code] == [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` - // provides type information for the struct's fields. - StructType struct_type = 3; - - // The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that disambiguates SQL type that Spanner will - // use to represent values of this type during query processing. This is - // necessary for some type codes because a single [TypeCode][google.spanner.v1.TypeCode] can be mapped - // to different SQL types depending on the SQL dialect. [type_annotation][google.spanner.v1.Type.type_annotation] - // typically is not needed to process the content of a value (it doesn't - // affect serialization) and clients can ignore it on the read path. - TypeAnnotationCode type_annotation = 4; -} - -// `StructType` defines the fields of a [STRUCT][google.spanner.v1.TypeCode.STRUCT] type. -message StructType { - // Message representing a single field of a struct. - message Field { - // The name of the field. For reads, this is the column name. For - // SQL queries, it is the column alias (e.g., `"Word"` in the - // query `"SELECT 'hello' AS Word"`), or the column name (e.g., - // `"ColName"` in the query `"SELECT ColName FROM Table"`). Some - // columns might have an empty name (e.g., `"SELECT - // UPPER(ColName)"`). Note that a query result can contain - // multiple fields with the same name. - string name = 1; - - // The type of the field. - Type type = 2; - } - - // The list of fields that make up this struct. Order is - // significant, because values of this struct type are represented as - // lists, where the order of field values matches the order of - // fields in the [StructType][google.spanner.v1.StructType]. In turn, the order of fields - // matches the order of columns in a read request, or the order of - // fields in the `SELECT` clause of a query. - repeated Field fields = 1; -} - -// `TypeCode` is used as part of [Type][google.spanner.v1.Type] to -// indicate the type of a Cloud Spanner value. -// -// Each legal value of a type can be encoded to or decoded from a JSON -// value, using the encodings described below. All Cloud Spanner values can -// be `null`, regardless of type; `null`s are always encoded as a JSON -// `null`. -enum TypeCode { - // Not specified. - TYPE_CODE_UNSPECIFIED = 0; - - // Encoded as JSON `true` or `false`. - BOOL = 1; - - // Encoded as `string`, in decimal format. - INT64 = 2; - - // Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or - // `"-Infinity"`. - FLOAT64 = 3; - - // Encoded as `string` in RFC 3339 timestamp format. The time zone - // must be present, and must be `"Z"`. - // - // If the schema has the column option - // `allow_commit_timestamp=true`, the placeholder string - // `"spanner.commit_timestamp()"` can be used to instruct the system - // to insert the commit timestamp associated with the transaction - // commit. - TIMESTAMP = 4; - - // Encoded as `string` in RFC 3339 date format. - DATE = 5; - - // Encoded as `string`. - STRING = 6; - - // Encoded as a base64-encoded `string`, as described in RFC 4648, - // section 4. - BYTES = 7; - - // Encoded as `list`, where the list elements are represented - // according to - // [array_element_type][google.spanner.v1.Type.array_element_type]. - ARRAY = 8; - - // Encoded as `list`, where list element `i` is represented according - // to [struct_type.fields[i]][google.spanner.v1.StructType.fields]. - STRUCT = 9; - - // Encoded as `string`, in decimal format or scientific notation format. - //
Decimal format: - //
`[+-]Digits[.[Digits]]` or - //
`[+-][Digits].Digits` - // - // Scientific notation: - //
`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or - //
`[+-][Digits].Digits[ExponentIndicator[+-]Digits]` - //
(ExponentIndicator is `"e"` or `"E"`) - NUMERIC = 10; - - // Encoded as a JSON-formatted `string` as described in RFC 7159. The - // following rules are applied when parsing JSON input: - // - // - Whitespace characters are not preserved. - // - If a JSON object has duplicate keys, only the first key is preserved. - // - Members of a JSON object are not guaranteed to have their order - // preserved. - // - JSON array elements will have their order preserved. - JSON = 11; -} - -// `TypeAnnotationCode` is used as a part of [Type][google.spanner.v1.Type] to -// disambiguate SQL types that should be used for a given Cloud Spanner value. -// Disambiguation is needed because the same Cloud Spanner type can be mapped to -// different SQL types depending on SQL dialect. TypeAnnotationCode doesn't -// affect the way value is serialized. -enum TypeAnnotationCode { - // Not specified. - TYPE_ANNOTATION_CODE_UNSPECIFIED = 0; - - // PostgreSQL compatible NUMERIC type. This annotation needs to be applied to - // [Type][google.spanner.v1.Type] instances having [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] - // type code to specify that values of this type should be treated as - // PostgreSQL NUMERIC values. Currently this annotation is always needed for - // [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] when a client interacts with PostgreSQL-enabled - // Spanner databases. - PG_NUMERIC = 2; - - // PostgreSQL compatible JSONB type. This annotation needs to be applied to - // [Type][google.spanner.v1.Type] instances having [JSON][google.spanner.v1.TypeCode.JSON] - // type code to specify that values of this type should be treated as - // PostgreSQL JSONB values. Currently this annotation is always needed for - // [JSON][google.spanner.v1.TypeCode.JSON] when a client interacts with PostgreSQL-enabled - // Spanner databases. - PG_JSONB = 3; -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 65a2f00e9..000000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const SpannerClient = v1.SpannerClient; -type SpannerClient = v1.SpannerClient; -export {v1, SpannerClient}; -export default {v1, SpannerClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index e10e70ad5..000000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,167 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.spanner.v1", - "libraryPackage": "@google-cloud/spanner", - "services": { - "Spanner": { - "clients": { - "grpc": { - "libraryClient": "SpannerClient", - "rpcs": { - "CreateSession": { - "methods": [ - "createSession" - ] - }, - "BatchCreateSessions": { - "methods": [ - "batchCreateSessions" - ] - }, - "GetSession": { - "methods": [ - "getSession" - ] - }, - "DeleteSession": { - "methods": [ - "deleteSession" - ] - }, - "ExecuteSql": { - "methods": [ - "executeSql" - ] - }, - "ExecuteBatchDml": { - "methods": [ - "executeBatchDml" - ] - }, - "Read": { - "methods": [ - "read" - ] - }, - "BeginTransaction": { - "methods": [ - "beginTransaction" - ] - }, - "Commit": { - "methods": [ - "commit" - ] - }, - "Rollback": { - "methods": [ - "rollback" - ] - }, - "PartitionQuery": { - "methods": [ - "partitionQuery" - ] - }, - "PartitionRead": { - "methods": [ - "partitionRead" - ] - }, - "ExecuteStreamingSql": { - "methods": [ - "executeStreamingSql" - ] - }, - "StreamingRead": { - "methods": [ - "streamingRead" - ] - }, - "ListSessions": { - "methods": [ - "listSessions", - "listSessionsStream", - "listSessionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SpannerClient", - "rpcs": { - "CreateSession": { - "methods": [ - "createSession" - ] - }, - "BatchCreateSessions": { - "methods": [ - "batchCreateSessions" - ] - }, - "GetSession": { - "methods": [ - "getSession" - ] - }, - "DeleteSession": { - "methods": [ - "deleteSession" - ] - }, - "ExecuteSql": { - "methods": [ - "executeSql" - ] - }, - "ExecuteBatchDml": { - "methods": [ - "executeBatchDml" - ] - }, - "Read": { - "methods": [ - "read" - ] - }, - "BeginTransaction": { - "methods": [ - "beginTransaction" - ] - }, - "Commit": { - "methods": [ - "commit" - ] - }, - "Rollback": { - "methods": [ - "rollback" - ] - }, - "PartitionQuery": { - "methods": [ - "partitionQuery" - ] - }, - "PartitionRead": { - "methods": [ - "partitionRead" - ] - }, - "ListSessions": { - "methods": [ - "listSessions", - "listSessionsStream", - "listSessionsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 680a3e1f4..000000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 {SpannerClient} from './spanner_client'; diff --git a/owl-bot-staging/v1/src/v1/spanner_client.ts b/owl-bot-staging/v1/src/v1/spanner_client.ts deleted file mode 100644 index 871ae0d5d..000000000 --- a/owl-bot-staging/v1/src/v1/spanner_client.ts +++ /dev/null @@ -1,2047 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform, PassThrough} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/spanner_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './spanner_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Cloud Spanner API - * - * The Cloud Spanner API can be used to manage sessions and execute - * transactions on data stored in Cloud Spanner databases. - * @class - * @memberof v1 - */ -export class SpannerClient { - 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}; - spannerStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SpannerClient. - * - * @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 SpannerClient({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 SpannerClient; - 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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 = { - databasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}/databases/{database}' - ), - sessionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/instances/{instance}/databases/{database}/sessions/{session}' - ), - }; - - // 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 = { - listSessions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'sessions') - }; - - // Some of the methods on this service provide streaming responses. - // Provide descriptors for these. - this.descriptors.stream = { - executeStreamingSql: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), - streamingRead: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.spanner.v1.Spanner', 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.spannerStub) { - return this.spannerStub; - } - - // Put together the "service stub" for - // google.spanner.v1.Spanner. - this.spannerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.spanner.v1.Spanner') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.spanner.v1.Spanner, - 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 spannerStubMethods = - ['createSession', 'batchCreateSessions', 'getSession', 'listSessions', 'deleteSession', 'executeSql', 'executeStreamingSql', 'executeBatchDml', 'read', 'streamingRead', 'beginTransaction', 'commit', 'rollback', 'partitionQuery', 'partitionRead']; - for (const methodName of spannerStubMethods) { - const callPromise = this.spannerStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - if (methodName in this.descriptors.stream) { - const stream = new PassThrough(); - setImmediate(() => { - stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.')); - }); - return stream; - } - 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.stream[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.spannerStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'spanner.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 'spanner.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', - 'https://www.googleapis.com/auth/spanner.data' - ]; - } - - 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 -- - // ------------------- -/** - * Creates a new session. A session can be used to perform - * transactions that read and/or modify data in a Cloud Spanner database. - * Sessions are meant to be reused for many consecutive - * transactions. - * - * Sessions can only execute one transaction at a time. To execute - * multiple concurrent read-write/write-only transactions, create - * multiple sessions. Note that standalone reads and queries use a - * transaction internally, and count toward the one transaction - * limit. - * - * Active sessions use additional server resources, so it is a good idea to - * delete idle and unneeded sessions. - * Aside from explicit deletes, Cloud Spanner may delete sessions for which no - * operations are sent for more than an hour. If a session is deleted, - * requests to it return `NOT_FOUND`. - * - * Idle sessions can be kept alive by sending a trivial SQL query - * periodically, e.g., `"SELECT 1"`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database in which the new session is created. - * @param {google.spanner.v1.Session} request.session - * Required. The session to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.spanner.v1.Session | Session}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - createSession( - request?: protos.google.spanner.v1.ICreateSessionRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.ICreateSessionRequest|undefined, {}|undefined - ]>; - createSession( - request: protos.google.spanner.v1.ICreateSessionRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.ICreateSessionRequest|null|undefined, - {}|null|undefined>): void; - createSession( - request: protos.google.spanner.v1.ICreateSessionRequest, - callback: Callback< - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.ICreateSessionRequest|null|undefined, - {}|null|undefined>): void; - createSession( - request?: protos.google.spanner.v1.ICreateSessionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.ICreateSessionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.ICreateSessionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.ICreateSessionRequest|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({ - 'database': request.database ?? '', - }); - this.initialize(); - return this.innerApiCalls.createSession(request, options, callback); - } -/** - * Creates multiple new sessions. - * - * This API can be used to initialize a session cache on the clients. - * See https://goo.gl/TgSFN2 for best practices on session cache management. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database in which the new sessions are created. - * @param {google.spanner.v1.Session} request.sessionTemplate - * Parameters to be applied to each created session. - * @param {number} request.sessionCount - * Required. The number of sessions to be created in this batch call. - * The API may return fewer than the requested number of sessions. If a - * specific number of sessions are desired, the client can make additional - * calls to BatchCreateSessions (adjusting - * {@link google.spanner.v1.BatchCreateSessionsRequest.session_count|session_count} as necessary). - * @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 {@link google.spanner.v1.BatchCreateSessionsResponse | BatchCreateSessionsResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - batchCreateSessions( - request?: protos.google.spanner.v1.IBatchCreateSessionsRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.IBatchCreateSessionsResponse, - protos.google.spanner.v1.IBatchCreateSessionsRequest|undefined, {}|undefined - ]>; - batchCreateSessions( - request: protos.google.spanner.v1.IBatchCreateSessionsRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.v1.IBatchCreateSessionsResponse, - protos.google.spanner.v1.IBatchCreateSessionsRequest|null|undefined, - {}|null|undefined>): void; - batchCreateSessions( - request: protos.google.spanner.v1.IBatchCreateSessionsRequest, - callback: Callback< - protos.google.spanner.v1.IBatchCreateSessionsResponse, - protos.google.spanner.v1.IBatchCreateSessionsRequest|null|undefined, - {}|null|undefined>): void; - batchCreateSessions( - request?: protos.google.spanner.v1.IBatchCreateSessionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.v1.IBatchCreateSessionsResponse, - protos.google.spanner.v1.IBatchCreateSessionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.v1.IBatchCreateSessionsResponse, - protos.google.spanner.v1.IBatchCreateSessionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.v1.IBatchCreateSessionsResponse, - protos.google.spanner.v1.IBatchCreateSessionsRequest|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({ - 'database': request.database ?? '', - }); - this.initialize(); - return this.innerApiCalls.batchCreateSessions(request, options, callback); - } -/** - * Gets a session. Returns `NOT_FOUND` if the session does not exist. - * This is mainly useful for determining whether a session is still - * alive. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the session to retrieve. - * @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 {@link google.spanner.v1.Session | Session}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - getSession( - request?: protos.google.spanner.v1.IGetSessionRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.IGetSessionRequest|undefined, {}|undefined - ]>; - getSession( - request: protos.google.spanner.v1.IGetSessionRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.IGetSessionRequest|null|undefined, - {}|null|undefined>): void; - getSession( - request: protos.google.spanner.v1.IGetSessionRequest, - callback: Callback< - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.IGetSessionRequest|null|undefined, - {}|null|undefined>): void; - getSession( - request?: protos.google.spanner.v1.IGetSessionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.IGetSessionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.IGetSessionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.v1.ISession, - protos.google.spanner.v1.IGetSessionRequest|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({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getSession(request, options, callback); - } -/** - * Ends a session, releasing server resources associated with it. This will - * asynchronously trigger cancellation of any operations that are running with - * this session. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the session to delete. - * @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 {@link google.protobuf.Empty | Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - deleteSession( - request?: protos.google.spanner.v1.IDeleteSessionRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IDeleteSessionRequest|undefined, {}|undefined - ]>; - deleteSession( - request: protos.google.spanner.v1.IDeleteSessionRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IDeleteSessionRequest|null|undefined, - {}|null|undefined>): void; - deleteSession( - request: protos.google.spanner.v1.IDeleteSessionRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IDeleteSessionRequest|null|undefined, - {}|null|undefined>): void; - deleteSession( - request?: protos.google.spanner.v1.IDeleteSessionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IDeleteSessionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IDeleteSessionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IDeleteSessionRequest|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({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteSession(request, options, callback); - } -/** - * Executes an SQL statement, returning all results in a single reply. This - * method cannot be used to return a result set larger than 10 MiB; - * if the query yields more data than that, the query fails with - * a `FAILED_PRECONDITION` error. - * - * Operations inside read-write transactions might return `ABORTED`. If - * this occurs, the application should restart the transaction from - * the beginning. See {@link google.spanner.v1.Transaction|Transaction} for more details. - * - * Larger result sets can be fetched in streaming fashion by calling - * {@link google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} instead. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.session - * Required. The session in which the SQL query should be performed. - * @param {google.spanner.v1.TransactionSelector} request.transaction - * The transaction to use. - * - * For queries, if none is provided, the default is a temporary read-only - * transaction with strong concurrency. - * - * Standard DML statements require a read-write transaction. To protect - * against replays, single-use transactions are not supported. The caller - * must either supply an existing transaction ID or begin a new transaction. - * - * Partitioned DML requires an existing Partitioned DML transaction ID. - * @param {string} request.sql - * Required. The SQL string. - * @param {google.protobuf.Struct} request.params - * Parameter names and values that bind to placeholders in the SQL string. - * - * A parameter placeholder consists of the `@` character followed by the - * parameter name (for example, `@firstName`). Parameter names must conform - * to the naming requirements of identifiers as specified at - * https://cloud.google.com/spanner/docs/lexical#identifiers. - * - * Parameters can appear anywhere that a literal value is expected. The same - * parameter name can be used more than once, for example: - * - * `"WHERE id > @msg_id AND id < @msg_id + 100"` - * - * It is an error to execute a SQL statement with unbound parameters. - * @param {number[]} request.paramTypes - * It is not always possible for Cloud Spanner to infer the right SQL type - * from a JSON value. For example, values of type `BYTES` and values - * of type `STRING` both appear in {@link google.spanner.v1.ExecuteSqlRequest.params|params} as JSON strings. - * - * In these cases, `param_types` can be used to specify the exact - * SQL type for some or all of the SQL statement parameters. See the - * definition of {@link google.spanner.v1.Type|Type} for more information - * about SQL types. - * @param {Buffer} request.resumeToken - * If this request is resuming a previously interrupted SQL statement - * execution, `resume_token` should be copied from the last - * {@link google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the interruption. Doing this - * enables the new SQL statement execution to resume where the last one left - * off. The rest of the request parameters must exactly match the - * request that yielded this token. - * @param {google.spanner.v1.ExecuteSqlRequest.QueryMode} request.queryMode - * Used to control the amount of debugging information returned in - * {@link google.spanner.v1.ResultSetStats|ResultSetStats}. If {@link google.spanner.v1.ExecuteSqlRequest.partition_token|partition_token} is set, {@link google.spanner.v1.ExecuteSqlRequest.query_mode|query_mode} can only - * be set to {@link google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL|QueryMode.NORMAL}. - * @param {Buffer} request.partitionToken - * If present, results will be restricted to the specified partition - * previously created using PartitionQuery(). There must be an exact - * match for the values of fields common to this message and the - * PartitionQueryRequest message used to create this partition_token. - * @param {number} request.seqno - * A per-transaction sequence number used to identify this request. This field - * makes each request idempotent such that if the request is received multiple - * times, at most one will succeed. - * - * The sequence number must be monotonically increasing within the - * transaction. If a request arrives for the first time with an out-of-order - * sequence number, the transaction may be aborted. Replays of previously - * handled requests will yield the same response as the first execution. - * - * Required for DML statements. Ignored for queries. - * @param {google.spanner.v1.ExecuteSqlRequest.QueryOptions} request.queryOptions - * Query optimizer configuration to use for the given query. - * @param {google.spanner.v1.RequestOptions} request.requestOptions - * Common options for this request. - * @param {boolean} request.dataBoostEnabled - * If this is for a partitioned read and this field is set to `true`, the - * request will be executed via Spanner independent compute resources. - * - * If the field is set to `true` but the request does not set - * `partition_token`, the API will return an `INVALID_ARGUMENT` error. - * @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 {@link google.spanner.v1.ResultSet | ResultSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - executeSql( - request?: protos.google.spanner.v1.IExecuteSqlRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IExecuteSqlRequest|undefined, {}|undefined - ]>; - executeSql( - request: protos.google.spanner.v1.IExecuteSqlRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IExecuteSqlRequest|null|undefined, - {}|null|undefined>): void; - executeSql( - request: protos.google.spanner.v1.IExecuteSqlRequest, - callback: Callback< - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IExecuteSqlRequest|null|undefined, - {}|null|undefined>): void; - executeSql( - request?: protos.google.spanner.v1.IExecuteSqlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IExecuteSqlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IExecuteSqlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IExecuteSqlRequest|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({ - 'session': request.session ?? '', - }); - this.initialize(); - return this.innerApiCalls.executeSql(request, options, callback); - } -/** - * Executes a batch of SQL DML statements. This method allows many statements - * to be run with lower latency than submitting them sequentially with - * {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}. - * - * Statements are executed in sequential order. A request can succeed even if - * a statement fails. The {@link google.spanner.v1.ExecuteBatchDmlResponse.status|ExecuteBatchDmlResponse.status} field in the - * response provides information about the statement that failed. Clients must - * inspect this field to determine whether an error occurred. - * - * Execution stops after the first failed statement; the remaining statements - * are not executed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.session - * Required. The session in which the DML statements should be performed. - * @param {google.spanner.v1.TransactionSelector} request.transaction - * Required. The transaction to use. Must be a read-write transaction. - * - * To protect against replays, single-use transactions are not supported. The - * caller must either supply an existing transaction ID or begin a new - * transaction. - * @param {number[]} request.statements - * Required. The list of statements to execute in this batch. Statements are executed - * serially, such that the effects of statement `i` are visible to statement - * `i+1`. Each statement must be a DML statement. Execution stops at the - * first failed statement; the remaining statements are not executed. - * - * Callers must provide at least one statement. - * @param {number} request.seqno - * Required. A per-transaction sequence number used to identify this request. This field - * makes each request idempotent such that if the request is received multiple - * times, at most one will succeed. - * - * The sequence number must be monotonically increasing within the - * transaction. If a request arrives for the first time with an out-of-order - * sequence number, the transaction may be aborted. Replays of previously - * handled requests will yield the same response as the first execution. - * @param {google.spanner.v1.RequestOptions} request.requestOptions - * Common options for this request. - * @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 {@link google.spanner.v1.ExecuteBatchDmlResponse | ExecuteBatchDmlResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - executeBatchDml( - request?: protos.google.spanner.v1.IExecuteBatchDmlRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.IExecuteBatchDmlResponse, - protos.google.spanner.v1.IExecuteBatchDmlRequest|undefined, {}|undefined - ]>; - executeBatchDml( - request: protos.google.spanner.v1.IExecuteBatchDmlRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.v1.IExecuteBatchDmlResponse, - protos.google.spanner.v1.IExecuteBatchDmlRequest|null|undefined, - {}|null|undefined>): void; - executeBatchDml( - request: protos.google.spanner.v1.IExecuteBatchDmlRequest, - callback: Callback< - protos.google.spanner.v1.IExecuteBatchDmlResponse, - protos.google.spanner.v1.IExecuteBatchDmlRequest|null|undefined, - {}|null|undefined>): void; - executeBatchDml( - request?: protos.google.spanner.v1.IExecuteBatchDmlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.v1.IExecuteBatchDmlResponse, - protos.google.spanner.v1.IExecuteBatchDmlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.v1.IExecuteBatchDmlResponse, - protos.google.spanner.v1.IExecuteBatchDmlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.v1.IExecuteBatchDmlResponse, - protos.google.spanner.v1.IExecuteBatchDmlRequest|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({ - 'session': request.session ?? '', - }); - this.initialize(); - return this.innerApiCalls.executeBatchDml(request, options, callback); - } -/** - * Reads rows from the database using key lookups and scans, as a - * simple key/value style alternative to - * {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}. This method cannot be used to - * return a result set larger than 10 MiB; if the read matches more - * data than that, the read fails with a `FAILED_PRECONDITION` - * error. - * - * Reads inside read-write transactions might return `ABORTED`. If - * this occurs, the application should restart the transaction from - * the beginning. See {@link google.spanner.v1.Transaction|Transaction} for more details. - * - * Larger result sets can be yielded in streaming fashion by calling - * {@link google.spanner.v1.Spanner.StreamingRead|StreamingRead} instead. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.session - * Required. The session in which the read should be performed. - * @param {google.spanner.v1.TransactionSelector} request.transaction - * The transaction to use. If none is provided, the default is a - * temporary read-only transaction with strong concurrency. - * @param {string} request.table - * Required. The name of the table in the database to be read. - * @param {string} request.index - * If non-empty, the name of an index on {@link google.spanner.v1.ReadRequest.table|table}. This index is - * used instead of the table primary key when interpreting {@link google.spanner.v1.ReadRequest.key_set|key_set} - * and sorting result rows. See {@link google.spanner.v1.ReadRequest.key_set|key_set} for further information. - * @param {string[]} request.columns - * Required. The columns of {@link google.spanner.v1.ReadRequest.table|table} to be returned for each row matching - * this request. - * @param {google.spanner.v1.KeySet} request.keySet - * Required. `key_set` identifies the rows to be yielded. `key_set` names the - * primary keys of the rows in {@link google.spanner.v1.ReadRequest.table|table} to be yielded, unless {@link google.spanner.v1.ReadRequest.index|index} - * is present. If {@link google.spanner.v1.ReadRequest.index|index} is present, then {@link google.spanner.v1.ReadRequest.key_set|key_set} instead names - * index keys in {@link google.spanner.v1.ReadRequest.index|index}. - * - * If the {@link google.spanner.v1.ReadRequest.partition_token|partition_token} field is empty, rows are yielded - * in table primary key order (if {@link google.spanner.v1.ReadRequest.index|index} is empty) or index key order - * (if {@link google.spanner.v1.ReadRequest.index|index} is non-empty). If the {@link google.spanner.v1.ReadRequest.partition_token|partition_token} field is not - * empty, rows will be yielded in an unspecified order. - * - * It is not an error for the `key_set` to name rows that do not - * exist in the database. Read yields nothing for nonexistent rows. - * @param {number} request.limit - * If greater than zero, only the first `limit` rows are yielded. If `limit` - * is zero, the default is no limit. A limit cannot be specified if - * `partition_token` is set. - * @param {Buffer} request.resumeToken - * If this request is resuming a previously interrupted read, - * `resume_token` should be copied from the last - * {@link google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the interruption. Doing this - * enables the new read to resume where the last read left off. The - * rest of the request parameters must exactly match the request - * that yielded this token. - * @param {Buffer} request.partitionToken - * If present, results will be restricted to the specified partition - * previously created using PartitionRead(). There must be an exact - * match for the values of fields common to this message and the - * PartitionReadRequest message used to create this partition_token. - * @param {google.spanner.v1.RequestOptions} request.requestOptions - * Common options for this request. - * @param {boolean} request.dataBoostEnabled - * If this is for a partitioned query and this field is set to `true`, the - * request will be executed via Spanner independent compute resources. - * - * If the field is set to `true` but the request does not set - * `partition_token`, the API will return an `INVALID_ARGUMENT` error. - * @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 {@link google.spanner.v1.ResultSet | ResultSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - read( - request?: protos.google.spanner.v1.IReadRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IReadRequest|undefined, {}|undefined - ]>; - read( - request: protos.google.spanner.v1.IReadRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IReadRequest|null|undefined, - {}|null|undefined>): void; - read( - request: protos.google.spanner.v1.IReadRequest, - callback: Callback< - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IReadRequest|null|undefined, - {}|null|undefined>): void; - read( - request?: protos.google.spanner.v1.IReadRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IReadRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IReadRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.v1.IResultSet, - protos.google.spanner.v1.IReadRequest|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({ - 'session': request.session ?? '', - }); - this.initialize(); - return this.innerApiCalls.read(request, options, callback); - } -/** - * Begins a new transaction. This step can often be skipped: - * {@link google.spanner.v1.Spanner.Read|Read}, {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql} and - * {@link google.spanner.v1.Spanner.Commit|Commit} can begin a new transaction as a - * side-effect. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.session - * Required. The session in which the transaction runs. - * @param {google.spanner.v1.TransactionOptions} request.options - * Required. Options for the new transaction. - * @param {google.spanner.v1.RequestOptions} request.requestOptions - * Common options for this request. - * Priority is ignored for this request. Setting the priority in this - * request_options struct will not do anything. To set the priority for a - * transaction, set it on the reads and writes that are part of this - * transaction instead. - * @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 {@link google.spanner.v1.Transaction | Transaction}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - beginTransaction( - request?: protos.google.spanner.v1.IBeginTransactionRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.ITransaction, - protos.google.spanner.v1.IBeginTransactionRequest|undefined, {}|undefined - ]>; - beginTransaction( - request: protos.google.spanner.v1.IBeginTransactionRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.v1.ITransaction, - protos.google.spanner.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): void; - beginTransaction( - request: protos.google.spanner.v1.IBeginTransactionRequest, - callback: Callback< - protos.google.spanner.v1.ITransaction, - protos.google.spanner.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): void; - beginTransaction( - request?: protos.google.spanner.v1.IBeginTransactionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.v1.ITransaction, - protos.google.spanner.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.v1.ITransaction, - protos.google.spanner.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.v1.ITransaction, - protos.google.spanner.v1.IBeginTransactionRequest|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({ - 'session': request.session ?? '', - }); - this.initialize(); - return this.innerApiCalls.beginTransaction(request, options, callback); - } -/** - * Commits a transaction. The request includes the mutations to be - * applied to rows in the database. - * - * `Commit` might return an `ABORTED` error. This can occur at any time; - * commonly, the cause is conflicts with concurrent - * transactions. However, it can also happen for a variety of other - * reasons. If `Commit` returns `ABORTED`, the caller should re-attempt - * the transaction from the beginning, re-using the same session. - * - * On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, - * for example, if the client job experiences a 1+ hour networking failure. - * At that point, Cloud Spanner has lost track of the transaction outcome and - * we recommend that you perform another read from the database to see the - * state of things as they are now. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.session - * Required. The session in which the transaction to be committed is running. - * @param {Buffer} request.transactionId - * Commit a previously-started transaction. - * @param {google.spanner.v1.TransactionOptions} request.singleUseTransaction - * Execute mutations in a temporary transaction. Note that unlike - * commit of a previously-started transaction, commit with a - * temporary transaction is non-idempotent. That is, if the - * `CommitRequest` is sent to Cloud Spanner more than once (for - * instance, due to retries in the application, or in the - * transport library), it is possible that the mutations are - * executed more than once. If this is undesirable, use - * {@link google.spanner.v1.Spanner.BeginTransaction|BeginTransaction} and - * {@link google.spanner.v1.Spanner.Commit|Commit} instead. - * @param {number[]} request.mutations - * The mutations to be executed when this transaction commits. All - * mutations are applied atomically, in the order they appear in - * this list. - * @param {boolean} request.returnCommitStats - * If `true`, then statistics related to the transaction will be included in - * the {@link google.spanner.v1.CommitResponse.commit_stats|CommitResponse}. Default value is - * `false`. - * @param {google.spanner.v1.RequestOptions} request.requestOptions - * Common options for this request. - * @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 {@link google.spanner.v1.CommitResponse | CommitResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - commit( - request?: protos.google.spanner.v1.ICommitRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.ICommitResponse, - protos.google.spanner.v1.ICommitRequest|undefined, {}|undefined - ]>; - commit( - request: protos.google.spanner.v1.ICommitRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.v1.ICommitResponse, - protos.google.spanner.v1.ICommitRequest|null|undefined, - {}|null|undefined>): void; - commit( - request: protos.google.spanner.v1.ICommitRequest, - callback: Callback< - protos.google.spanner.v1.ICommitResponse, - protos.google.spanner.v1.ICommitRequest|null|undefined, - {}|null|undefined>): void; - commit( - request?: protos.google.spanner.v1.ICommitRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.v1.ICommitResponse, - protos.google.spanner.v1.ICommitRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.v1.ICommitResponse, - protos.google.spanner.v1.ICommitRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.v1.ICommitResponse, - protos.google.spanner.v1.ICommitRequest|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({ - 'session': request.session ?? '', - }); - this.initialize(); - return this.innerApiCalls.commit(request, options, callback); - } -/** - * Rolls back a transaction, releasing any locks it holds. It is a good - * idea to call this for any transaction that includes one or more - * {@link google.spanner.v1.Spanner.Read|Read} or {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql} requests and - * ultimately decides not to commit. - * - * `Rollback` returns `OK` if it successfully aborts the transaction, the - * transaction was already aborted, or the transaction is not - * found. `Rollback` never returns `ABORTED`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.session - * Required. The session in which the transaction to roll back is running. - * @param {Buffer} request.transactionId - * Required. The transaction to roll back. - * @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 {@link google.protobuf.Empty | Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - rollback( - request?: protos.google.spanner.v1.IRollbackRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IRollbackRequest|undefined, {}|undefined - ]>; - rollback( - request: protos.google.spanner.v1.IRollbackRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IRollbackRequest|null|undefined, - {}|null|undefined>): void; - rollback( - request: protos.google.spanner.v1.IRollbackRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IRollbackRequest|null|undefined, - {}|null|undefined>): void; - rollback( - request?: protos.google.spanner.v1.IRollbackRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IRollbackRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IRollbackRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.spanner.v1.IRollbackRequest|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({ - 'session': request.session ?? '', - }); - this.initialize(); - return this.innerApiCalls.rollback(request, options, callback); - } -/** - * Creates a set of partition tokens that can be used to execute a query - * operation in parallel. Each of the returned partition tokens can be used - * by {@link google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} to specify a subset - * of the query result to read. The same session and read-only transaction - * must be used by the PartitionQueryRequest used to create the - * partition tokens and the ExecuteSqlRequests that use the partition tokens. - * - * Partition tokens become invalid when the session used to create them - * is deleted, is idle for too long, begins a new transaction, or becomes too - * old. When any of these happen, it is not possible to resume the query, and - * the whole operation must be restarted from the beginning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.session - * Required. The session used to create the partitions. - * @param {google.spanner.v1.TransactionSelector} request.transaction - * Read only snapshot transactions are supported, read/write and single use - * transactions are not. - * @param {string} request.sql - * Required. The query request to generate partitions for. The request will fail if - * the query is not root partitionable. The query plan of a root - * partitionable query has a single distributed union operator. A distributed - * union operator conceptually divides one or more tables into multiple - * splits, remotely evaluates a subquery independently on each split, and - * then unions all results. - * - * This must not contain DML commands, such as INSERT, UPDATE, or - * DELETE. Use {@link google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} with a - * PartitionedDml transaction for large, partition-friendly DML operations. - * @param {google.protobuf.Struct} request.params - * Parameter names and values that bind to placeholders in the SQL string. - * - * A parameter placeholder consists of the `@` character followed by the - * parameter name (for example, `@firstName`). Parameter names can contain - * letters, numbers, and underscores. - * - * Parameters can appear anywhere that a literal value is expected. The same - * parameter name can be used more than once, for example: - * - * `"WHERE id > @msg_id AND id < @msg_id + 100"` - * - * It is an error to execute a SQL statement with unbound parameters. - * @param {number[]} request.paramTypes - * It is not always possible for Cloud Spanner to infer the right SQL type - * from a JSON value. For example, values of type `BYTES` and values - * of type `STRING` both appear in {@link google.spanner.v1.PartitionQueryRequest.params|params} as JSON strings. - * - * In these cases, `param_types` can be used to specify the exact - * SQL type for some or all of the SQL query parameters. See the - * definition of {@link google.spanner.v1.Type|Type} for more information - * about SQL types. - * @param {google.spanner.v1.PartitionOptions} request.partitionOptions - * Additional options that affect how many partitions are created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.spanner.v1.PartitionResponse | PartitionResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - partitionQuery( - request?: protos.google.spanner.v1.IPartitionQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionQueryRequest|undefined, {}|undefined - ]>; - partitionQuery( - request: protos.google.spanner.v1.IPartitionQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionQueryRequest|null|undefined, - {}|null|undefined>): void; - partitionQuery( - request: protos.google.spanner.v1.IPartitionQueryRequest, - callback: Callback< - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionQueryRequest|null|undefined, - {}|null|undefined>): void; - partitionQuery( - request?: protos.google.spanner.v1.IPartitionQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionQueryRequest|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({ - 'session': request.session ?? '', - }); - this.initialize(); - return this.innerApiCalls.partitionQuery(request, options, callback); - } -/** - * Creates a set of partition tokens that can be used to execute a read - * operation in parallel. Each of the returned partition tokens can be used - * by {@link google.spanner.v1.Spanner.StreamingRead|StreamingRead} to specify a subset of the read - * result to read. The same session and read-only transaction must be used by - * the PartitionReadRequest used to create the partition tokens and the - * ReadRequests that use the partition tokens. There are no ordering - * guarantees on rows returned among the returned partition tokens, or even - * within each individual StreamingRead call issued with a partition_token. - * - * Partition tokens become invalid when the session used to create them - * is deleted, is idle for too long, begins a new transaction, or becomes too - * old. When any of these happen, it is not possible to resume the read, and - * the whole operation must be restarted from the beginning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.session - * Required. The session used to create the partitions. - * @param {google.spanner.v1.TransactionSelector} request.transaction - * Read only snapshot transactions are supported, read/write and single use - * transactions are not. - * @param {string} request.table - * Required. The name of the table in the database to be read. - * @param {string} request.index - * If non-empty, the name of an index on {@link google.spanner.v1.PartitionReadRequest.table|table}. This index is - * used instead of the table primary key when interpreting {@link google.spanner.v1.PartitionReadRequest.key_set|key_set} - * and sorting result rows. See {@link google.spanner.v1.PartitionReadRequest.key_set|key_set} for further information. - * @param {string[]} request.columns - * The columns of {@link google.spanner.v1.PartitionReadRequest.table|table} to be returned for each row matching - * this request. - * @param {google.spanner.v1.KeySet} request.keySet - * Required. `key_set` identifies the rows to be yielded. `key_set` names the - * primary keys of the rows in {@link google.spanner.v1.PartitionReadRequest.table|table} to be yielded, unless {@link google.spanner.v1.PartitionReadRequest.index|index} - * is present. If {@link google.spanner.v1.PartitionReadRequest.index|index} is present, then {@link google.spanner.v1.PartitionReadRequest.key_set|key_set} instead names - * index keys in {@link google.spanner.v1.PartitionReadRequest.index|index}. - * - * It is not an error for the `key_set` to name rows that do not - * exist in the database. Read yields nothing for nonexistent rows. - * @param {google.spanner.v1.PartitionOptions} request.partitionOptions - * Additional options that affect how many partitions are created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.spanner.v1.PartitionResponse | PartitionResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - */ - partitionRead( - request?: protos.google.spanner.v1.IPartitionReadRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionReadRequest|undefined, {}|undefined - ]>; - partitionRead( - request: protos.google.spanner.v1.IPartitionReadRequest, - options: CallOptions, - callback: Callback< - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionReadRequest|null|undefined, - {}|null|undefined>): void; - partitionRead( - request: protos.google.spanner.v1.IPartitionReadRequest, - callback: Callback< - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionReadRequest|null|undefined, - {}|null|undefined>): void; - partitionRead( - request?: protos.google.spanner.v1.IPartitionReadRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionReadRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionReadRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.spanner.v1.IPartitionResponse, - protos.google.spanner.v1.IPartitionReadRequest|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({ - 'session': request.session ?? '', - }); - this.initialize(); - return this.innerApiCalls.partitionRead(request, options, callback); - } - -/** - * Like {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, except returns the result - * set as a stream. Unlike {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, there - * is no limit on the size of the returned result set. However, no - * individual row in the result set can exceed 100 MiB, and no - * column value can exceed 10 MiB. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.session - * Required. The session in which the SQL query should be performed. - * @param {google.spanner.v1.TransactionSelector} request.transaction - * The transaction to use. - * - * For queries, if none is provided, the default is a temporary read-only - * transaction with strong concurrency. - * - * Standard DML statements require a read-write transaction. To protect - * against replays, single-use transactions are not supported. The caller - * must either supply an existing transaction ID or begin a new transaction. - * - * Partitioned DML requires an existing Partitioned DML transaction ID. - * @param {string} request.sql - * Required. The SQL string. - * @param {google.protobuf.Struct} request.params - * Parameter names and values that bind to placeholders in the SQL string. - * - * A parameter placeholder consists of the `@` character followed by the - * parameter name (for example, `@firstName`). Parameter names must conform - * to the naming requirements of identifiers as specified at - * https://cloud.google.com/spanner/docs/lexical#identifiers. - * - * Parameters can appear anywhere that a literal value is expected. The same - * parameter name can be used more than once, for example: - * - * `"WHERE id > @msg_id AND id < @msg_id + 100"` - * - * It is an error to execute a SQL statement with unbound parameters. - * @param {number[]} request.paramTypes - * It is not always possible for Cloud Spanner to infer the right SQL type - * from a JSON value. For example, values of type `BYTES` and values - * of type `STRING` both appear in {@link google.spanner.v1.ExecuteSqlRequest.params|params} as JSON strings. - * - * In these cases, `param_types` can be used to specify the exact - * SQL type for some or all of the SQL statement parameters. See the - * definition of {@link google.spanner.v1.Type|Type} for more information - * about SQL types. - * @param {Buffer} request.resumeToken - * If this request is resuming a previously interrupted SQL statement - * execution, `resume_token` should be copied from the last - * {@link google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the interruption. Doing this - * enables the new SQL statement execution to resume where the last one left - * off. The rest of the request parameters must exactly match the - * request that yielded this token. - * @param {google.spanner.v1.ExecuteSqlRequest.QueryMode} request.queryMode - * Used to control the amount of debugging information returned in - * {@link google.spanner.v1.ResultSetStats|ResultSetStats}. If {@link google.spanner.v1.ExecuteSqlRequest.partition_token|partition_token} is set, {@link google.spanner.v1.ExecuteSqlRequest.query_mode|query_mode} can only - * be set to {@link google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL|QueryMode.NORMAL}. - * @param {Buffer} request.partitionToken - * If present, results will be restricted to the specified partition - * previously created using PartitionQuery(). There must be an exact - * match for the values of fields common to this message and the - * PartitionQueryRequest message used to create this partition_token. - * @param {number} request.seqno - * A per-transaction sequence number used to identify this request. This field - * makes each request idempotent such that if the request is received multiple - * times, at most one will succeed. - * - * The sequence number must be monotonically increasing within the - * transaction. If a request arrives for the first time with an out-of-order - * sequence number, the transaction may be aborted. Replays of previously - * handled requests will yield the same response as the first execution. - * - * Required for DML statements. Ignored for queries. - * @param {google.spanner.v1.ExecuteSqlRequest.QueryOptions} request.queryOptions - * Query optimizer configuration to use for the given query. - * @param {google.spanner.v1.RequestOptions} request.requestOptions - * Common options for this request. - * @param {boolean} request.dataBoostEnabled - * If this is for a partitioned read and this field is set to `true`, the - * request will be executed via Spanner independent compute resources. - * - * If the field is set to `true` but the request does not set - * `partition_token`, the API will return an `INVALID_ARGUMENT` error. - * @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 {@link google.spanner.v1.PartialResultSet | PartialResultSet} on 'data' event. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) - * for more details and examples. - */ - executeStreamingSql( - request?: protos.google.spanner.v1.IExecuteSqlRequest, - options?: CallOptions): - gax.CancellableStream{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'session': request.session ?? '', - }); - this.initialize(); - return this.innerApiCalls.executeStreamingSql(request, options); - } - -/** - * Like {@link google.spanner.v1.Spanner.Read|Read}, except returns the result set as a - * stream. Unlike {@link google.spanner.v1.Spanner.Read|Read}, there is no limit on the - * size of the returned result set. However, no individual row in - * the result set can exceed 100 MiB, and no column value can exceed - * 10 MiB. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.session - * Required. The session in which the read should be performed. - * @param {google.spanner.v1.TransactionSelector} request.transaction - * The transaction to use. If none is provided, the default is a - * temporary read-only transaction with strong concurrency. - * @param {string} request.table - * Required. The name of the table in the database to be read. - * @param {string} request.index - * If non-empty, the name of an index on {@link google.spanner.v1.ReadRequest.table|table}. This index is - * used instead of the table primary key when interpreting {@link google.spanner.v1.ReadRequest.key_set|key_set} - * and sorting result rows. See {@link google.spanner.v1.ReadRequest.key_set|key_set} for further information. - * @param {string[]} request.columns - * Required. The columns of {@link google.spanner.v1.ReadRequest.table|table} to be returned for each row matching - * this request. - * @param {google.spanner.v1.KeySet} request.keySet - * Required. `key_set` identifies the rows to be yielded. `key_set` names the - * primary keys of the rows in {@link google.spanner.v1.ReadRequest.table|table} to be yielded, unless {@link google.spanner.v1.ReadRequest.index|index} - * is present. If {@link google.spanner.v1.ReadRequest.index|index} is present, then {@link google.spanner.v1.ReadRequest.key_set|key_set} instead names - * index keys in {@link google.spanner.v1.ReadRequest.index|index}. - * - * If the {@link google.spanner.v1.ReadRequest.partition_token|partition_token} field is empty, rows are yielded - * in table primary key order (if {@link google.spanner.v1.ReadRequest.index|index} is empty) or index key order - * (if {@link google.spanner.v1.ReadRequest.index|index} is non-empty). If the {@link google.spanner.v1.ReadRequest.partition_token|partition_token} field is not - * empty, rows will be yielded in an unspecified order. - * - * It is not an error for the `key_set` to name rows that do not - * exist in the database. Read yields nothing for nonexistent rows. - * @param {number} request.limit - * If greater than zero, only the first `limit` rows are yielded. If `limit` - * is zero, the default is no limit. A limit cannot be specified if - * `partition_token` is set. - * @param {Buffer} request.resumeToken - * If this request is resuming a previously interrupted read, - * `resume_token` should be copied from the last - * {@link google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the interruption. Doing this - * enables the new read to resume where the last read left off. The - * rest of the request parameters must exactly match the request - * that yielded this token. - * @param {Buffer} request.partitionToken - * If present, results will be restricted to the specified partition - * previously created using PartitionRead(). There must be an exact - * match for the values of fields common to this message and the - * PartitionReadRequest message used to create this partition_token. - * @param {google.spanner.v1.RequestOptions} request.requestOptions - * Common options for this request. - * @param {boolean} request.dataBoostEnabled - * If this is for a partitioned query and this field is set to `true`, the - * request will be executed via Spanner independent compute resources. - * - * If the field is set to `true` but the request does not set - * `partition_token`, the API will return an `INVALID_ARGUMENT` error. - * @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 {@link google.spanner.v1.PartialResultSet | PartialResultSet} on 'data' event. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) - * for more details and examples. - */ - streamingRead( - request?: protos.google.spanner.v1.IReadRequest, - options?: CallOptions): - gax.CancellableStream{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'session': request.session ?? '', - }); - this.initialize(); - return this.innerApiCalls.streamingRead(request, options); - } - - /** - * Lists all sessions in a given database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database in which to list sessions. - * @param {number} request.pageSize - * Number of sessions to be returned in the response. If 0 or less, defaults - * to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token} from a previous - * {@link google.spanner.v1.ListSessionsResponse|ListSessionsResponse}. - * @param {string} request.filter - * An expression for filtering the results of the request. Filter rules are - * case insensitive. The fields eligible for filtering are: - * - * * `labels.key` where key is the name of a label - * - * Some examples of using filters are: - * - * * `labels.env:*` --> The session has the label "env". - * * `labels.env:dev` --> The session has the label "env" and the value of - * the label contains the string "dev". - * @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 {@link google.spanner.v1.Session | Session}. - * 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 `listSessionsAsync()` - * 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. - */ - listSessions( - request?: protos.google.spanner.v1.IListSessionsRequest, - options?: CallOptions): - Promise<[ - protos.google.spanner.v1.ISession[], - protos.google.spanner.v1.IListSessionsRequest|null, - protos.google.spanner.v1.IListSessionsResponse - ]>; - listSessions( - request: protos.google.spanner.v1.IListSessionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.spanner.v1.IListSessionsRequest, - protos.google.spanner.v1.IListSessionsResponse|null|undefined, - protos.google.spanner.v1.ISession>): void; - listSessions( - request: protos.google.spanner.v1.IListSessionsRequest, - callback: PaginationCallback< - protos.google.spanner.v1.IListSessionsRequest, - protos.google.spanner.v1.IListSessionsResponse|null|undefined, - protos.google.spanner.v1.ISession>): void; - listSessions( - request?: protos.google.spanner.v1.IListSessionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.spanner.v1.IListSessionsRequest, - protos.google.spanner.v1.IListSessionsResponse|null|undefined, - protos.google.spanner.v1.ISession>, - callback?: PaginationCallback< - protos.google.spanner.v1.IListSessionsRequest, - protos.google.spanner.v1.IListSessionsResponse|null|undefined, - protos.google.spanner.v1.ISession>): - Promise<[ - protos.google.spanner.v1.ISession[], - protos.google.spanner.v1.IListSessionsRequest|null, - protos.google.spanner.v1.IListSessionsResponse - ]>|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({ - 'database': request.database ?? '', - }); - this.initialize(); - return this.innerApiCalls.listSessions(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.database - * Required. The database in which to list sessions. - * @param {number} request.pageSize - * Number of sessions to be returned in the response. If 0 or less, defaults - * to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token} from a previous - * {@link google.spanner.v1.ListSessionsResponse|ListSessionsResponse}. - * @param {string} request.filter - * An expression for filtering the results of the request. Filter rules are - * case insensitive. The fields eligible for filtering are: - * - * * `labels.key` where key is the name of a label - * - * Some examples of using filters are: - * - * * `labels.env:*` --> The session has the label "env". - * * `labels.env:dev` --> The session has the label "env" and the value of - * the label contains the string "dev". - * @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 {@link google.spanner.v1.Session | Session} 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 `listSessionsAsync()` - * 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. - */ - listSessionsStream( - request?: protos.google.spanner.v1.IListSessionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'database': request.database ?? '', - }); - const defaultCallSettings = this._defaults['listSessions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSessions.createStream( - this.innerApiCalls.listSessions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listSessions`, 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.database - * Required. The database in which to list sessions. - * @param {number} request.pageSize - * Number of sessions to be returned in the response. If 0 or less, defaults - * to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token} from a previous - * {@link google.spanner.v1.ListSessionsResponse|ListSessionsResponse}. - * @param {string} request.filter - * An expression for filtering the results of the request. Filter rules are - * case insensitive. The fields eligible for filtering are: - * - * * `labels.key` where key is the name of a label - * - * Some examples of using filters are: - * - * * `labels.env:*` --> The session has the label "env". - * * `labels.env:dev` --> The session has the label "env" and the value of - * the label contains the string "dev". - * @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 - * {@link google.spanner.v1.Session | Session}. 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. - */ - listSessionsAsync( - request?: protos.google.spanner.v1.IListSessionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'database': request.database ?? '', - }); - const defaultCallSettings = this._defaults['listSessions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSessions.asyncIterate( - this.innerApiCalls['listSessions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified database resource name string. - * - * @param {string} project - * @param {string} instance - * @param {string} database - * @returns {string} Resource name string. - */ - databasePath(project:string,instance:string,database:string) { - return this.pathTemplates.databasePathTemplate.render({ - project: project, - instance: instance, - database: database, - }); - } - - /** - * Parse the project from Database resource. - * - * @param {string} databaseName - * A fully-qualified path representing Database resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDatabaseName(databaseName: string) { - return this.pathTemplates.databasePathTemplate.match(databaseName).project; - } - - /** - * Parse the instance from Database resource. - * - * @param {string} databaseName - * A fully-qualified path representing Database resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromDatabaseName(databaseName: string) { - return this.pathTemplates.databasePathTemplate.match(databaseName).instance; - } - - /** - * Parse the database from Database resource. - * - * @param {string} databaseName - * A fully-qualified path representing Database resource. - * @returns {string} A string representing the database. - */ - matchDatabaseFromDatabaseName(databaseName: string) { - return this.pathTemplates.databasePathTemplate.match(databaseName).database; - } - - /** - * Return a fully-qualified session resource name string. - * - * @param {string} project - * @param {string} instance - * @param {string} database - * @param {string} session - * @returns {string} Resource name string. - */ - sessionPath(project:string,instance:string,database:string,session:string) { - return this.pathTemplates.sessionPathTemplate.render({ - project: project, - instance: instance, - database: database, - session: session, - }); - } - - /** - * Parse the project from Session resource. - * - * @param {string} sessionName - * A fully-qualified path representing Session resource. - * @returns {string} A string representing the project. - */ - matchProjectFromSessionName(sessionName: string) { - return this.pathTemplates.sessionPathTemplate.match(sessionName).project; - } - - /** - * Parse the instance from Session resource. - * - * @param {string} sessionName - * A fully-qualified path representing Session resource. - * @returns {string} A string representing the instance. - */ - matchInstanceFromSessionName(sessionName: string) { - return this.pathTemplates.sessionPathTemplate.match(sessionName).instance; - } - - /** - * Parse the database from Session resource. - * - * @param {string} sessionName - * A fully-qualified path representing Session resource. - * @returns {string} A string representing the database. - */ - matchDatabaseFromSessionName(sessionName: string) { - return this.pathTemplates.sessionPathTemplate.match(sessionName).database; - } - - /** - * Parse the session from Session resource. - * - * @param {string} sessionName - * A fully-qualified path representing Session resource. - * @returns {string} A string representing the session. - */ - matchSessionFromSessionName(sessionName: string) { - return this.pathTemplates.sessionPathTemplate.match(sessionName).session; - } - - /** - * 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.spannerStub && !this._terminated) { - return this.spannerStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/spanner_client_config.json b/owl-bot-staging/v1/src/v1/spanner_client_config.json deleted file mode 100644 index d14bef0e6..000000000 --- a/owl-bot-staging/v1/src/v1/spanner_client_config.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "interfaces": { - "google.spanner.v1.Spanner": { - "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 - }, - "9442ca297df43f7314712e1a19d003838e738a45": { - "initial_retry_delay_millis": 250, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 32000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateSession": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "BatchCreateSessions": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "GetSession": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "ListSessions": { - "timeout_millis": 3600000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "DeleteSession": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "ExecuteSql": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "ExecuteStreamingSql": { - "timeout_millis": 3600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ExecuteBatchDml": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "Read": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "StreamingRead": { - "timeout_millis": 3600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "BeginTransaction": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "Commit": { - "timeout_millis": 3600000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "Rollback": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "PartitionQuery": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - }, - "PartitionRead": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "9442ca297df43f7314712e1a19d003838e738a45" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/spanner_proto_list.json b/owl-bot-staging/v1/src/v1/spanner_proto_list.json deleted file mode 100644 index de809666e..000000000 --- a/owl-bot-staging/v1/src/v1/spanner_proto_list.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - "../../protos/google/spanner/v1/commit_response.proto", - "../../protos/google/spanner/v1/keys.proto", - "../../protos/google/spanner/v1/mutation.proto", - "../../protos/google/spanner/v1/query_plan.proto", - "../../protos/google/spanner/v1/result_set.proto", - "../../protos/google/spanner/v1/spanner.proto", - "../../protos/google/spanner/v1/transaction.proto", - "../../protos/google/spanner/v1/type.proto" -] diff --git a/owl-bot-staging/v1/test/gapic_spanner_v1.ts b/owl-bot-staging/v1/test/gapic_spanner_v1.ts deleted file mode 100644 index 2fa52bce8..000000000 --- a/owl-bot-staging/v1/test/gapic_spanner_v1.ts +++ /dev/null @@ -1,2047 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 spannerModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -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 stubServerStreamingCall(response?: ResponseType, error?: Error) { - const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // write something to the stream to trigger transformStub and send the response back to the client - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - return sinon.stub().returns(mockStream); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.SpannerClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = spannerModule.v1.SpannerClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = spannerModule.v1.SpannerClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = spannerModule.v1.SpannerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new spannerModule.v1.SpannerClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new spannerModule.v1.SpannerClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.spannerStub, undefined); - await client.initialize(); - assert(client.spannerStub); - }); - - it('has close method for the initialized client', done => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.spannerStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.spannerStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new spannerModule.v1.SpannerClient({ - 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 spannerModule.v1.SpannerClient({ - 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('createSession', () => { - it('invokes createSession without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.CreateSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.CreateSessionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.Session() - ); - client.innerApiCalls.createSession = stubSimpleCall(expectedResponse); - const [response] = await client.createSession(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSession without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.CreateSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.CreateSessionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.Session() - ); - client.innerApiCalls.createSession = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSession( - request, - (err?: Error|null, result?: protos.google.spanner.v1.ISession|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSession with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.CreateSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.CreateSessionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSession = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createSession(request), expectedError); - const actualRequest = (client.innerApiCalls.createSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSession with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.CreateSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.CreateSessionRequest', ['database']); - request.database = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createSession(request), expectedError); - }); - }); - - describe('batchCreateSessions', () => { - it('invokes batchCreateSessions without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.BatchCreateSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.BatchCreateSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.BatchCreateSessionsResponse() - ); - client.innerApiCalls.batchCreateSessions = stubSimpleCall(expectedResponse); - const [response] = await client.batchCreateSessions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchCreateSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchCreateSessions without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.BatchCreateSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.BatchCreateSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.BatchCreateSessionsResponse() - ); - client.innerApiCalls.batchCreateSessions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchCreateSessions( - request, - (err?: Error|null, result?: protos.google.spanner.v1.IBatchCreateSessionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchCreateSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchCreateSessions with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.BatchCreateSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.BatchCreateSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchCreateSessions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchCreateSessions(request), expectedError); - const actualRequest = (client.innerApiCalls.batchCreateSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchCreateSessions with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.BatchCreateSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.BatchCreateSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchCreateSessions(request), expectedError); - }); - }); - - describe('getSession', () => { - it('invokes getSession without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.GetSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.GetSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.Session() - ); - client.innerApiCalls.getSession = stubSimpleCall(expectedResponse); - const [response] = await client.getSession(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSession without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.GetSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.GetSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.Session() - ); - client.innerApiCalls.getSession = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSession( - request, - (err?: Error|null, result?: protos.google.spanner.v1.ISession|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSession with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.GetSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.GetSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSession = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSession(request), expectedError); - const actualRequest = (client.innerApiCalls.getSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSession with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.GetSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.GetSessionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getSession(request), expectedError); - }); - }); - - describe('deleteSession', () => { - it('invokes deleteSession without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.DeleteSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.DeleteSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSession = stubSimpleCall(expectedResponse); - const [response] = await client.deleteSession(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSession without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.DeleteSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.DeleteSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSession = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSession( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSession with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.DeleteSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.DeleteSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSession = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteSession(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSession with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.DeleteSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.DeleteSessionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteSession(request), expectedError); - }); - }); - - describe('executeSql', () => { - it('invokes executeSql without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.ResultSet() - ); - client.innerApiCalls.executeSql = stubSimpleCall(expectedResponse); - const [response] = await client.executeSql(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeSql without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.ResultSet() - ); - client.innerApiCalls.executeSql = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeSql( - request, - (err?: Error|null, result?: protos.google.spanner.v1.IResultSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeSql with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeSql = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executeSql(request), expectedError); - const actualRequest = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeSql with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); - request.session = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.executeSql(request), expectedError); - }); - }); - - describe('executeBatchDml', () => { - it('invokes executeBatchDml without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteBatchDmlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteBatchDmlRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.ExecuteBatchDmlResponse() - ); - client.innerApiCalls.executeBatchDml = stubSimpleCall(expectedResponse); - const [response] = await client.executeBatchDml(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeBatchDml as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeBatchDml as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeBatchDml without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteBatchDmlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteBatchDmlRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.ExecuteBatchDmlResponse() - ); - client.innerApiCalls.executeBatchDml = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeBatchDml( - request, - (err?: Error|null, result?: protos.google.spanner.v1.IExecuteBatchDmlResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeBatchDml as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeBatchDml as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeBatchDml with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteBatchDmlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteBatchDmlRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeBatchDml = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executeBatchDml(request), expectedError); - const actualRequest = (client.innerApiCalls.executeBatchDml as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeBatchDml as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeBatchDml with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteBatchDmlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteBatchDmlRequest', ['session']); - request.session = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.executeBatchDml(request), expectedError); - }); - }); - - describe('read', () => { - it('invokes read without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.ResultSet() - ); - client.innerApiCalls.read = stubSimpleCall(expectedResponse); - const [response] = await client.read(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.read as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.read as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes read without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.ResultSet() - ); - client.innerApiCalls.read = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.read( - request, - (err?: Error|null, result?: protos.google.spanner.v1.IResultSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.read as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.read as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes read with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.read = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.read(request), expectedError); - const actualRequest = (client.innerApiCalls.read as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.read as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes read with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); - request.session = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.read(request), expectedError); - }); - }); - - describe('beginTransaction', () => { - it('invokes beginTransaction without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.BeginTransactionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.BeginTransactionRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.Transaction() - ); - client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); - const [response] = await client.beginTransaction(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes beginTransaction without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.BeginTransactionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.BeginTransactionRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.Transaction() - ); - client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.beginTransaction( - request, - (err?: Error|null, result?: protos.google.spanner.v1.ITransaction|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes beginTransaction with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.BeginTransactionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.BeginTransactionRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.beginTransaction(request), expectedError); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes beginTransaction with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.BeginTransactionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.BeginTransactionRequest', ['session']); - request.session = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.beginTransaction(request), expectedError); - }); - }); - - describe('commit', () => { - it('invokes commit without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.CommitRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.CommitRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.CommitResponse() - ); - client.innerApiCalls.commit = stubSimpleCall(expectedResponse); - const [response] = await client.commit(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes commit without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.CommitRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.CommitRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.CommitResponse() - ); - client.innerApiCalls.commit = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.commit( - request, - (err?: Error|null, result?: protos.google.spanner.v1.ICommitResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes commit with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.CommitRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.CommitRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.commit(request), expectedError); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes commit with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.CommitRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.CommitRequest', ['session']); - request.session = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.commit(request), expectedError); - }); - }); - - describe('rollback', () => { - it('invokes rollback without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.RollbackRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.RollbackRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); - const [response] = await client.rollback(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rollback without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.RollbackRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.RollbackRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.rollback = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rollback( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rollback with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.RollbackRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.RollbackRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rollback(request), expectedError); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rollback with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.RollbackRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.RollbackRequest', ['session']); - request.session = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.rollback(request), expectedError); - }); - }); - - describe('partitionQuery', () => { - it('invokes partitionQuery without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.PartitionQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.PartitionQueryRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.PartitionResponse() - ); - client.innerApiCalls.partitionQuery = stubSimpleCall(expectedResponse); - const [response] = await client.partitionQuery(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes partitionQuery without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.PartitionQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.PartitionQueryRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.PartitionResponse() - ); - client.innerApiCalls.partitionQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.partitionQuery( - request, - (err?: Error|null, result?: protos.google.spanner.v1.IPartitionResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes partitionQuery with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.PartitionQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.PartitionQueryRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.partitionQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes partitionQuery with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.PartitionQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.PartitionQueryRequest', ['session']); - request.session = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.partitionQuery(request), expectedError); - }); - }); - - describe('partitionRead', () => { - it('invokes partitionRead without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.PartitionReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.PartitionReadRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.PartitionResponse() - ); - client.innerApiCalls.partitionRead = stubSimpleCall(expectedResponse); - const [response] = await client.partitionRead(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.partitionRead as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionRead as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes partitionRead without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.PartitionReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.PartitionReadRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.PartitionResponse() - ); - client.innerApiCalls.partitionRead = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.partitionRead( - request, - (err?: Error|null, result?: protos.google.spanner.v1.IPartitionResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.partitionRead as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionRead as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes partitionRead with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.PartitionReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.PartitionReadRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.partitionRead = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.partitionRead(request), expectedError); - const actualRequest = (client.innerApiCalls.partitionRead as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionRead as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes partitionRead with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.PartitionReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.PartitionReadRequest', ['session']); - request.session = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.partitionRead(request), expectedError); - }); - }); - - describe('executeStreamingSql', () => { - it('invokes executeStreamingSql without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.PartialResultSet() - ); - client.innerApiCalls.executeStreamingSql = stubServerStreamingCall(expectedResponse); - const stream = client.executeStreamingSql(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeStreamingSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeStreamingSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeStreamingSql with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeStreamingSql = stubServerStreamingCall(undefined, expectedError); - const stream = client.executeStreamingSql(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - const actualRequest = (client.innerApiCalls.executeStreamingSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeStreamingSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeStreamingSql with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ExecuteSqlRequest', ['session']); - request.session = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.executeStreamingSql(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - }); - }); - - describe('streamingRead', () => { - it('invokes streamingRead without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.spanner.v1.PartialResultSet() - ); - client.innerApiCalls.streamingRead = stubServerStreamingCall(expectedResponse); - const stream = client.streamingRead(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.streamingRead as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.streamingRead as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes streamingRead with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); - request.session = defaultValue1; - const expectedHeaderRequestParams = `session=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.streamingRead = stubServerStreamingCall(undefined, expectedError); - const stream = client.streamingRead(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - const actualRequest = (client.innerApiCalls.streamingRead as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.streamingRead as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes streamingRead with closed client', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ReadRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ReadRequest', ['session']); - request.session = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.streamingRead(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.spanner.v1.PartialResultSet) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - }); - }); - - describe('listSessions', () => { - it('invokes listSessions without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ListSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.v1.Session()), - generateSampleMessage(new protos.google.spanner.v1.Session()), - generateSampleMessage(new protos.google.spanner.v1.Session()), - ]; - client.innerApiCalls.listSessions = stubSimpleCall(expectedResponse); - const [response] = await client.listSessions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSessions without error using callback', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ListSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.v1.Session()), - generateSampleMessage(new protos.google.spanner.v1.Session()), - generateSampleMessage(new protos.google.spanner.v1.Session()), - ]; - client.innerApiCalls.listSessions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSessions( - request, - (err?: Error|null, result?: protos.google.spanner.v1.ISession[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSessions with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ListSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSessions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSessions(request), expectedError); - const actualRequest = (client.innerApiCalls.listSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSessionsStream without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ListSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.v1.Session()), - generateSampleMessage(new protos.google.spanner.v1.Session()), - generateSampleMessage(new protos.google.spanner.v1.Session()), - ]; - client.descriptors.page.listSessions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSessionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.v1.Session[] = []; - stream.on('data', (response: protos.google.spanner.v1.Session) => { - 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.listSessions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSessions, request)); - assert( - (client.descriptors.page.listSessions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listSessionsStream with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ListSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSessions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSessionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.spanner.v1.Session[] = []; - stream.on('data', (response: protos.google.spanner.v1.Session) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSessions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSessions, request)); - assert( - (client.descriptors.page.listSessions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSessions without error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ListSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.spanner.v1.Session()), - generateSampleMessage(new protos.google.spanner.v1.Session()), - generateSampleMessage(new protos.google.spanner.v1.Session()), - ]; - client.descriptors.page.listSessions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.spanner.v1.ISession[] = []; - const iterable = client.listSessionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSessions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSessions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSessions with error', async () => { - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.spanner.v1.ListSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.spanner.v1.ListSessionsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSessions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSessionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.spanner.v1.ISession[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSessions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSessions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('database', () => { - const fakePath = "/rendered/path/database"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - database: "databaseValue", - }; - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.databasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.databasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('databasePath', () => { - const result = client.databasePath("projectValue", "instanceValue", "databaseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.databasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDatabaseName', () => { - const result = client.matchProjectFromDatabaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromDatabaseName', () => { - const result = client.matchInstanceFromDatabaseName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatabaseFromDatabaseName', () => { - const result = client.matchDatabaseFromDatabaseName(fakePath); - assert.strictEqual(result, "databaseValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('session', () => { - const fakePath = "/rendered/path/session"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - database: "databaseValue", - session: "sessionValue", - }; - const client = new spannerModule.v1.SpannerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.sessionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.sessionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('sessionPath', () => { - const result = client.sessionPath("projectValue", "instanceValue", "databaseValue", "sessionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.sessionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSessionName', () => { - const result = client.matchProjectFromSessionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.sessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromSessionName', () => { - const result = client.matchInstanceFromSessionName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.sessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatabaseFromSessionName', () => { - const result = client.matchDatabaseFromSessionName(fakePath); - assert.strictEqual(result, "databaseValue"); - assert((client.pathTemplates.sessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSessionFromSessionName', () => { - const result = client.matchSessionFromSessionName(fakePath); - assert.strictEqual(result, "sessionValue"); - assert((client.pathTemplates.sessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index ee59a7326..000000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'spanner', - filename: './spanner.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/protos/google/spanner/v1/spanner.proto b/protos/google/spanner/v1/spanner.proto index ef772170b..77a1f0e47 100644 --- a/protos/google/spanner/v1/spanner.proto +++ b/protos/google/spanner/v1/spanner.proto @@ -643,6 +643,13 @@ message ExecuteSqlRequest { // Common options for this request. RequestOptions request_options = 11; + + // If this is for a partitioned read and this field is set to `true`, the + // request will be executed via Spanner independent compute resources. + // + // If the field is set to `true` but the request does not set + // `partition_token`, the API will return an `INVALID_ARGUMENT` error. + bool data_boost_enabled = 15; } // The request for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. @@ -949,6 +956,13 @@ message ReadRequest { // Common options for this request. RequestOptions request_options = 11; + + // If this is for a partitioned query and this field is set to `true`, the + // request will be executed via Spanner independent compute resources. + // + // If the field is set to `true` but the request does not set + // `partition_token`, the API will return an `INVALID_ARGUMENT` error. + bool data_boost_enabled = 16; } // The request for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction]. diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 91552afe3..b7fd19956 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -17400,6 +17400,9 @@ export namespace google { /** ExecuteSqlRequest requestOptions */ requestOptions?: (google.spanner.v1.IRequestOptions|null); + + /** ExecuteSqlRequest dataBoostEnabled */ + dataBoostEnabled?: (boolean|null); } /** Represents an ExecuteSqlRequest. */ @@ -17444,6 +17447,9 @@ export namespace google { /** ExecuteSqlRequest requestOptions. */ public requestOptions?: (google.spanner.v1.IRequestOptions|null); + /** ExecuteSqlRequest dataBoostEnabled. */ + public dataBoostEnabled: boolean; + /** * Creates a new ExecuteSqlRequest instance using the specified properties. * @param [properties] Properties to set @@ -18566,6 +18572,9 @@ export namespace google { /** ReadRequest requestOptions */ requestOptions?: (google.spanner.v1.IRequestOptions|null); + + /** ReadRequest dataBoostEnabled */ + dataBoostEnabled?: (boolean|null); } /** Represents a ReadRequest. */ @@ -18607,6 +18616,9 @@ export namespace google { /** ReadRequest requestOptions. */ public requestOptions?: (google.spanner.v1.IRequestOptions|null); + /** ReadRequest dataBoostEnabled. */ + public dataBoostEnabled: boolean; + /** * Creates a new ReadRequest instance using the specified properties. * @param [properties] Properties to set diff --git a/protos/protos.js b/protos/protos.js index ad74f311f..1bfa52a63 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -42925,6 +42925,7 @@ * @property {number|Long|null} [seqno] ExecuteSqlRequest seqno * @property {google.spanner.v1.ExecuteSqlRequest.IQueryOptions|null} [queryOptions] ExecuteSqlRequest queryOptions * @property {google.spanner.v1.IRequestOptions|null} [requestOptions] ExecuteSqlRequest requestOptions + * @property {boolean|null} [dataBoostEnabled] ExecuteSqlRequest dataBoostEnabled */ /** @@ -43031,6 +43032,14 @@ */ ExecuteSqlRequest.prototype.requestOptions = null; + /** + * ExecuteSqlRequest dataBoostEnabled. + * @member {boolean} dataBoostEnabled + * @memberof google.spanner.v1.ExecuteSqlRequest + * @instance + */ + ExecuteSqlRequest.prototype.dataBoostEnabled = false; + /** * Creates a new ExecuteSqlRequest instance using the specified properties. * @function create @@ -43080,6 +43089,8 @@ $root.google.spanner.v1.ExecuteSqlRequest.QueryOptions.encode(message.queryOptions, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); if (message.requestOptions != null && Object.hasOwnProperty.call(message, "requestOptions")) $root.google.spanner.v1.RequestOptions.encode(message.requestOptions, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.dataBoostEnabled != null && Object.hasOwnProperty.call(message, "dataBoostEnabled")) + writer.uint32(/* id 15, wireType 0 =*/120).bool(message.dataBoostEnabled); return writer; }; @@ -43177,6 +43188,10 @@ message.requestOptions = $root.google.spanner.v1.RequestOptions.decode(reader, reader.uint32()); break; } + case 15: { + message.dataBoostEnabled = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -43266,6 +43281,9 @@ if (error) return "requestOptions." + error; } + if (message.dataBoostEnabled != null && message.hasOwnProperty("dataBoostEnabled")) + if (typeof message.dataBoostEnabled !== "boolean") + return "dataBoostEnabled: boolean expected"; return null; }; @@ -43354,6 +43372,8 @@ throw TypeError(".google.spanner.v1.ExecuteSqlRequest.requestOptions: object expected"); message.requestOptions = $root.google.spanner.v1.RequestOptions.fromObject(object.requestOptions); } + if (object.dataBoostEnabled != null) + message.dataBoostEnabled = Boolean(object.dataBoostEnabled); return message; }; @@ -43399,6 +43419,7 @@ object.seqno = options.longs === String ? "0" : 0; object.queryOptions = null; object.requestOptions = null; + object.dataBoostEnabled = false; } if (message.session != null && message.hasOwnProperty("session")) object.session = message.session; @@ -43429,6 +43450,8 @@ object.queryOptions = $root.google.spanner.v1.ExecuteSqlRequest.QueryOptions.toObject(message.queryOptions, options); if (message.requestOptions != null && message.hasOwnProperty("requestOptions")) object.requestOptions = $root.google.spanner.v1.RequestOptions.toObject(message.requestOptions, options); + if (message.dataBoostEnabled != null && message.hasOwnProperty("dataBoostEnabled")) + object.dataBoostEnabled = message.dataBoostEnabled; return object; }; @@ -46084,6 +46107,7 @@ * @property {Uint8Array|null} [resumeToken] ReadRequest resumeToken * @property {Uint8Array|null} [partitionToken] ReadRequest partitionToken * @property {google.spanner.v1.IRequestOptions|null} [requestOptions] ReadRequest requestOptions + * @property {boolean|null} [dataBoostEnabled] ReadRequest dataBoostEnabled */ /** @@ -46182,6 +46206,14 @@ */ ReadRequest.prototype.requestOptions = null; + /** + * ReadRequest dataBoostEnabled. + * @member {boolean} dataBoostEnabled + * @memberof google.spanner.v1.ReadRequest + * @instance + */ + ReadRequest.prototype.dataBoostEnabled = false; + /** * Creates a new ReadRequest instance using the specified properties. * @function create @@ -46227,6 +46259,8 @@ writer.uint32(/* id 10, wireType 2 =*/82).bytes(message.partitionToken); if (message.requestOptions != null && Object.hasOwnProperty.call(message, "requestOptions")) $root.google.spanner.v1.RequestOptions.encode(message.requestOptions, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.dataBoostEnabled != null && Object.hasOwnProperty.call(message, "dataBoostEnabled")) + writer.uint32(/* id 16, wireType 0 =*/128).bool(message.dataBoostEnabled); return writer; }; @@ -46303,6 +46337,10 @@ message.requestOptions = $root.google.spanner.v1.RequestOptions.decode(reader, reader.uint32()); break; } + case 16: { + message.dataBoostEnabled = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -46378,6 +46416,9 @@ if (error) return "requestOptions." + error; } + if (message.dataBoostEnabled != null && message.hasOwnProperty("dataBoostEnabled")) + if (typeof message.dataBoostEnabled !== "boolean") + return "dataBoostEnabled: boolean expected"; return null; }; @@ -46440,6 +46481,8 @@ throw TypeError(".google.spanner.v1.ReadRequest.requestOptions: object expected"); message.requestOptions = $root.google.spanner.v1.RequestOptions.fromObject(object.requestOptions); } + if (object.dataBoostEnabled != null) + message.dataBoostEnabled = Boolean(object.dataBoostEnabled); return message; }; @@ -46484,6 +46527,7 @@ object.partitionToken = $util.newBuffer(object.partitionToken); } object.requestOptions = null; + object.dataBoostEnabled = false; } if (message.session != null && message.hasOwnProperty("session")) object.session = message.session; @@ -46511,6 +46555,8 @@ object.partitionToken = options.bytes === String ? $util.base64.encode(message.partitionToken, 0, message.partitionToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.partitionToken) : message.partitionToken; if (message.requestOptions != null && message.hasOwnProperty("requestOptions")) object.requestOptions = $root.google.spanner.v1.RequestOptions.toObject(message.requestOptions, options); + if (message.dataBoostEnabled != null && message.hasOwnProperty("dataBoostEnabled")) + object.dataBoostEnabled = message.dataBoostEnabled; return object; }; diff --git a/protos/protos.json b/protos/protos.json index 9fc57be4b..667d6ecd9 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -4604,6 +4604,10 @@ "requestOptions": { "type": "RequestOptions", "id": 11 + }, + "dataBoostEnabled": { + "type": "bool", + "id": 15 } }, "nested": { @@ -4868,6 +4872,10 @@ "requestOptions": { "type": "RequestOptions", "id": 11 + }, + "dataBoostEnabled": { + "type": "bool", + "id": 16 } } }, diff --git a/src/v1/spanner_client.ts b/src/v1/spanner_client.ts index 3b47a41e6..4f13e606b 100644 --- a/src/v1/spanner_client.ts +++ b/src/v1/spanner_client.ts @@ -824,6 +824,12 @@ export class SpannerClient { * Query optimizer configuration to use for the given query. * @param {google.spanner.v1.RequestOptions} request.requestOptions * Common options for this request. + * @param {boolean} request.dataBoostEnabled + * If this is for a partitioned read and this field is set to `true`, the + * request will be executed via Spanner independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API will return an `INVALID_ARGUMENT` error. * @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. @@ -1075,6 +1081,12 @@ export class SpannerClient { * PartitionReadRequest message used to create this partition_token. * @param {google.spanner.v1.RequestOptions} request.requestOptions * Common options for this request. + * @param {boolean} request.dataBoostEnabled + * If this is for a partitioned query and this field is set to `true`, the + * request will be executed via Spanner independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API will return an `INVALID_ARGUMENT` error. * @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. @@ -1770,6 +1782,12 @@ export class SpannerClient { * Query optimizer configuration to use for the given query. * @param {google.spanner.v1.RequestOptions} request.requestOptions * Common options for this request. + * @param {boolean} request.dataBoostEnabled + * If this is for a partitioned read and this field is set to `true`, the + * request will be executed via Spanner independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API will return an `INVALID_ARGUMENT` error. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1848,6 +1866,12 @@ export class SpannerClient { * PartitionReadRequest message used to create this partition_token. * @param {google.spanner.v1.RequestOptions} request.requestOptions * Common options for this request. + * @param {boolean} request.dataBoostEnabled + * If this is for a partitioned query and this field is set to `true`, the + * request will be executed via Spanner independent compute resources. + * + * If the field is set to `true` but the request does not set + * `partition_token`, the API will return an `INVALID_ARGUMENT` error. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream}