@google-cloud/spanner 7.18.0 → 7.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -0
  3. package/build/protos/google/spanner/admin/database/v1/backup.proto +757 -0
  4. package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +230 -0
  5. package/build/protos/google/spanner/admin/database/v1/common.proto +132 -0
  6. package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +1209 -0
  7. package/build/protos/google/spanner/admin/instance/v1/common.proto +64 -0
  8. package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +2110 -0
  9. package/build/protos/google/spanner/executor/v1/cloud_executor.proto +1520 -0
  10. package/build/protos/google/spanner/v1/commit_response.proto +59 -0
  11. package/build/protos/google/spanner/v1/keys.proto +163 -0
  12. package/build/protos/google/spanner/v1/mutation.proto +107 -0
  13. package/build/protos/google/spanner/v1/query_plan.proto +128 -0
  14. package/build/protos/google/spanner/v1/result_set.proto +237 -0
  15. package/build/protos/google/spanner/v1/spanner.proto +1389 -0
  16. package/build/protos/google/spanner/v1/transaction.proto +575 -0
  17. package/build/protos/google/spanner/v1/type.proto +214 -0
  18. package/build/protos/protos.d.ts +39317 -0
  19. package/build/protos/protos.js +100360 -0
  20. package/build/protos/protos.json +10271 -0
  21. package/build/src/backup.d.ts +349 -0
  22. package/build/src/backup.js +246 -0
  23. package/build/src/batch-transaction.d.ts +247 -0
  24. package/build/src/batch-transaction.js +384 -0
  25. package/build/src/codec.d.ts +362 -0
  26. package/build/src/codec.js +791 -0
  27. package/build/src/common-grpc/service-object.d.ts +80 -0
  28. package/build/src/common-grpc/service-object.js +101 -0
  29. package/build/src/common-grpc/service.d.ts +445 -0
  30. package/build/src/common-grpc/service.js +826 -0
  31. package/build/src/common.d.ts +66 -0
  32. package/build/src/common.js +54 -0
  33. package/build/src/database.d.ts +2103 -0
  34. package/build/src/database.js +1655 -0
  35. package/build/src/extra_proto_list.json +1 -0
  36. package/build/src/helper.d.ts +45 -0
  37. package/build/src/helper.js +71 -0
  38. package/build/src/index.d.ts +1195 -0
  39. package/build/src/index.js +1059 -0
  40. package/build/src/instance-config.d.ts +294 -0
  41. package/build/src/instance-config.js +216 -0
  42. package/build/src/instance.d.ts +832 -0
  43. package/build/src/instance.js +781 -0
  44. package/build/src/instrument.d.ts +85 -0
  45. package/build/src/instrument.js +215 -0
  46. package/build/src/multiplexed-session.d.ts +136 -0
  47. package/build/src/multiplexed-session.js +197 -0
  48. package/build/src/partial-result-stream.d.ts +253 -0
  49. package/build/src/partial-result-stream.js +400 -0
  50. package/build/src/session-factory.d.ts +100 -0
  51. package/build/src/session-factory.js +93 -0
  52. package/build/src/session-pool.d.ts +471 -0
  53. package/build/src/session-pool.js +754 -0
  54. package/build/src/session.d.ts +258 -0
  55. package/build/src/session.js +348 -0
  56. package/build/src/spanner_grpc_config.json +92 -0
  57. package/build/src/table.d.ts +831 -0
  58. package/build/src/table.js +277 -0
  59. package/build/src/transaction-runner.d.ts +185 -0
  60. package/build/src/transaction-runner.js +282 -0
  61. package/build/src/transaction.d.ts +1691 -0
  62. package/build/src/transaction.js +2004 -0
  63. package/build/src/v1/database_admin_client.d.ts +2301 -0
  64. package/build/src/v1/database_admin_client.js +2286 -0
  65. package/build/src/v1/database_admin_client_config.json +160 -0
  66. package/build/src/v1/database_admin_proto_list.json +6 -0
  67. package/build/src/v1/gapic_metadata.json +27 -0
  68. package/build/src/v1/index.d.ts +4 -0
  69. package/build/src/v1/index.js +29 -0
  70. package/build/src/v1/instance_admin_client.d.ts +1985 -0
  71. package/build/src/v1/instance_admin_client.js +1768 -0
  72. package/build/src/v1/instance_admin_client_config.json +129 -0
  73. package/build/src/v1/instance_admin_proto_list.json +4 -0
  74. package/build/src/v1/spanner_client.d.ts +1250 -0
  75. package/build/src/v1/spanner_client.js +1086 -0
  76. package/build/src/v1/spanner_client_config.json +119 -0
  77. package/build/src/v1/spanner_executor_proxy_client.d.ts +418 -0
  78. package/build/src/v1/spanner_executor_proxy_client.js +706 -0
  79. package/build/src/v1/spanner_executor_proxy_client_config.json +30 -0
  80. package/build/src/v1/spanner_executor_proxy_proto_list.json +14 -0
  81. package/build/src/v1/spanner_proto_list.json +10 -0
  82. package/package.json +1 -1
