@google-cloud/spanner 5.15.2 → 5.16.3

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.
@@ -24,6 +24,7 @@ const extend = require("extend");
24
24
  const snakeCase = require("lodash.snakecase");
25
25
  const database_1 = require("./database");
26
26
  const common_1 = require("./common");
27
+ const google_gax_1 = require("google-gax");
27
28
  const backup_1 = require("./backup");
28
29
  /**
29
30
  * The {@link Instance} class represents a [Cloud Spanner
@@ -37,9 +38,11 @@ const backup_1 = require("./backup");
37
38
  * @param {string} name Name of the instance.
38
39
  *
39
40
  * @example
41
+ * ```
40
42
  * const {Spanner} = require('@google-cloud/spanner');
41
43
  * const spanner = new Spanner();
42
44
  * const instance = spanner.instance('my-instance');
45
+ * ```
43
46
  */
44
47
  class Instance extends common.GrpcServiceObject {
45
48
  constructor(spanner, name) {
@@ -59,6 +62,7 @@ class Instance extends common.GrpcServiceObject {
59
62
  * @returns {Promise<CreateInstanceResponse>}
60
63
  *
61
64
  * @example
65
+ * ```
62
66
  * const {Spanner} = require('@google-cloud/spanner');
63
67
  * const spanner = new Spanner();
64
68
  *
@@ -89,6 +93,7 @@ class Instance extends common.GrpcServiceObject {
89
93
  * .then(function() {
90
94
  * // Instance created successfully.
91
95
  * });
96
+ * ```
92
97
  */
93
98
  create: true,
94
99
  };
@@ -115,86 +120,25 @@ class Instance extends common.GrpcServiceObject {
115
120
  /**
116
121
  * Get a reference to a Backup object.
117
122
  *
118
- * @throws {Error} If any parameter is not provided.
123
+ * @throws {GoogleError} If any parameter is not provided.
119
124
  *
120
125
  * @param {string} backupId The name of the backup.
121
126
  * @return {Backup} A Backup object.
122
127
  *
123
128
  * @example
129
+ * ```
124
130
  * const {Spanner} = require('@google-cloud/spanner');
125
131
  * const spanner = new Spanner();
126
132
  * const instance = spanner.instance('my-instance');
127
133
  * const backup = instance.backup('my-backup');
134
+ * ```
128
135
  */
129
136
  backup(backupId) {
130
137
  if (!backupId) {
131
- throw new Error('A backup ID is required to create a Backup.');
138
+ throw new google_gax_1.GoogleError('A backup ID is required to create a Backup.');
132
139
  }
133
140
  return new backup_1.Backup(this, backupId);
134
141
  }
135
- /**
136
- * Query object for listing backups.
137
- *
138
- * @typedef {object} GetBackupsOptions
139
- * @property {string} [filter] An expression for filtering the results of the
140
- * request. Filter can be configured as outlined in
141
- * {@link v1.DatabaseAdminClient#listBackups}.
142
- * @property {number} [pageSize] Maximum number of results per page.
143
- * @property {string} [pageToken] A previously-returned page token
144
- * representing part of the larger set of results to view.
145
- * @property {object} [gaxOptions] Request configuration options,
146
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
147
- * for more details.
148
- */
149
- /**
150
- * @typedef {array} GetBackupsResponse
151
- * @property {Backup[]} 0 Array of {@link Backup} instances.
152
- * @property {object} 1 A query object to receive more results.
153
- * @property {object} 2 The full API response.
154
- */
155
- /**
156
- * @callback GetBackupsCallback
157
- * @param {?Error} err Request error, if any.
158
- * @param {Backup[]} 0 Array of {@link Backup} instances.
159
- * @param {object} nextQuery A query object to receive more results.
160
- * @param {object} apiResponse The full API response.
161
- */
162
- /**
163
- * List backups on the instance.
164
- *
165
- * Both completed and in-progress backups are listed if no filter is supplied.
166
- *
167
- * @see {@link #backup}
168
- *
169
- * @param {GetBackupsOptions} [options] The query object for listing backups.
170
- * @param {gax.CallOptions} [options.gaxOptions] The request configuration
171
- * options, See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
172
- * for more details.
173
- * @returns {Promise<GetBackupsResponse>} When resolved, contains a paged list
174
- * of backups.
175
- *
176
- * @example
177
- * const {Spanner} = require('@google-cloud/spanner');
178
- * const spanner = new Spanner();
179
- * const instance = spanner.instance('my-instance');
180
- * const [backups] = await instance.getBackups();
181
- *
182
- * //-
183
- * // To manually handle pagination, set autoPaginate:false in gaxOptions.
184
- * //-
185
- * let pageToken = undefined;
186
- * do {
187
- * const [backups, , response] = await instance.getBackups({
188
- * pageSize: 3,
189
- * pageToken,
190
- * gaxOptions: {autoPaginate: false},
191
- * });
192
- * backups.forEach(backup => {
193
- * // Do something with backup
194
- * });
195
- * pageToken = response.nextPageToken;
196
- * } while (pageToken);
197
- */
198
142
  getBackups(optionsOrCallback, cb) {
199
143
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
200
144
  const options = typeof optionsOrCallback === 'object'
@@ -250,6 +194,7 @@ class Instance extends common.GrpcServiceObject {
250
194
  * instances.
251
195
  *
252
196
  * @example
197
+ * ```
253
198
  * const {Spanner} = require('@google-cloud/spanner');
254
199
  * const spanner = new Spanner();
255
200
  *
@@ -272,6 +217,7 @@ class Instance extends common.GrpcServiceObject {
272
217
  * .on('data', function(database) {
273
218
  * this.end();
274
219
  * });
220
+ * ```
275
221
  */
276
222
  getBackupsStream(options = {}) {
277
223
  const gaxOpts = extend(true, {}, options.gaxOptions);
@@ -297,33 +243,6 @@ class Instance extends common.GrpcServiceObject {
297
243
  headers: this.resourceHeader_,
298
244
  });
299
245
  }
300
- /**
301
- * Query object for listing backup operations.
302
- *
303
- * @typedef {object} GetBackupOperationsOptions
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#listBackupOperations}.
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} GetBackupOperationsResponse
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 GetBackupOperationsCallback
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
246
  /**
328
247
  * List pending and completed backup operations for all databases in the instance.
329
248
  *
@@ -338,6 +257,7 @@ class Instance extends common.GrpcServiceObject {
338
257
  * paged list of backup operations.
339
258
  *
340
259
  * @example
260
+ * ```
341
261
  * const {Spanner} = require('@google-cloud/spanner');
342
262
  * const spanner = new Spanner();
343
263
  * const instance = spanner.instance('my-instance');
@@ -358,6 +278,7 @@ class Instance extends common.GrpcServiceObject {
358
278
  * });
359
279
  * pageToken = response.nextPageToken;
360
280
  * } while (pageToken);
281
+ * ```
361
282
  */
362
283
  getBackupOperations(optionsOrCallback, cb) {
363
284
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -392,33 +313,6 @@ class Instance extends common.GrpcServiceObject {
392
313
  callback(err, operations, nextQuery, ...args);
393
314
  });
394
315
  }
395
- /**
396
- * Query object for listing database operations.
397
- *
398
- * @typedef {object} GetDatabaseOperationsOptions
399
- * @property {string} [filter] An expression for filtering the results of the
400
- * request. Filter can be configured as outlined in
401
- * {@link v1.DatabaseAdminClient#listDatabaseOperations}.
402
- * @property {number} [pageSize] Maximum number of results per page.
403
- * @property {string} [pageToken] A previously-returned page token
404
- * representing part of the larger set of results to view.
405
- * @property {object} [gaxOptions] Request configuration options,
406
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
407
- * for more details.
408
- */
409
- /**
410
- * @typedef {array} GetDatabaseOperationsResponse
411
- * @property {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
412
- * @property {object} 1 A query object to receive more results.
413
- * @property {object} 2 The full API response.
414
- */
415
- /**
416
- * @callback GetDatabaseOperationsCallback
417
- * @param {?Error} err Request error, if any.
418
- * @param {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
419
- * @param {object} nextQuery A query object to receive more results.
420
- * @param {object} apiResponse The full API response.
421
- */
422
316
  /**
423
317
  * List pending and completed operations for all databases in the instance.
424
318
  *
@@ -433,6 +327,7 @@ class Instance extends common.GrpcServiceObject {
433
327
  * paged list of database operations.
434
328
  *
435
329
  * @example
330
+ * ```
436
331
  * const {Spanner} = require('@google-cloud/spanner');
437
332
  * const spanner = new Spanner();
438
333
  * const instance = spanner.instance('my-instance');
@@ -454,6 +349,7 @@ class Instance extends common.GrpcServiceObject {
454
349
  * });
455
350
  * pageToken = response.nextPageToken;
456
351
  * } while (pageToken);
352
+ * ```
457
353
  */
458
354
  getDatabaseOperations(optionsOrCallback, cb) {
459
355
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -488,93 +384,9 @@ class Instance extends common.GrpcServiceObject {
488
384
  callback(err, operations, nextQuery, ...args);
489
385
  });
490
386
  }
491
- /**
492
- * Config for the new database.
493
- *
494
- * @typedef {object} CreateDatabaseRequest
495
- * @property {SessionPoolOptions} [poolOptions]
496
- * @property {SessionPoolCtor} [poolCtor]
497
- */
498
- /**
499
- * @typedef {array} CreateDatabaseResponse
500
- * @property {Database} 0 The new {@link Database}.
501
- * @property {google.longrunning.Operation} 1 An {@link Operation} object that can be used to check
502
- * the status of the request.
503
- * @property {object} 2 The full API response.
504
- */
505
- /**
506
- * @callback CreateDatabaseCallback
507
- * @param {?Error} err Request error, if any.
508
- * @param {Database} database The new {@link Database}.
509
- * @param {google.longrunning.Operation} operation An {@link Operation} object that can be used to
510
- * check the status of the request.
511
- * @param {object} apiResponse The full API response.
512
- */
513
- /**
514
- * Create a database in this instance.
515
- *
516
- * Wrapper around {@link v1.DatabaseAdminClient#createDatabase}.
517
- *
518
- * @see {@link v1.DatabaseAdminClient#createDatabase}
519
- * @see [CreateDatabase API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase)
520
- *
521
- * @throws {Error} If a name is not provided.
522
- *
523
- * @param {name} name The name of the database to create.
524
- * @param {CreateDatabaseRequest} [options] Configuration object.
525
- * @param {CreateDatabaseCallback} [callback] Callback function.
526
- * @returns {Promise<CreateDatabaseResponse>}
527
- *
528
- * @example
529
- * const {Spanner} = require('@google-cloud/spanner');
530
- * const spanner = new Spanner();
531
- *
532
- * const instance = spanner.instance('my-instance');
533
- *
534
- * function callback(err, database, operation, apiResponse) {
535
- * if (err) {
536
- * // Error handling omitted.
537
- * }
538
- *
539
- * operation
540
- * .on('error', function(err) {})
541
- * .on('complete', function() {
542
- * // Database created successfully.
543
- * });
544
- * }
545
- *
546
- * instance.createDatabase('new-database-name', callback);
547
- *
548
- * //-
549
- * // Set the schema for the database.
550
- * //-
551
- * instance.createDatabase('new-database-name', {
552
- * schema:
553
- * 'CREATE TABLE Singers (' +
554
- * ' SingerId STRING(1024) NOT NULL,' +
555
- * ' Name STRING(1024),' +
556
- * ') PRIMARY KEY(SingerId)'
557
- * }, callback);
558
- * //-
559
- * // If the callback is omitted, we'll return a Promise.
560
- * //-
561
- * instance.createDatabase('new-database-name')
562
- * .then(function(data) {
563
- * const database = data[0];
564
- * const operation = data[1];
565
- * return operation.promise();
566
- * })
567
- * .then(function() {
568
- * // Database created successfully.
569
- * });
570
- *
571
- * @example <caption>include:samples/schema.js</caption>
572
- * region_tag:spanner_create_database
573
- * Full example:
574
- */
575
387
  createDatabase(name, optionsOrCallback, cb) {
576
388
  if (!name) {
577
- throw new Error('A name is required to create a database.');
389
+ throw new google_gax_1.GoogleError('A name is required to create a database.');
578
390
  }
579
391
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
580
392
  const options = typeof optionsOrCallback === 'object'
@@ -611,7 +423,7 @@ class Instance extends common.GrpcServiceObject {
611
423
  /**
612
424
  * Get a reference to a Database object.
613
425
  *
614
- * @throws {Error} If a name is not provided.
426
+ * @throws {GoogleError} If a name is not provided.
615
427
  *
616
428
  * @param {string} name The name of the instance.
617
429
  * @param {SessionPoolOptions|SessionPoolCtor} [poolOptions] Session pool
@@ -623,15 +435,17 @@ class Instance extends common.GrpcServiceObject {
623
435
  * @return {Database} A Database object.
624
436
  *
625
437
  * @example
438
+ * ```
626
439
  * const {Spanner} = require('@google-cloud/spanner');
627
440
  * const spanner = new Spanner();
628
441
  *
629
442
  * const instance = spanner.instance('my-instance');
630
443
  * const database = instance.database('my-database');
444
+ * ```
631
445
  */
632
446
  database(name, poolOptions, queryOptions) {
633
447
  if (!name) {
634
- throw new Error('A name is required to access a Database object.');
448
+ throw new google_gax_1.GoogleError('A name is required to access a Database object.');
635
449
  }
636
450
  // Only add an additional key for SessionPoolOptions and QueryOptions if an
637
451
  // options object with at least one value was passed in.
@@ -648,50 +462,6 @@ class Instance extends common.GrpcServiceObject {
648
462
  }
649
463
  return this.databases_.get(key);
650
464
  }
651
- /**
652
- * @typedef {array} DeleteInstanceResponse
653
- * @property {object} 0 The full API response.
654
- */
655
- /**
656
- * @callback DeleteInstanceCallback
657
- * @param {?Error} err Request error, if any.
658
- * @param {object} apiResponse The full API response.
659
- */
660
- /**
661
- * Delete the instance.
662
- *
663
- * Wrapper around {@link v1.InstanceAdminClient#deleteInstance}.
664
- *
665
- * @see {@link v1.InstanceAdminClient#deleteInstance}
666
- * @see [DeleteInstance API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance)
667
- *
668
- * @param {object} [gaxOptions] Request configuration options,
669
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
670
- * for more details.
671
- * @param {DeleteInstanceCallback} [callback] Callback function.
672
- * @returns {Promise<DeleteInstanceResponse>}
673
- *
674
- * @example
675
- * const {Spanner} = require('@google-cloud/spanner');
676
- * const spanner = new Spanner();
677
- *
678
- * const instance = spanner.instance('my-instance');
679
- *
680
- * instance.delete(function(err, apiResponse) {
681
- * if (err) {
682
- * // Error handling omitted.
683
- * }
684
- *
685
- * // Instance was deleted successfully.
686
- * });
687
- *
688
- * //-
689
- * // If the callback is omitted, we'll return a Promise.
690
- * //-
691
- * instance.delete().then(function(data) {
692
- * const apiResponse = data[0];
693
- * });
694
- */
695
465
  delete(optionsOrCallback, cb) {
696
466
  const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
697
467
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -718,40 +488,6 @@ class Instance extends common.GrpcServiceObject {
718
488
  });
719
489
  });
720
490
  }
721
- /**
722
- * @typedef {array} InstanceExistsResponse
723
- * @property {boolean} 0 Whether the {@link Instance} exists.
724
- */
725
- /**
726
- * @callback InstanceExistsCallback
727
- * @param {?Error} err Request error, if any.
728
- * @param {boolean} exists Whether the {@link Instance} exists.
729
- */
730
- /**
731
- * Check if an instance exists.
732
- *
733
- * @method Instance#exists
734
- * @param {object} [gaxOptions] Request configuration options,
735
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
736
- * for more details.
737
- * @param {InstanceExistsCallback} [callback] Callback function.
738
- * @returns {Promise<InstanceExistsResponse>}
739
- *
740
- * @example
741
- * const {Spanner} = require('@google-cloud/spanner');
742
- * const spanner = new Spanner();
743
- *
744
- * const instance = spanner.instance('my-instance');
745
- *
746
- * instance.exists(function(err, exists) {});
747
- *
748
- * //-
749
- * // If the callback is omitted, we'll return a Promise.
750
- * //-
751
- * instance.exists().then(function(data) {
752
- * const exists = data[0];
753
- * });
754
- */
755
491
  exists(optionsOrCallback, cb) {
756
492
  const gaxOptions = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
757
493
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -765,52 +501,6 @@ class Instance extends common.GrpcServiceObject {
765
501
  callback(null, exists);
766
502
  });
767
503
  }
