@google-cloud/spanner 7.17.0 → 7.18.0

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