@@ -0,0 +1,832 @@
1
+ /*!
2
+ * Copyright 2016 Google Inc. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { GetConfig } from '@google-cloud/common';
17
+ declare const common: any;
18
+ import { Database, SessionPoolConstructor } from './database';
19
+ import { Spanner, RequestConfig } from '.';
20
+ import { RequestCallback, PagedOptions, PagedResponse, LongRunningCallback, NormalCallback, ResourceCallback, PagedOptionsWithFilter } from './common';
21
+ import { Duplex } from 'stream';
22
+ import { SessionPoolOptions, SessionPool } from './session-pool';
23
+ import { Operation as GaxOperation, CallOptions } from 'google-gax';
24
+ import { Backup, CopyBackupCallback, CopyBackupResponse, CopyBackupOptions } from './backup';
25
+ import { google as instanceAdmin } from '../protos/protos';
26
+ import { google as databaseAdmin } from '../protos/protos';
27
+ import { google as spannerClient } from '../protos/protos';
28
+ import { CreateInstanceRequest } from './index';
29
+ import { ObservabilityOptions } from './instrument';
30
+ export type IBackup = databaseAdmin.spanner.admin.database.v1.IBackup;
31
+ export type IDatabase = databaseAdmin.spanner.admin.database.v1.IDatabase;
32
+ export type IInstance = instanceAdmin.spanner.admin.instance.v1.IInstance;
33
+ export type IOperation = instanceAdmin.longrunning.IOperation;
34
+ export type CreateInstanceResponse = [Instance, GaxOperation, IOperation];
35
+ export type CreateDatabaseResponse = [Database, GaxOperation, IOperation];
36
+ export type DeleteInstanceResponse = [instanceAdmin.protobuf.IEmpty];
37
+ export type ExistsInstanceResponse = [boolean];
38
+ export type GetInstanceResponse = [Instance, IInstance];
39
+ export type GetInstanceMetadataResponse = [IInstance];
40
+ export interface GetInstanceMetadataOptions {
41
+ fieldNames?: string | string[];
42
+ gaxOptions?: CallOptions;
43
+ }
44
+ export type GetDatabasesResponse = PagedResponse<Database, databaseAdmin.spanner.admin.database.v1.IListDatabasesResponse>;
45
+ export type SetInstanceMetadataResponse = [GaxOperation, IOperation];
46
+ export type GetBackupsResponse = PagedResponse<Backup, databaseAdmin.spanner.admin.database.v1.IListBackupsResponse>;
47
+ export type GetBackupOperationsResponse = PagedResponse<IOperation, databaseAdmin.spanner.admin.database.v1.IListBackupOperationsResponse>;
48
+ export type GetDatabaseOperationsResponse = PagedResponse<IOperation, databaseAdmin.spanner.admin.database.v1.IListDatabaseOperationsResponse>;
49
+ export interface CreateDatabaseOptions extends databaseAdmin.spanner.admin.database.v1.ICreateDatabaseRequest {
50
+ poolOptions?: SessionPoolOptions;
51
+ poolCtor?: SessionPool;
52
+ schema?: string | string[];
53
+ gaxOptions?: CallOptions;
54
+ }
55
+ export type GetDatabasesOptions = PagedOptions;
56
+ export type CreateInstanceCallback = LongRunningCallback<Instance>;
57
+ export type CreateDatabaseCallback = LongRunningCallback<Database>;
58
+ export type DeleteInstanceCallback = NormalCallback<instanceAdmin.protobuf.IEmpty>;
59
+ export type ExistsInstanceCallback = NormalCallback<boolean>;
60
+ export type GetDatabasesCallback = RequestCallback<Database, databaseAdmin.spanner.admin.database.v1.IListDatabasesResponse>;
61
+ export type GetInstanceCallback = ResourceCallback<Instance, IInstance>;
62
+ export type GetInstanceMetadataCallback = NormalCallback<IInstance>;
63
+ export type SetInstanceMetadataCallback = ResourceCallback<GaxOperation, IOperation>;
64
+ export type GetBackupsOptions = PagedOptionsWithFilter;
65
+ export type GetBackupsCallback = RequestCallback<Backup, databaseAdmin.spanner.admin.database.v1.IListBackupsResponse>;
66
+ export type GetBackupOperationsOptions = PagedOptionsWithFilter;
67
+ export type GetBackupOperationsCallback = RequestCallback<IOperation, databaseAdmin.spanner.admin.database.v1.IListBackupOperationsResponse>;
68
+ export type GetDatabaseOperationsOptions = PagedOptionsWithFilter;
69
+ export type GetDatabaseOperationsCallback = RequestCallback<IOperation, databaseAdmin.spanner.admin.database.v1.IListDatabaseOperationsResponse>;
70
+ export interface GetInstanceConfig extends GetConfig, CreateInstanceRequest, GetInstanceMetadataOptions {
71
+ }
72
+ interface InstanceRequest {
73
+ (config: RequestConfig, callback: ResourceCallback<GaxOperation, IOperation>): void;
74
+ <T>(config: RequestConfig, callback: RequestCallback<T>): void;
75
+ <T, R>(config: RequestConfig, callback: RequestCallback<T, R>): void;
76
+ }
77
+ /**
78
+ * The {@link Instance} class represents a [Cloud Spanner
79
+ * instance](https://cloud.google.com/spanner/docs/instances).
80
+ *
81
+ * Create an `Instance` object to interact with a Cloud Spanner instance.
82
+ *
83
+ * @class
84
+ *
85
+ * @param {Spanner} spanner {@link Spanner} instance.
86
+ * @param {string} name Name of the instance.
87
+ *
88
+ * @example
89
+ * ```
90
+ * const {Spanner} = require('@google-cloud/spanner');
91
+ * const spanner = new Spanner();
92
+ * const instance = spanner.instance('my-instance');
93
+ * ```
94
+ */
95
+ declare class Instance extends common.GrpcServiceObject {
96
+ formattedName_: string;
97
+ request: InstanceRequest;
98
+ requestStream: (config: RequestConfig) => Duplex;
99
+ databases_: Map<string, Database>;
100
+ metadata?: IInstance;
101
+ commonHeaders_: {
102
+ [k: string]: string;
103
+ };
104
+ _observabilityOptions?: ObservabilityOptions;
105
+ constructor(spanner: Spanner, name: string);
106
+ /**
107
+ * Get a reference to a Backup object.
108
+ *
109
+ * @throws {GoogleError} If any parameter is not provided.
110
+ *
111
+ * @param {string} backupId The name of the backup.
112
+ * @return {Backup} A Backup object.
113
+ *
114
+ * @example
115
+ * ```
116
+ * const {Spanner} = require('@google-cloud/spanner');
117
+ * const spanner = new Spanner();
118
+ * const instance = spanner.instance('my-instance');
119
+ * const backup = instance.backup('my-backup');
120
+ * ```
121
+ */
122
+ backup(backupId: string): Backup;
123
+ /**
124
+ * Get a reference to a Backup object.
125
+ *
126
+ * @throws {GoogleError} If any parameter is not provided.
127
+ *
128
+ * @typedef {object} CopyBackupOptions
129
+ * * @property {string|null}
130
+ * * sourceBackup The full path of the backup to be copied
131
+ * * @property {string|number|google.protobuf.Timestamp|external:PreciseDate}
132
+ * * expireTime The expire time of the backup.
133
+ * * @property {google.spanner.admin.database.v1.ICopyBackupEncryptionConfig}
134
+ * * encryptionConfig An encryption configuration describing the
135
+ * * encryption type and key resources in Cloud KMS to be used to encrypt
136
+ * * the copy backup.
137
+ * * @property {object} [gaxOptions] The request configuration options,
138
+ * * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
139
+ * * for more details.
140
+ * */
141
+ /**
142
+ * @callback CopyBackupCallback
143
+ * @param {string} sourceBackupId Full path of the source backup to be copied.
144
+ * @param {string} backupId The name of the backup.
145
+ * @param {CopyBackupOptions}
146
+ * @return {Backup} A Backup object.
147
+ *
148
+ * @example
149
+ * ```
150
+ * const {Spanner} = require('@google-cloud/spanner');
151
+ * const spanner = new Spanner();
152
+ * const instance = spanner.instance('my-instance');
153
+ * const backup = instance.copyBackup('my-source-backup','my-backup',{
154
+ * expireTime: expireTime,
155
+ * encryptionConfig: {
156
+ * encryptionType: 'CUSTOMER_MANAGED_ENCRYPTION',
157
+ * kmsKeyName: 'projects/my-project-id/my-region/keyRings/my-key-ring/cryptoKeys/my-key',
158
+ * },);
159
+ * ```
160
+ */
161
+ copyBackup(sourceBackupId: string, backupId: string, options: CopyBackupOptions, callback?: CopyBackupCallback): Promise<CopyBackupResponse> | void;
162
+ /**
163
+ * Query object for listing backups.
164
+ *
165
+ * @typedef {object} GetBackupsOptions
166
+ * @property {string} [filter] An expression for filtering the results of the
167
+ * request. Filter can be configured as outlined in
168
+ * {@link v1.DatabaseAdminClient#listBackups}.
169
+ * @property {number} [pageSize] Maximum number of results per page.
170
+ * @property {string} [pageToken] A previously-returned page token
171
+ * representing part of the larger set of results to view.
172
+ * @property {object} [gaxOptions] Request configuration options,
173
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
174
+ * for more details.
175
+ */
176
+ /**
177
+ * @typedef {array} GetBackupsResponse
178
+ * @property {Backup[]} 0 Array of {@link Backup} instances.
179
+ * @property {object} 1 A query object to receive more results.
180
+ * @property {object} 2 The full API response.
181
+ */
182
+ /**
183
+ * @callback GetBackupsCallback
184
+ * @param {?Error} err Request error, if any.
185
+ * @param {Backup[]} 0 Array of {@link Backup} instances.
186
+ * @param {object} nextQuery A query object to receive more results.
187
+ * @param {object} apiResponse The full API response.
188
+ */
189
+ /**
190
+ * List backups on the instance.
191
+ *
192
+ * Both completed and in-progress backups are listed if no filter is supplied.
193
+ *
194
+ * @see {@link #backup}
195
+ *
196
+ * @param {GetBackupsOptions} [options] The query object for listing backups.
197
+ * @param {gax.CallOptions} [options.gaxOptions] The request configuration
198
+ * options, See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
199
+ * for more details.
200
+ * @returns {Promise<GetBackupsResponse>} When resolved, contains a paged list
201
+ * of backups.
202
+ *
203
+ * @example
204
+ * ```
205
+ * const {Spanner} = require('@google-cloud/spanner');
206
+ * const spanner = new Spanner();
207
+ * const instance = spanner.instance('my-instance');
208
+ * const [backups] = await instance.getBackups();
209
+ *
210
+ * //-
211
+ * // To manually handle pagination, set autoPaginate:false in gaxOptions.
212
+ * //-
213
+ * let pageToken = undefined;
214
+ * do {
215
+ * const [backups, , response] = await instance.getBackups({
216
+ * pageSize: 3,
217
+ * pageToken,
218
+ * gaxOptions: {autoPaginate: false},
219
+ * });
220
+ * backups.forEach(backup => {
221
+ * // Do something with backup
222
+ * });
223
+ * pageToken = response.nextPageToken;
224
+ * } while (pageToken);
225
+ * ```
226
+ */
227
+ getBackups(options?: GetBackupsOptions): Promise<GetBackupsResponse>;
228
+ getBackups(callback: GetBackupsCallback): void;
229
+ getBackups(options: GetBackupsOptions, callback: GetBackupsCallback): void;
230
+ /**
231
+ * Get a list of backups as a readable object stream.
232
+ *
233
+ * Wrapper around {@link v1.DatabaseAdminClient#listBackups}.
234
+ *
235
+ * @see {@link v1.DatabaseAdminClient#listBackups}
236
+ * @see [ListBackups API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.ListBackups)
237
+ *
238
+ * @method Spanner#getBackupsStream
239
+ * @param {GetBackupOptions} [options] Query object for listing backups.
240
+ * @returns {ReadableStream} A readable stream that emits {@link Backup}
241
+ * instances.
242
+ *
243
+ * @example
244
+ * ```
245
+ * const {Spanner} = require('@google-cloud/spanner');
246
+ * const spanner = new Spanner();
247
+ *
248
+ * const instance = spanner.instance('my-instance');
249
+ *
250
+ * instance.getBackupsStream()
251
+ * .on('error', console.error)
252
+ * .on('data', function(database) {
253
+ * // `backups` is a `Backup` object.
254
+ * })
255
+ * .on('end', function() {
256
+ * // All backups retrieved.
257
+ * });
258
+ *
259
+ * //-
260
+ * // If you anticipate many results, you can end a stream early to prevent
261
+ * // unnecessary processing and API requests.
262
+ * //-
263
+ * instance.getBackupsStream()
264
+ * .on('data', function(database) {
265
+ * this.end();
266
+ * });
267
+ * ```
268
+ */
269
+ getBackupsStream(options?: GetBackupsOptions): NodeJS.ReadableStream;
270
+ /**
271
+ * Query object for listing backup operations.
272
+ *
273
+ * @typedef {object} GetBackupOperationsOptions
274
+ * @property {string} [filter] An expression for filtering the results of the
275
+ * request. Filter can be configured as outlined in
276
+ * {@link v1.DatabaseAdminClient#listBackupOperations}.
277
+ * @property {number} [pageSize] Maximum number of results per page.
278
+ * @property {string} [pageToken] A previously-returned page token
279
+ * representing part of the larger set of results to view.
280
+ * @property {object} [gaxOptions] Request configuration options,
281
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
282
+ * for more details.
283
+ */
284
+ /**
285
+ * @typedef {array} GetBackupOperationsResponse
286
+ * @property {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
287
+ * @property {object} 1 A query object to receive more results.
288
+ * @property {object} 2 The full API response.
289
+ */
290
+ /**
291
+ * @callback GetBackupOperationsCallback
292
+ * @param {?Error} err Request error, if any.
293
+ * @param {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
294
+ * @param {object} nextQuery A query object to receive more results.
295
+ * @param {object} apiResponse The full API response.
296
+ */
297
+ getBackupOperations(options?: GetBackupOperationsOptions): Promise<GetBackupOperationsResponse>;
298
+ getBackupOperations(callback: GetBackupOperationsCallback): void;
299
+ getBackupOperations(options: GetBackupOperationsOptions, callback: GetBackupOperationsCallback): void;
300
+ /**
301
+ * Query object for listing database operations.
302
+ *
303
+ * @typedef {object} GetDatabaseOperationsOptions
304
+ * @property {string} [filter] An expression for filtering the results of the
305
+ * request. Filter can be configured as outlined in
306
+ * {@link v1.DatabaseAdminClient#listDatabaseOperations}.
307
+ * @property {number} [pageSize] Maximum number of results per page.
308
+ * @property {string} [pageToken] A previously-returned page token
309
+ * representing part of the larger set of results to view.
310
+ * @property {object} [gaxOptions] Request configuration options,
311
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
312
+ * for more details.
313
+ */
314
+ /**
315
+ * @typedef {array} GetDatabaseOperationsResponse
316
+ * @property {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
317
+ * @property {object} 1 A query object to receive more results.
318
+ * @property {object} 2 The full API response.
319
+ */
320
+ /**
321
+ * @callback GetDatabaseOperationsCallback
322
+ * @param {?Error} err Request error, if any.
323
+ * @param {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
324
+ * @param {object} nextQuery A query object to receive more results.
325
+ * @param {object} apiResponse The full API response.
326
+ */
327
+ getDatabaseOperations(options?: GetDatabaseOperationsOptions): Promise<GetDatabaseOperationsResponse>;
328
+ getDatabaseOperations(callback: GetDatabaseOperationsCallback): void;
329
+ getDatabaseOperations(options: GetDatabaseOperationsOptions, callback: GetDatabaseOperationsCallback): void;
330
+ /**
331
+ * Config for the new database.
332
+ *
333
+ * @typedef {object} CreateDatabaseRequest
334
+ * @property {SessionPoolOptions} [poolOptions]
335
+ * @property {SessionPoolCtor} [poolCtor]
336
+ */
337
+ /**
338
+ * @typedef {array} CreateDatabaseResponse
339
+ * @property {Database} 0 The new {@link Database}.
340
+ * @property {google.longrunning.Operation} 1 An {@link Operation} object that can be used to check
341
+ * the status of the request.
342
+ * @property {object} 2 The full API response.
343
+ */
344
+ /**
345
+ * @callback CreateDatabaseCallback
346
+ * @param {?Error} err Request error, if any.
347
+ * @param {Database} database The new {@link Database}.
348
+ * @param {google.longrunning.Operation} operation An {@link Operation} object that can be used to
349
+ * check the status of the request.
350
+ * @param {object} apiResponse The full API response.
351
+ */
352
+ /**
353
+ * Create a database in this instance.
354
+ *
355
+ * Wrapper around {@link v1.DatabaseAdminClient#createDatabase}.
356
+ *
357
+ * @see {@link v1.DatabaseAdminClient#createDatabase}
358
+ * @see [CreateDatabase API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase)
359
+ *
360
+ * @throws {GoogleError} If a name is not provided.
361
+ *
362
+ * @param {name} name The name of the database to create.
363
+ * @param {CreateDatabaseRequest} [options] Configuration object.
364
+ * @param {CreateDatabaseCallback} [callback] Callback function.
365
+ * @returns {Promise<CreateDatabaseResponse>}
366
+ *
367
+ * @example
368
+ * ```
369
+ * const {Spanner} = require('@google-cloud/spanner');
370
+ * const spanner = new Spanner();
371
+ *
372
+ * const instance = spanner.instance('my-instance');
373
+ *
374
+ * function callback(err, database, operation, apiResponse) {
375
+ * if (err) {
376
+ * // Error handling omitted.
377
+ * }
378
+ *
379
+ * operation
380
+ * .on('error', function(err) {})
381
+ * .on('complete', function() {
382
+ * // Database created successfully.
383
+ * });
384
+ * }
385
+ *
386
+ * instance.createDatabase('new-database-name', callback);
387
+ *
388
+ * //-
389
+ * // Set the schema for the database.
390
+ * //-
391
+ * instance.createDatabase('new-database-name', {
392
+ * schema:
393
+ * 'CREATE TABLE Singers (' +
394
+ * ' SingerId STRING(1024) NOT NULL,' +
395
+ * ' Name STRING(1024),' +
396
+ * ') PRIMARY KEY(SingerId)'
397
+ * }, callback);
398
+ * //-
399
+ * // If the callback is omitted, we'll return a Promise.
400
+ * //-
401
+ * instance.createDatabase('new-database-name')
402
+ * .then(function(data) {
403
+ * const database = data[0];
404
+ * const operation = data[1];
405
+ * return operation.promise();
406
+ * })
407
+ * .then(function() {
408
+ * // Database created successfully.
409
+ * });
410
+ *
411
+ * ```
412
+ * @example <caption>include:samples/schema.js</caption>
413
+ * region_tag:spanner_create_database
414
+ * Full example:
415
+ */
416
+ createDatabase(name: string, options?: CreateDatabaseOptions): Promise<CreateDatabaseResponse>;
417
+ createDatabase(name: string, callback: CreateDatabaseCallback): void;
418
+ createDatabase(name: string, options: CreateDatabaseOptions, callback: CreateDatabaseCallback): void;
419
+ /**
420
+ * Get a reference to a Database object.
421
+ *
422
+ * @throws {GoogleError} If a name is not provided.
423
+ *
424
+ * @param {string} name The name of the instance.
425
+ * @param {SessionPoolOptions|SessionPoolCtor} [poolOptions] Session pool
426
+ * configuration options.
427
+ * @param {spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions} [queryOptions]
428
+ * Default query options to use with the database. These options will be
429
+ * overridden by any query options set in environment variables or that
430
+ * are specified on a per-query basis.
431
+ * @return {Database} A Database object.
432
+ *
433
+ * @example
434
+ * ```
435
+ * const {Spanner} = require('@google-cloud/spanner');
436
+ * const spanner = new Spanner();
437
+ *
438
+ * const instance = spanner.instance('my-instance');
439
+ * const database = instance.database('my-database');
440
+ * ```
441
+ */
442
+ database(name: string, poolOptions?: SessionPoolOptions | SessionPoolConstructor, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions): Database;
443
+ /**
444
+ * @typedef {array} DeleteInstanceResponse
445
+ * @property {object} 0 The full API response.
446
+ */
447
+ /**
448
+ * @callback DeleteInstanceCallback
449
+ * @param {?Error} err Request error, if any.
450
+ * @param {object} apiResponse The full API response.
451
+ */
452
+ /**
453
+ * Delete the instance.
454
+ *
455
+ * Wrapper around {@link v1.InstanceAdminClient#deleteInstance}.
456
+ *
457
+ * @see {@link v1.InstanceAdminClient#deleteInstance}
458
+ * @see [DeleteInstance API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance)
459
+ *
460
+ * @param {object} [gaxOptions] Request configuration options,
461
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
462
+ * for more details.
463
+ * @param {DeleteInstanceCallback} [callback] Callback function.
464
+ * @returns {Promise<DeleteInstanceResponse>}
465
+ *
466
+ * @example
467
+ * ```
468
+ * const {Spanner} = require('@google-cloud/spanner');
469
+ * const spanner = new Spanner();
470
+ *
471
+ * const instance = spanner.instance('my-instance');
472
+ *
473
+ * instance.delete(function(err, apiResponse) {
474
+ * if (err) {
475
+ * // Error handling omitted.
476
+ * }
477
+ *
478
+ * // Instance was deleted successfully.
479
+ * });
480
+ *
481
+ * //-
482
+ * // If the callback is omitted, we'll return a Promise.
483
+ * //-
484
+ * instance.delete().then(function(data) {
485
+ * const apiResponse = data[0];
486
+ * });
487
+ * ```
488
+ */
489
+ delete(gaxOptions?: CallOptions): Promise<DeleteInstanceResponse>;
490
+ delete(callback: DeleteInstanceCallback): void;
491
+ delete(gaxOptions: CallOptions, callback: DeleteInstanceCallback): void;
492
+ /**
493
+ * @typedef {array} InstanceExistsResponse
494
+ * @property {boolean} 0 Whether the {@link Instance} exists.
495
+ */
496
+ /**
497
+ * @callback InstanceExistsCallback
498
+ * @param {?Error} err Request error, if any.
499
+ * @param {boolean} exists Whether the {@link Instance} exists.
500
+ */
501
+ /**
502
+ * Check if an instance exists.
503
+ *
504
+ * @method Instance#exists
505
+ * @param {object} [gaxOptions] Request configuration options,
506
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
507
+ * for more details.
508
+ * @param {InstanceExistsCallback} [callback] Callback function.
509
+ * @returns {Promise<InstanceExistsResponse>}
510
+ *
511
+ * @example
512
+ * ```
513
+ * const {Spanner} = require('@google-cloud/spanner');
514
+ * const spanner = new Spanner();
515
+ *
516
+ * const instance = spanner.instance('my-instance');
517
+ *
518
+ * instance.exists(function(err, exists) {});
519
+ *
520
+ * //-
521
+ * // If the callback is omitted, we'll return a Promise.
522
+ * //-
523
+ * instance.exists().then(function(data) {
524
+ * const exists = data[0];
525
+ * });
526
+ * ```
527
+ */
528
+ exists(gaxOptions?: CallOptions): Promise<ExistsInstanceResponse>;
529
+ exists(callback: ExistsInstanceCallback): void;
530
+ exists(gaxOptions: CallOptions, callback: ExistsInstanceCallback): void;
531
+ /**
532
+ * @typedef {array} GetInstanceResponse
533
+ * @property {Instance} 0 The {@link Instance}.
534
+ * @property {object} 1 The full API response.
535
+ */
536
+ /**
537
+ * @callback GetInstanceCallback
538
+ * @param {?Error} err Request error, if any.
539
+ * @param {Instance} instance The {@link Instance}.
540
+ * @param {object} apiResponse The full API response.
541
+ */
542
+ /**
543
+ * Get an instance if it exists.
544
+ *
545
+ * You may optionally use this to "get or create" an object by providing an
546
+ * object with `autoCreate` set to `true`. Any extra configuration that is
547
+ * normally required for the `create` method must be contained within this
548
+ * object as well.
549
+ *
550
+ * @param {options} [options] Configuration object.
551
+ * @param {boolean} [options.autoCreate=false] Automatically create the
552
+ * object if it does not exist.
553
+ * @param {string | string[]} [options.fieldNames] A list of `Instance` field
554
+ * names to be requested. Eligible values are: `name`, `displayName`,
555
+ * `endpointUris`, `labels`, `config`, `nodeCount`, `state`.
556
+ * @param {GetInstanceCallback} [callback] Callback function.
557
+ * @returns {Promise<GetInstanceResponse>}
558
+ *
559
+ * @example
560
+ * ```
561
+ * const {Spanner} = require('@google-cloud/spanner');
562
+ * const spanner = new Spanner();
563
+ *
564
+ * const instance = spanner.instance('my-instance');
565
+ *
566
+ * instance.get(function(err, instance, apiResponse) {
567
+ * // `instance.metadata` has been populated.
568
+ * });
569
+ *
570
+ * //-
571
+ * // If the callback is omitted, we'll return a Promise.
572
+ * //-
573
+ * instance.get().then(function(data) {
574
+ * const instance = data[0];
575
+ * const apiResponse = data[0];
576
+ * });
577
+ * ```
578
+ */
579
+ get(options?: GetInstanceConfig): Promise<GetInstanceResponse>;
580
+ get(callback: GetInstanceCallback): void;
581
+ get(options: GetInstanceConfig, callback: GetInstanceCallback): void;
582
+ /**
583
+ * Query object for listing databases.
584
+ *
585
+ * @typedef {object} GetDatabasesRequest
586
+ * @property {number} [pageSize] Maximum number of results per page.
587
+ * @property {string} [pageToken] A previously-returned page token
588
+ * representing part of the larger set of results to view.
589
+ * @property {object} [gaxOptions] Request configuration options,
590
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
591
+ * for more details.
592
+ */
593
+ /**
594
+ * @typedef {array} GetDatabasesResponse
595
+ * @property {Database[]} 0 Array of {@link Database} instances.
596
+ * @property {object} nextQuery A query object to receive more results.
597
+ * @property {object} apiResponse The full API response.
598
+ */
599
+ /**
600
+ * @callback GetDatabasesCallback
601
+ * @param {?Error} err Request error, if any.
602
+ * @param {Database[]} databases Array of {@link Database} instances.
603
+ * @param {object} nextQuery A query object to receive more results.
604
+ * @param {object} apiResponse The full API response.
605
+ */
606
+ /**
607
+ * Get a list of databases.
608
+ *
609
+ * Wrapper around {@link v1.DatabaseAdminClient#listDatabases}.
610
+ *
611
+ * @see {@link v1.DatabaseAdminClient#listDatabases}
612
+ * @see [ListDatabases API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases)
613
+ *
614
+ * @param {GetDatabasesOptions} [options] Query object for listing databases.
615
+ * @param {GetDatabasesCallback} [callback] Callback function.
616
+ * @returns {Promise<GetDatabasesResponse>}
617
+ *
618
+ * @example
619
+ * ```
620
+ * const {Spanner} = require('@google-cloud/spanner');
621
+ * const spanner = new Spanner();
622
+ *
623
+ * const instance = spanner.instance('my-instance');
624
+ *
625
+ * instance.getDatabases(function(err, databases) {
626
+ * // `databases` is an array of `Database` objects.
627
+ * });
628
+ *
629
+ * //-
630
+ * // To control how many API requests are made and page through the results
631
+ * // manually, set `autoPaginate` to `false`.
632
+ * //-
633
+ * function callback(err, databases, nextQuery, apiResponse) {
634
+ * if (nextQuery) {
635
+ * // More results exist.
636
+ * instance.getDatabases(nextQuery, callback);
637
+ * }
638
+ * }
639
+ *
640
+ * instance.getDatabases({
641
+ * gaxOptions: {autoPaginate: false}
642
+ * }, callback);
643
+ *
644
+ * //-
645
+ * // If the callback is omitted, we'll return a Promise.
646
+ * //-
647
+ * instance.getDatabases().then(function(data) {
648
+ * const databases = data[0];
649
+ * });
650
+ * ```
651
+ */
652
+ getDatabases(options?: GetDatabasesOptions): Promise<GetDatabasesResponse>;
653
+ getDatabases(callback: GetDatabasesCallback): void;
654
+ getDatabases(options: GetDatabasesOptions, callback: GetDatabasesCallback): void;
655
+ /**
656
+ * Get a list of databases as a readable object stream.
657
+ *
658
+ * Wrapper around {@link v1.DatabaseAdminClient#listDatabases}.
659
+ *
660
+ * @see {@link v1.DatabaseAdminClient#listDatabases}
661
+ * @see [ListDatabases API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases)
662
+ *
663
+ * @method Spanner#getDatabasesStream
664
+ * @param {GetDatabasesOptions} [options] Query object for listing databases.
665
+ * @returns {ReadableStream} A readable stream that emits {@link Database}
666
+ * instances.
667
+ *
668
+ * @example
669
+ * ```
670
+ * const {Spanner} = require('@google-cloud/spanner');
671
+ * const spanner = new Spanner();
672
+ *
673
+ * const instance = spanner.instance('my-instance');
674
+ *
675
+ * instance.getDatabasesStream()
676
+ * .on('error', console.error)
677
+ * .on('data', function(database) {
678
+ * // `database` is a `Database` object.
679
+ * })
680
+ * .on('end', function() {
681
+ * // All databases retrieved.
682
+ * });
683
+ *
684
+ * //-
685
+ * // If you anticipate many results, you can end a stream early to prevent
686
+ * // unnecessary processing and API requests.
687
+ * //-
688
+ * instance.getDatabasesStream()
689
+ * .on('data', function(database) {
690
+ * this.end();
691
+ * });
692
+ * ```
693
+ */
694
+ getDatabasesStream(options?: GetDatabasesOptions): NodeJS.ReadableStream;
695
+ /**
696
+ * @typedef {array} GetInstanceMetadataResponse
697
+ * @property {object} 0 The {@link Instance} metadata.
698
+ * @property {object} 1 The full API response.
699
+ */
700
+ /**
701
+ * @callback GetInstanceMetadataCallback
702
+ * @param {?Error} err Request error, if any.
703
+ * @param {object} metadata The {@link Instance} metadata.
704
+ * @param {object} apiResponse The full API response.
705
+ */
706
+ /**
707
+ * Get the instance's metadata.
708
+ *
709
+ * Wrapper around {@link v1.InstanceAdminClient#getInstance}.
710
+ *
711
+ * @see {@link v1.InstanceAdminClient#getInstance}
712
+ * @see [GetInstance API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.GetInstance)
713
+ *
714
+ * @param {GetInstanceMetadataOptions} [options] Configuration object
715
+ * @param {string | string[]} [options.fieldNames] A list of `Instance` field
716
+ * names to be requested. Eligible values are: `name`, `displayName`,
717
+ * `endpointUris`, `labels`, `config`, `nodeCount`, `state`.
718
+ * @param {GetInstanceMetadataCallback} [callback] Callback function.
719
+ * @returns {Promise<GetInstanceMetadataResponse>}
720
+ *
721
+ * @example
722
+ * ```
723
+ * const {Spanner} = require('@google-cloud/spanner');
724
+ * const spanner = new Spanner();
725
+ *
726
+ * const instance = spanner.instance('my-instance');
727
+ *
728
+ * instance.getMetadata(function(err, metadata, apiResponse) {});
729
+ *
730
+ * //-
731
+ * // Request only `displayName`.
732
+ * //-
733
+ * instance.getMetadata({fieldNames: 'displayName'}, (err, metadata, apiResponse) => {
734
+ * // metadata will only contain value for `displayName`
735
+ * const displayName = metadata['displayName'];
736
+ * })
737
+ *
738
+ * //-
739
+ * // Request multiple specific field names.
740
+ * //-
741
+ * instance.getMetadata({fieldNames: ['displayName', 'nodeCount']}, (err, metadata, apiResponse) => {
742
+ * // metadata will only contain value for `displayName` and 'nodeCount'
743
+ * const displayName = metadata['displayName'];
744
+ * const nodeCount = metadata['nodeCount'];
745
+ * });
746
+ *
747
+ * //-
748
+ * // If the callback is omitted, we'll return a Promise.
749
+ * //-
750
+ * instance.getMetadata().then(function(data) {
751
+ * const metadata = data[0];
752
+ * const apiResponse = data[1];
753
+ * });
754
+ * ```
755
+ */
756
+ getMetadata(options?: GetInstanceMetadataOptions): Promise<GetInstanceMetadataResponse>;
757
+ getMetadata(callback: GetInstanceMetadataCallback): void;
758
+ getMetadata(options: GetInstanceMetadataOptions, callback: GetInstanceMetadataCallback): void;
759
+ /**
760
+ * Update the metadata for this instance. Note that this method follows PATCH
761
+ * semantics, so previously-configured settings will persist.
762
+ *
763
+ * Wrapper around {@link v1.InstanceAdminClient#updateInstance}.
764
+ *
765
+ * @see {@link v1.InstanceAdminClient#updateInstance}
766
+ * @see [UpdateInstance API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance)
767
+ *
768
+ * @param {object} metadata The metadata you wish to set.
769
+ * @param {object} [gaxOptions] Request configuration options,
770
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
771
+ * for more details.
772
+ * @param {SetInstanceMetadataCallback} [callback] Callback function.
773
+ * @returns {Promise<LongRunningOperationResponse>}
774
+ *
775
+ * @example
776
+ * ```
777
+ * const {Spanner} = require('@google-cloud/spanner');
778
+ * const spanner = new Spanner();
779
+ *
780
+ * const instance = spanner.instance('my-instance');
781
+ *
782
+ * const metadata = {
783
+ * displayName: 'My Instance'
784
+ * };
785
+ *
786
+ * instance.setMetadata(metadata, function(err, operation, apiResponse) {
787
+ * if (err) {
788
+ * // Error handling omitted.
789
+ * }
790
+ *
791
+ * operation
792
+ * .on('error', function(err) {})
793
+ * .on('complete', function() {
794
+ * // Metadata updated successfully.
795
+ * });
796
+ * });
797
+ *
798
+ * //-
799
+ * // If the callback is omitted, we'll return a Promise.
800
+ * //-
801
+ * instance.setMetadata(metadata).then(function(data) {
802
+ * const operation = data[0];
803
+ * const apiResponse = data[1];
804
+ * });
805
+ * ```
806
+ */
807
+ setMetadata(metadata: IInstance, gaxOptions?: CallOptions): Promise<SetInstanceMetadataResponse>;
808
+ setMetadata(metadata: IInstance, callback: SetInstanceMetadataCallback): void;
809
+ setMetadata(metadata: IInstance, gaxOptions: CallOptions, callback: SetInstanceMetadataCallback): void;
810
+ /**
811
+ * Format the instance name to include the project ID.
812
+ *
813
+ * @private
814
+ *
815
+ * @param {string} projectId The project ID.
816
+ * @param {string} name The instance name.
817
+ * @returns {string}
818
+ *
819
+ * @example
820
+ * ```
821
+ * Instance.formatName_('grape-spaceship-123', 'my-instance');
822
+ * // 'projects/grape-spaceship-123/instances/my-instance'
823
+ * ```
824
+ */
825
+ static formatName_(projectId: string, name: string): string;
826
+ }
827
+ /**
828
+ * Reference to the {@link Instance} class.
829
+ * @name module:@google-cloud/spanner.Instance
830
+ * @see Instance
831
+ */
832
+ export { Instance };