@google-cloud/spanner 5.15.0 → 5.16.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.
@@ -86,9 +86,11 @@ interface InstanceRequest {
86
86
  * @param {string} name Name of the instance.
87
87
  *
88
88
  * @example
89
+ * ```
89
90
  * const {Spanner} = require('@google-cloud/spanner');
90
91
  * const spanner = new Spanner();
91
92
  * const instance = spanner.instance('my-instance');
93
+ * ```
92
94
  */
93
95
  declare class Instance extends common.GrpcServiceObject {
94
96
  formattedName_: string;
@@ -109,12 +111,79 @@ declare class Instance extends common.GrpcServiceObject {
109
111
  * @return {Backup} A Backup object.
110
112
  *
111
113
  * @example
114
+ * ```
112
115
  * const {Spanner} = require('@google-cloud/spanner');
113
116
  * const spanner = new Spanner();
114
117
  * const instance = spanner.instance('my-instance');
115
118
  * const backup = instance.backup('my-backup');
119
+ * ```
116
120
  */
117
121
  backup(backupId: string): Backup;
122
+ /**
123
+ * Query object for listing backups.
124
+ *
125
+ * @typedef {object} GetBackupsOptions
126
+ * @property {string} [filter] An expression for filtering the results of the
127
+ * request. Filter can be configured as outlined in
128
+ * {@link v1.DatabaseAdminClient#listBackups}.
129
+ * @property {number} [pageSize] Maximum number of results per page.
130
+ * @property {string} [pageToken] A previously-returned page token
131
+ * representing part of the larger set of results to view.
132
+ * @property {object} [gaxOptions] Request configuration options,
133
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
134
+ * for more details.
135
+ */
136
+ /**
137
+ * @typedef {array} GetBackupsResponse
138
+ * @property {Backup[]} 0 Array of {@link Backup} instances.
139
+ * @property {object} 1 A query object to receive more results.
140
+ * @property {object} 2 The full API response.
141
+ */
142
+ /**
143
+ * @callback GetBackupsCallback
144
+ * @param {?Error} err Request error, if any.
145
+ * @param {Backup[]} 0 Array of {@link Backup} instances.
146
+ * @param {object} nextQuery A query object to receive more results.
147
+ * @param {object} apiResponse The full API response.
148
+ */
149
+ /**
150
+ * List backups on the instance.
151
+ *
152
+ * Both completed and in-progress backups are listed if no filter is supplied.
153
+ *
154
+ * @see {@link #backup}
155
+ *
156
+ * @param {GetBackupsOptions} [options] The query object for listing backups.
157
+ * @param {gax.CallOptions} [options.gaxOptions] The request configuration
158
+ * options, See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
159
+ * for more details.
160
+ * @returns {Promise<GetBackupsResponse>} When resolved, contains a paged list
161
+ * of backups.
162
+ *
163
+ * @example
164
+ * ```
165
+ * const {Spanner} = require('@google-cloud/spanner');
166
+ * const spanner = new Spanner();
167
+ * const instance = spanner.instance('my-instance');
168
+ * const [backups] = await instance.getBackups();
169
+ *
170
+ * //-
171
+ * // To manually handle pagination, set autoPaginate:false in gaxOptions.
172
+ * //-
173
+ * let pageToken = undefined;
174
+ * do {
175
+ * const [backups, , response] = await instance.getBackups({
176
+ * pageSize: 3,
177
+ * pageToken,
178
+ * gaxOptions: {autoPaginate: false},
179
+ * });
180
+ * backups.forEach(backup => {
181
+ * // Do something with backup
182
+ * });
183
+ * pageToken = response.nextPageToken;
184
+ * } while (pageToken);
185
+ * ```
186
+ */
118
187
  getBackups(options?: GetBackupsOptions): Promise<GetBackupsResponse>;
119
188
  getBackups(callback: GetBackupsCallback): void;
120
189
  getBackups(options: GetBackupsOptions, callback: GetBackupsCallback): void;
@@ -132,6 +201,7 @@ declare class Instance extends common.GrpcServiceObject {
132
201
  * instances.
133
202
  *
134
203
  * @example
204
+ * ```
135
205
  * const {Spanner} = require('@google-cloud/spanner');
136
206
  * const spanner = new Spanner();
137
207
  *
@@ -154,14 +224,155 @@ declare class Instance extends common.GrpcServiceObject {
154
224
  * .on('data', function(database) {
155
225
  * this.end();
156
226
  * });
227
+ * ```
157
228
  */
158
229
  getBackupsStream(options?: GetBackupsOptions): NodeJS.ReadableStream;
230
+ /**
231
+ * Query object for listing backup operations.
232
+ *
233
+ * @typedef {object} GetBackupOperationsOptions
234
+ * @property {string} [filter] An expression for filtering the results of the
235
+ * request. Filter can be configured as outlined in
236
+ * {@link v1.DatabaseAdminClient#listBackupOperations}.
237
+ * @property {number} [pageSize] Maximum number of results per page.
238
+ * @property {string} [pageToken] A previously-returned page token
239
+ * representing part of the larger set of results to view.
240
+ * @property {object} [gaxOptions] Request configuration options,
241
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
242
+ * for more details.
243
+ */
244
+ /**
245
+ * @typedef {array} GetBackupOperationsResponse
246
+ * @property {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
247
+ * @property {object} 1 A query object to receive more results.
248
+ * @property {object} 2 The full API response.
249
+ */
250
+ /**
251
+ * @callback GetBackupOperationsCallback
252
+ * @param {?Error} err Request error, if any.
253
+ * @param {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
254
+ * @param {object} nextQuery A query object to receive more results.
255
+ * @param {object} apiResponse The full API response.
256
+ */
159
257
  getBackupOperations(options?: GetBackupOperationsOptions): Promise<GetBackupOperationsResponse>;
160
258
  getBackupOperations(callback: GetBackupOperationsCallback): void;
161
259
  getBackupOperations(options: GetBackupOperationsOptions, callback: GetBackupOperationsCallback): void;
260
+ /**
261
+ * Query object for listing database operations.
262
+ *
263
+ * @typedef {object} GetDatabaseOperationsOptions
264
+ * @property {string} [filter] An expression for filtering the results of the
265
+ * request. Filter can be configured as outlined in
266
+ * {@link v1.DatabaseAdminClient#listDatabaseOperations}.
267
+ * @property {number} [pageSize] Maximum number of results per page.
268
+ * @property {string} [pageToken] A previously-returned page token
269
+ * representing part of the larger set of results to view.
270
+ * @property {object} [gaxOptions] Request configuration options,
271
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
272
+ * for more details.
273
+ */
274
+ /**
275
+ * @typedef {array} GetDatabaseOperationsResponse
276
+ * @property {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
277
+ * @property {object} 1 A query object to receive more results.
278
+ * @property {object} 2 The full API response.
279
+ */
280
+ /**
281
+ * @callback GetDatabaseOperationsCallback
282
+ * @param {?Error} err Request error, if any.
283
+ * @param {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
284
+ * @param {object} nextQuery A query object to receive more results.
285
+ * @param {object} apiResponse The full API response.
286
+ */
162
287
  getDatabaseOperations(options?: GetDatabaseOperationsOptions): Promise<GetDatabaseOperationsResponse>;
163
288
  getDatabaseOperations(callback: GetDatabaseOperationsCallback): void;
164
289
  getDatabaseOperations(options: GetDatabaseOperationsOptions, callback: GetDatabaseOperationsCallback): void;
290
+ /**
291
+ * Config for the new database.
292
+ *
293
+ * @typedef {object} CreateDatabaseRequest
294
+ * @property {SessionPoolOptions} [poolOptions]
295
+ * @property {SessionPoolCtor} [poolCtor]
296
+ */
297
+ /**
298
+ * @typedef {array} CreateDatabaseResponse
299
+ * @property {Database} 0 The new {@link Database}.
300
+ * @property {google.longrunning.Operation} 1 An {@link Operation} object that can be used to check
301
+ * the status of the request.
302
+ * @property {object} 2 The full API response.
303
+ */
304
+ /**
305
+ * @callback CreateDatabaseCallback
306
+ * @param {?Error} err Request error, if any.
307
+ * @param {Database} database The new {@link Database}.
308
+ * @param {google.longrunning.Operation} operation An {@link Operation} object that can be used to
309
+ * check the status of the request.
310
+ * @param {object} apiResponse The full API response.
311
+ */
312
+ /**
313
+ * Create a database in this instance.
314
+ *
315
+ * Wrapper around {@link v1.DatabaseAdminClient#createDatabase}.
316
+ *
317
+ * @see {@link v1.DatabaseAdminClient#createDatabase}
318
+ * @see [CreateDatabase API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase)
319
+ *
320
+ * @throws {Error} If a name is not provided.
321
+ *
322
+ * @param {name} name The name of the database to create.
323
+ * @param {CreateDatabaseRequest} [options] Configuration object.
324
+ * @param {CreateDatabaseCallback} [callback] Callback function.
325
+ * @returns {Promise<CreateDatabaseResponse>}
326
+ *
327
+ * @example
328
+ * ```
329
+ * const {Spanner} = require('@google-cloud/spanner');
330
+ * const spanner = new Spanner();
331
+ *
332
+ * const instance = spanner.instance('my-instance');
333
+ *
334
+ * function callback(err, database, operation, apiResponse) {
335
+ * if (err) {
336
+ * // Error handling omitted.
337
+ * }
338
+ *
339
+ * operation
340
+ * .on('error', function(err) {})
341
+ * .on('complete', function() {
342
+ * // Database created successfully.
343
+ * });
344
+ * }
345
+ *
346
+ * instance.createDatabase('new-database-name', callback);
347
+ *
348
+ * //-
349
+ * // Set the schema for the database.
350
+ * //-
351
+ * instance.createDatabase('new-database-name', {
352
+ * schema:
353
+ * 'CREATE TABLE Singers (' +
354
+ * ' SingerId STRING(1024) NOT NULL,' +
355
+ * ' Name STRING(1024),' +
356
+ * ') PRIMARY KEY(SingerId)'
357
+ * }, callback);
358
+ * //-
359
+ * // If the callback is omitted, we'll return a Promise.
360
+ * //-
361
+ * instance.createDatabase('new-database-name')
362
+ * .then(function(data) {
363
+ * const database = data[0];
364
+ * const operation = data[1];
365
+ * return operation.promise();
366
+ * })
367
+ * .then(function() {
368
+ * // Database created successfully.
369
+ * });
370
+ *
371
+ * ```
372
+ * @example <caption>include:samples/schema.js</caption>
373
+ * region_tag:spanner_create_database
374
+ * Full example:
375
+ */
165
376
  createDatabase(name: string, options?: CreateDatabaseOptions): Promise<CreateDatabaseResponse>;
166
377
  createDatabase(name: string, callback: CreateDatabaseCallback): void;
167
378
  createDatabase(name: string, options: CreateDatabaseOptions, callback: CreateDatabaseCallback): void;
@@ -180,22 +391,224 @@ declare class Instance extends common.GrpcServiceObject {
180
391
  * @return {Database} A Database object.
181
392
  *
182
393
  * @example
394
+ * ```
183
395
  * const {Spanner} = require('@google-cloud/spanner');
184
396
  * const spanner = new Spanner();
185
397
  *
186
398
  * const instance = spanner.instance('my-instance');
187
399
  * const database = instance.database('my-database');
400
+ * ```
188
401
  */
189
402
  database(name: string, poolOptions?: SessionPoolOptions | SessionPoolConstructor, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions): Database;
403
+ /**
404
+ * @typedef {array} DeleteInstanceResponse
405
+ * @property {object} 0 The full API response.
406
+ */
407
+ /**
408
+ * @callback DeleteInstanceCallback
409
+ * @param {?Error} err Request error, if any.
410
+ * @param {object} apiResponse The full API response.
411
+ */
412
+ /**
413
+ * Delete the instance.
414
+ *
415
+ * Wrapper around {@link v1.InstanceAdminClient#deleteInstance}.
416
+ *
417
+ * @see {@link v1.InstanceAdminClient#deleteInstance}
418
+ * @see [DeleteInstance API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance)
419
+ *
420
+ * @param {object} [gaxOptions] Request configuration options,
421
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
422
+ * for more details.
423
+ * @param {DeleteInstanceCallback} [callback] Callback function.
424
+ * @returns {Promise<DeleteInstanceResponse>}
425
+ *
426
+ * @example
427
+ * ```
428
+ * const {Spanner} = require('@google-cloud/spanner');
429
+ * const spanner = new Spanner();
430
+ *
431
+ * const instance = spanner.instance('my-instance');
432
+ *
433
+ * instance.delete(function(err, apiResponse) {
434
+ * if (err) {
435
+ * // Error handling omitted.
436
+ * }
437
+ *
438
+ * // Instance was deleted successfully.
439
+ * });
440
+ *
441
+ * //-
442
+ * // If the callback is omitted, we'll return a Promise.
443
+ * //-
444
+ * instance.delete().then(function(data) {
445
+ * const apiResponse = data[0];
446
+ * });
447
+ * ```
448
+ */
190
449
  delete(gaxOptions?: CallOptions): Promise<DeleteInstanceResponse>;
191
450
  delete(callback: DeleteInstanceCallback): void;
192
451
  delete(gaxOptions: CallOptions, callback: DeleteInstanceCallback): void;
452
+ /**
453
+ * @typedef {array} InstanceExistsResponse
454
+ * @property {boolean} 0 Whether the {@link Instance} exists.
455
+ */
456
+ /**
457
+ * @callback InstanceExistsCallback
458
+ * @param {?Error} err Request error, if any.
459
+ * @param {boolean} exists Whether the {@link Instance} exists.
460
+ */
461
+ /**
462
+ * Check if an instance exists.
463
+ *
464
+ * @method Instance#exists
465
+ * @param {object} [gaxOptions] Request configuration options,
466
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
467
+ * for more details.
468
+ * @param {InstanceExistsCallback} [callback] Callback function.
469
+ * @returns {Promise<InstanceExistsResponse>}
470
+ *
471
+ * @example
472
+ * ```
473
+ * const {Spanner} = require('@google-cloud/spanner');
474
+ * const spanner = new Spanner();
475
+ *
476
+ * const instance = spanner.instance('my-instance');
477
+ *
478
+ * instance.exists(function(err, exists) {});
479
+ *
480
+ * //-
481
+ * // If the callback is omitted, we'll return a Promise.
482
+ * //-
483
+ * instance.exists().then(function(data) {
484
+ * const exists = data[0];
485
+ * });
486
+ * ```
487
+ */
193
488
  exists(gaxOptions?: CallOptions): Promise<ExistsInstanceResponse>;
194
489
  exists(callback: ExistsInstanceCallback): void;
195
490
  exists(gaxOptions: CallOptions, callback: ExistsInstanceCallback): void;
491
+ /**
492
+ * @typedef {array} GetInstanceResponse
493
+ * @property {Instance} 0 The {@link Instance}.
494
+ * @property {object} 1 The full API response.
495
+ */
496
+ /**
497
+ * @callback GetInstanceCallback
498
+ * @param {?Error} err Request error, if any.
499
+ * @param {Instance} instance The {@link Instance}.
500
+ * @param {object} apiResponse The full API response.
501
+ */
502
+ /**
503
+ * Get an instance if it exists.
504
+ *
505
+ * You may optionally use this to "get or create" an object by providing an
506
+ * object with `autoCreate` set to `true`. Any extra configuration that is
507
+ * normally required for the `create` method must be contained within this
508
+ * object as well.
509
+ *
510
+ * @param {options} [options] Configuration object.
511
+ * @param {boolean} [options.autoCreate=false] Automatically create the
512
+ * object if it does not exist.
513
+ * @param {string | string[]} [options.fieldNames] A list of `Instance` field
514
+ * names to be requested. Eligible values are: `name`, `displayName`,
515
+ * `endpointUris`, `labels`, `config`, `nodeCount`, `state`.
516
+ * @param {GetInstanceCallback} [callback] Callback function.
517
+ * @returns {Promise<GetInstanceResponse>}
518
+ *
519
+ * @example
520
+ * ```
521
+ * const {Spanner} = require('@google-cloud/spanner');
522
+ * const spanner = new Spanner();
523
+ *
524
+ * const instance = spanner.instance('my-instance');
525
+ *
526
+ * instance.get(function(err, instance, apiResponse) {
527
+ * // `instance.metadata` has been populated.
528
+ * });
529
+ *
530
+ * //-
531
+ * // If the callback is omitted, we'll return a Promise.
532
+ * //-
533
+ * instance.get().then(function(data) {
534
+ * const instance = data[0];
535
+ * const apiResponse = data[0];
536
+ * });
537
+ * ```
538
+ */
196
539
  get(options?: GetInstanceConfig): Promise<GetInstanceResponse>;
197
540
  get(callback: GetInstanceCallback): void;
198
541
  get(options: GetInstanceConfig, callback: GetInstanceCallback): void;
542
+ /**
543
+ * Query object for listing databases.
544
+ *
545
+ * @typedef {object} GetDatabasesRequest
546
+ * @property {number} [pageSize] Maximum number of results per page.
547
+ * @property {string} [pageToken] A previously-returned page token
548
+ * representing part of the larger set of results to view.
549
+ * @property {object} [gaxOptions] Request configuration options,
550
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
551
+ * for more details.
552
+ */
553
+ /**
554
+ * @typedef {array} GetDatabasesResponse
555
+ * @property {Database[]} 0 Array of {@link Database} instances.
556
+ * @property {object} nextQuery A query object to receive more results.
557
+ * @property {object} apiResponse The full API response.
558
+ */
559
+ /**
560
+ * @callback GetDatabasesCallback
561
+ * @param {?Error} err Request error, if any.
562
+ * @param {Database[]} databases Array of {@link Database} instances.
563
+ * @param {object} nextQuery A query object to receive more results.
564
+ * @param {object} apiResponse The full API response.
565
+ */
566
+ /**
567
+ * Get a list of databases.
568
+ *
569
+ * Wrapper around {@link v1.DatabaseAdminClient#listDatabases}.
570
+ *
571
+ * @see {@link v1.DatabaseAdminClient#listDatabases}
572
+ * @see [ListDatabases API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases)
573
+ *
574
+ * @param {GetDatabasesOptions} [options] Query object for listing databases.
575
+ * @param {GetDatabasesCallback} [callback] Callback function.
576
+ * @returns {Promise<GetDatabasesResponse>}
577
+ *
578
+ * @example
579
+ * ```
580
+ * const {Spanner} = require('@google-cloud/spanner');
581
+ * const spanner = new Spanner();
582
+ *
583
+ * const instance = spanner.instance('my-instance');
584
+ *
585
+ * instance.getDatabases(function(err, databases) {
586
+ * // `databases` is an array of `Database` objects.
587
+ * });
588
+ *
589
+ * //-
590
+ * // To control how many API requests are made and page through the results
591
+ * // manually, set `autoPaginate` to `false`.
592
+ * //-
593
+ * function callback(err, databases, nextQuery, apiResponse) {
594
+ * if (nextQuery) {
595
+ * // More results exist.
596
+ * instance.getDatabases(nextQuery, callback);
597
+ * }
598
+ * }
599
+ *
600
+ * instance.getDatabases({
601
+ * gaxOptions: {autoPaginate: false}
602
+ * }, callback);
603
+ *
604
+ * //-
605
+ * // If the callback is omitted, we'll return a Promise.
606
+ * //-
607
+ * instance.getDatabases().then(function(data) {
608
+ * const databases = data[0];
609
+ * });
610
+ * ```
611
+ */
199
612
  getDatabases(options?: GetDatabasesOptions): Promise<GetDatabasesResponse>;
200
613
  getDatabases(callback: GetDatabasesCallback): void;
201
614
  getDatabases(options: GetDatabasesOptions, callback: GetDatabasesCallback): void;
@@ -213,6 +626,7 @@ declare class Instance extends common.GrpcServiceObject {
213
626
  * instances.
214
627
  *
215
628
  * @example
629
+ * ```
216
630
  * const {Spanner} = require('@google-cloud/spanner');
217
631
  * const spanner = new Spanner();
218
632
  *
@@ -235,11 +649,121 @@ declare class Instance extends common.GrpcServiceObject {
235
649
  * .on('data', function(database) {
236
650
  * this.end();
237
651
  * });
652
+ * ```
238
653
  */
239
654
  getDatabasesStream(options?: GetDatabasesOptions): NodeJS.ReadableStream;
655
+ /**
656
+ * @typedef {array} GetInstanceMetadataResponse
657
+ * @property {object} 0 The {@link Instance} metadata.
658
+ * @property {object} 1 The full API response.
659
+ */
660
+ /**
661
+ * @callback GetInstanceMetadataCallback
662
+ * @param {?Error} err Request error, if any.
663
+ * @param {object} metadata The {@link Instance} metadata.
664
+ * @param {object} apiResponse The full API response.
665
+ */
666
+ /**
667
+ * Get the instance's metadata.
668
+ *
669
+ * Wrapper around {@link v1.InstanceAdminClient#getInstance}.
670
+ *
671
+ * @see {@link v1.InstanceAdminClient#getInstance}
672
+ * @see [GetInstance API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.GetInstance)
673
+ *
674
+ * @param {GetInstanceMetadataOptions} [options] Configuration object
675
+ * @param {string | string[]} [options.fieldNames] A list of `Instance` field
676
+ * names to be requested. Eligible values are: `name`, `displayName`,
677
+ * `endpointUris`, `labels`, `config`, `nodeCount`, `state`.
678
+ * @param {GetInstanceMetadataCallback} [callback] Callback function.
679
+ * @returns {Promise<GetInstanceMetadataResponse>}
680
+ *
681
+ * @example
682
+ * ```
683
+ * const {Spanner} = require('@google-cloud/spanner');
684
+ * const spanner = new Spanner();
685
+ *
686
+ * const instance = spanner.instance('my-instance');
687
+ *
688
+ * instance.getMetadata(function(err, metadata, apiResponse) {});
689
+ *
690
+ * //-
691
+ * // Request only `displayName`.
692
+ * //-
693
+ * instance.getMetadata({fieldNames: 'displayName'}, (err, metadata, apiResponse) => {
694
+ * // metadata will only contain value for `displayName`
695
+ * const displayName = metadata['displayName'];
696
+ * })
697
+ *
698
+ * //-
699
+ * // Request multiple specific field names.
700
+ * //-
701
+ * instance.getMetadata({fieldNames: ['displayName', 'nodeCount']}, (err, metadata, apiResponse) => {
702
+ * // metadata will only contain value for `displayName` and 'nodeCount'
703
+ * const displayName = metadata['displayName'];
704
+ * const nodeCount = metadata['nodeCount'];
705
+ * });
706
+ *
707
+ * //-
708
+ * // If the callback is omitted, we'll return a Promise.
709
+ * //-
710
+ * instance.getMetadata().then(function(data) {
711
+ * const metadata = data[0];
712
+ * const apiResponse = data[1];
713
+ * });
714
+ * ```
715
+ */
240
716
  getMetadata(options?: GetInstanceMetadataOptions): Promise<GetInstanceMetadataResponse>;
241
717
  getMetadata(callback: GetInstanceMetadataCallback): void;
242
718
  getMetadata(options: GetInstanceMetadataOptions, callback: GetInstanceMetadataCallback): void;
719
+ /**
720
+ * Update the metadata for this instance. Note that this method follows PATCH
721
+ * semantics, so previously-configured settings will persist.
722
+ *
723
+ * Wrapper around {@link v1.InstanceAdminClient#updateInstance}.
724
+ *
725
+ * @see {@link v1.InstanceAdminClient#updateInstance}
726
+ * @see [UpdateInstance API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance)
727
+ *
728
+ * @param {object} metadata The metadata you wish to set.
729
+ * @param {object} [gaxOptions] Request configuration options,
730
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
731
+ * for more details.
732
+ * @param {SetInstanceMetadataCallback} [callback] Callback function.
733
+ * @returns {Promise<LongRunningOperationResponse>}
734
+ *
735
+ * @example
736
+ * ```
737
+ * const {Spanner} = require('@google-cloud/spanner');
738
+ * const spanner = new Spanner();
739
+ *
740
+ * const instance = spanner.instance('my-instance');
741
+ *
742
+ * const metadata = {
743
+ * displayName: 'My Instance'
744
+ * };
745
+ *
746
+ * instance.setMetadata(metadata, function(err, operation, apiResponse) {
747
+ * if (err) {
748
+ * // Error handling omitted.
749
+ * }
750
+ *
751
+ * operation
752
+ * .on('error', function(err) {})
753
+ * .on('complete', function() {
754
+ * // Metadata updated successfully.
755
+ * });
756
+ * });
757
+ *
758
+ * //-
759
+ * // If the callback is omitted, we'll return a Promise.
760
+ * //-
761
+ * instance.setMetadata(metadata).then(function(data) {
762
+ * const operation = data[0];
763
+ * const apiResponse = data[1];
764
+ * });
765
+ * ```
766
+ */
243
767
  setMetadata(metadata: IInstance, gaxOptions?: CallOptions): Promise<SetInstanceMetadataResponse>;
244
768
  setMetadata(metadata: IInstance, callback: SetInstanceMetadataCallback): void;
245
769
  setMetadata(metadata: IInstance, gaxOptions: CallOptions, callback: SetInstanceMetadataCallback): void;
@@ -253,8 +777,10 @@ declare class Instance extends common.GrpcServiceObject {
253
777
  * @returns {string}
254
778
  *
255
779
  * @example
780
+ * ```
256
781
  * Instance.formatName_('grape-spaceship-123', 'my-instance');
257
782
  * // 'projects/grape-spaceship-123/instances/my-instance'
783
+ * ```
258
784
  */
259
785
  static formatName_(projectId: string, name: string): string;
260
786
  }