768
- /**
769
- * @typedef {array} GetInstanceResponse
770
- * @property {Instance} 0 The {@link Instance}.
771
- * @property {object} 1 The full API response.
772
- */
773
- /**
774
- * @callback GetInstanceCallback
775
- * @param {?Error} err Request error, if any.
776
- * @param {Instance} instance The {@link Instance}.
777
- * @param {object} apiResponse The full API response.
778
- */
779
- /**
780
- * Get an instance if it exists.
781
- *
782
- * You may optionally use this to "get or create" an object by providing an
783
- * object with `autoCreate` set to `true`. Any extra configuration that is
784
- * normally required for the `create` method must be contained within this
785
- * object as well.
786
- *
787
- * @param {options} [options] Configuration object.
788
- * @param {boolean} [options.autoCreate=false] Automatically create the
789
- * object if it does not exist.
790
- * @param {string | string[]} [options.fieldNames] A list of `Instance` field
791
- * names to be requested. Eligible values are: `name`, `displayName`,
792
- * `endpointUris`, `labels`, `config`, `nodeCount`, `state`.
793
- * @param {GetInstanceCallback} [callback] Callback function.
794
- * @returns {Promise<GetInstanceResponse>}
795
- *
796
- * @example
797
- * const {Spanner} = require('@google-cloud/spanner');
798
- * const spanner = new Spanner();
799
- *
800
- * const instance = spanner.instance('my-instance');
801
- *
802
- * instance.get(function(err, instance, apiResponse) {
803
- * // `instance.metadata` has been populated.
804
- * });
805
- *
806
- * //-
807
- * // If the callback is omitted, we'll return a Promise.
808
- * //-
809
- * instance.get().then(function(data) {
810
- * const instance = data[0];
811
- * const apiResponse = data[0];
812
- * });
813
- */
814
504
  get(optionsOrCallback, cb) {
815
505
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
816
506
  const options = typeof optionsOrCallback === 'object'
@@ -849,74 +539,6 @@ class Instance extends common.GrpcServiceObject {
849
539
  callback(null, this, metadata);
850
540
  });
851
541
  }
852
- /**
853
- * Query object for listing databases.
854
- *
855
- * @typedef {object} GetDatabasesRequest
856
- * @property {number} [pageSize] Maximum number of results per page.
857
- * @property {string} [pageToken] A previously-returned page token
858
- * representing part of the larger set of results to view.
859
- * @property {object} [gaxOptions] Request configuration options,
860
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
861
- * for more details.
862
- */
863
- /**
864
- * @typedef {array} GetDatabasesResponse
865
- * @property {Database[]} 0 Array of {@link Database} instances.
866
- * @property {object} nextQuery A query object to receive more results.
867
- * @property {object} apiResponse The full API response.
868
- */
869
- /**
870
- * @callback GetDatabasesCallback
871
- * @param {?Error} err Request error, if any.
872
- * @param {Database[]} databases Array of {@link Database} instances.
873
- * @param {object} nextQuery A query object to receive more results.
874
- * @param {object} apiResponse The full API response.
875
- */
876
- /**
877
- * Get a list of databases.
878
- *
879
- * Wrapper around {@link v1.DatabaseAdminClient#listDatabases}.
880
- *
881
- * @see {@link v1.DatabaseAdminClient#listDatabases}
882
- * @see [ListDatabases API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases)
883
- *
884
- * @param {GetDatabasesOptions} [options] Query object for listing databases.
885
- * @param {GetDatabasesCallback} [callback] Callback function.
886
- * @returns {Promise<GetDatabasesResponse>}
887
- *
888
- * @example
889
- * const {Spanner} = require('@google-cloud/spanner');
890
- * const spanner = new Spanner();
891
- *
892
- * const instance = spanner.instance('my-instance');
893
- *
894
- * instance.getDatabases(function(err, databases) {
895
- * // `databases` is an array of `Database` objects.
896
- * });
897
- *
898
- * //-
899
- * // To control how many API requests are made and page through the results
900
- * // manually, set `autoPaginate` to `false`.
901
- * //-
902
- * function callback(err, databases, nextQuery, apiResponse) {
903
- * if (nextQuery) {
904
- * // More results exist.
905
- * instance.getDatabases(nextQuery, callback);
906
- * }
907
- * }
908
- *
909
- * instance.getDatabases({
910
- * gaxOptions: {autoPaginate: false}
911
- * }, callback);
912
- *
913
- * //-
914
- * // If the callback is omitted, we'll return a Promise.
915
- * //-
916
- * instance.getDatabases().then(function(data) {
917
- * const databases = data[0];
918
- * });
919
- */
920
542
  getDatabases(optionsOrCallback, cb) {
921
543
  // eslint-disable-next-line @typescript-eslint/no-this-alias
922
544
  const self = this;
@@ -974,6 +596,7 @@ class Instance extends common.GrpcServiceObject {
974
596
  * instances.
975
597
  *
976
598
  * @example
599
+ * ```
977
600
  * const {Spanner} = require('@google-cloud/spanner');
978
601
  * const spanner = new Spanner();
979
602
  *
@@ -996,6 +619,7 @@ class Instance extends common.GrpcServiceObject {
996
619
  * .on('data', function(database) {
997
620
  * this.end();
998
621
  * });
622
+ * ```
999
623
  */
1000
624
  getDatabasesStream(options = {}) {
1001
625
  const gaxOpts = extend(true, {}, options.gaxOptions);
@@ -1021,65 +645,6 @@ class Instance extends common.GrpcServiceObject {
1021
645
  headers: this.resourceHeader_,
1022
646
  });
1023
647
  }
1024
- /**
1025
- * @typedef {array} GetInstanceMetadataResponse
1026
- * @property {object} 0 The {@link Instance} metadata.
1027
- * @property {object} 1 The full API response.
1028
- */
1029
- /**
1030
- * @callback GetInstanceMetadataCallback
1031
- * @param {?Error} err Request error, if any.
1032
- * @param {object} metadata The {@link Instance} metadata.
1033
- * @param {object} apiResponse The full API response.
1034
- */
1035
- /**
1036
- * Get the instance's metadata.
1037
- *
1038
- * Wrapper around {@link v1.InstanceAdminClient#getInstance}.
1039
- *
1040
- * @see {@link v1.InstanceAdminClient#getInstance}
1041
- * @see [GetInstance API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.GetInstance)
1042
- *
1043
- * @param {GetInstanceMetadataOptions} [options] Configuration object
1044
- * @param {string | string[]} [options.fieldNames] A list of `Instance` field
1045
- * names to be requested. Eligible values are: `name`, `displayName`,
1046
- * `endpointUris`, `labels`, `config`, `nodeCount`, `state`.
1047
- * @param {GetInstanceMetadataCallback} [callback] Callback function.
1048
- * @returns {Promise<GetInstanceMetadataResponse>}
1049
- *
1050
- * @example
1051
- * const {Spanner} = require('@google-cloud/spanner');
1052
- * const spanner = new Spanner();
1053
- *
1054
- * const instance = spanner.instance('my-instance');
1055
- *
1056
- * instance.getMetadata(function(err, metadata, apiResponse) {});
1057
- *
1058
- * //-
1059
- * // Request only `displayName`.
1060
- * //-
1061
- * instance.getMetadata({fieldNames: 'displayName'}, (err, metadata, apiResponse) => {
1062
- * // metadata will only contain value for `displayName`
1063
- * const displayName = metadata['displayName'];
1064
- * })
1065
- *
1066
- * //-
1067
- * // Request multiple specific field names.
1068
- * //-
1069
- * instance.getMetadata({fieldNames: ['displayName', 'nodeCount']}, (err, metadata, apiResponse) => {
1070
- * // metadata will only contain value for `displayName` and 'nodeCount'
1071
- * const displayName = metadata['displayName'];
1072
- * const nodeCount = metadata['nodeCount'];
1073
- * });
1074
- *
1075
- * //-
1076
- * // If the callback is omitted, we'll return a Promise.
1077
- * //-
1078
- * instance.getMetadata().then(function(data) {
1079
- * const metadata = data[0];
1080
- * const apiResponse = data[1];
1081
- * });
1082
- */
1083
648
  getMetadata(optionsOrCallback, cb) {
1084
649
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
1085
650
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
@@ -1104,52 +669,6 @@ class Instance extends common.GrpcServiceObject {
1104
669
  callback(err, resp);
1105
670
  });
1106
671
  }
1107
- /**
1108
- * Update the metadata for this instance. Note that this method follows PATCH
1109
- * semantics, so previously-configured settings will persist.
1110
- *
1111
- * Wrapper around {@link v1.InstanceAdminClient#updateInstance}.
1112
- *
1113
- * @see {@link v1.InstanceAdminClient#updateInstance}
1114
- * @see [UpdateInstance API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance)
1115
- *
1116
- * @param {object} metadata The metadata you wish to set.
1117
- * @param {object} [gaxOptions] Request configuration options,
1118
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1119
- * for more details.
1120
- * @param {SetInstanceMetadataCallback} [callback] Callback function.
1121
- * @returns {Promise<LongRunningOperationResponse>}
1122
- *
1123
- * @example
1124
- * const {Spanner} = require('@google-cloud/spanner');
1125
- * const spanner = new Spanner();
1126
- *
1127
- * const instance = spanner.instance('my-instance');
1128
- *
1129
- * const metadata = {
1130
- * displayName: 'My Instance'
1131
- * };
1132
- *
1133
- * instance.setMetadata(metadata, function(err, operation, apiResponse) {
1134
- * if (err) {
1135
- * // Error handling omitted.
1136
- * }
1137
- *
1138
- * operation
1139
- * .on('error', function(err) {})
1140
- * .on('complete', function() {
1141
- * // Metadata updated successfully.
1142
- * });
1143
- * });
1144
- *
1145
- * //-
1146
- * // If the callback is omitted, we'll return a Promise.
1147
- * //-
1148
- * instance.setMetadata(metadata).then(function(data) {
1149
- * const operation = data[0];
1150
- * const apiResponse = data[1];
1151
- * });
1152
- */
1153
672
  setMetadata(metadata, optionsOrCallback, cb) {
1154
673
  const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
1155
674
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -1179,8 +698,10 @@ class Instance extends common.GrpcServiceObject {
1179
698
  * @returns {string}
1180
699
  *
1181
700
  * @example
701
+ * ```
1182
702
  * Instance.formatName_('grape-spaceship-123', 'my-instance');
1183
703
  * // 'projects/grape-spaceship-123/instances/my-instance'
704
+ * ```
1184
705
  */
1185
706
  static formatName_(projectId, name) {
1186
707
  if (name.indexOf('/') > -1) {