@google-cloud/spanner 5.14.0 → 5.16.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.
@@ -37,9 +37,11 @@ const backup_1 = require("./backup");
37
37
  * @param {string} name Name of the instance.
38
38
  *
39
39
  * @example
40
+ * ```
40
41
  * const {Spanner} = require('@google-cloud/spanner');
41
42
  * const spanner = new Spanner();
42
43
  * const instance = spanner.instance('my-instance');
44
+ * ```
43
45
  */
44
46
  class Instance extends common.GrpcServiceObject {
45
47
  constructor(spanner, name) {
@@ -59,6 +61,7 @@ class Instance extends common.GrpcServiceObject {
59
61
  * @returns {Promise<CreateInstanceResponse>}
60
62
  *
61
63
  * @example
64
+ * ```
62
65
  * const {Spanner} = require('@google-cloud/spanner');
63
66
  * const spanner = new Spanner();
64
67
  *
@@ -89,6 +92,7 @@ class Instance extends common.GrpcServiceObject {
89
92
  * .then(function() {
90
93
  * // Instance created successfully.
91
94
  * });
95
+ * ```
92
96
  */
93
97
  create: true,
94
98
  };
@@ -121,10 +125,12 @@ class Instance extends common.GrpcServiceObject {
121
125
  * @return {Backup} A Backup object.
122
126
  *
123
127
  * @example
128
+ * ```
124
129
  * const {Spanner} = require('@google-cloud/spanner');
125
130
  * const spanner = new Spanner();
126
131
  * const instance = spanner.instance('my-instance');
127
132
  * const backup = instance.backup('my-backup');
133
+ * ```
128
134
  */
129
135
  backup(backupId) {
130
136
  if (!backupId) {
@@ -132,69 +138,6 @@ class Instance extends common.GrpcServiceObject {
132
138
  }
133
139
  return new backup_1.Backup(this, backupId);
134
140
  }
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
141
  getBackups(optionsOrCallback, cb) {
199
142
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
200
143
  const options = typeof optionsOrCallback === 'object'
@@ -250,6 +193,7 @@ class Instance extends common.GrpcServiceObject {
250
193
  * instances.
251
194
  *
252
195
  * @example
196
+ * ```
253
197
  * const {Spanner} = require('@google-cloud/spanner');
254
198
  * const spanner = new Spanner();
255
199
  *
@@ -272,6 +216,7 @@ class Instance extends common.GrpcServiceObject {
272
216
  * .on('data', function(database) {
273
217
  * this.end();
274
218
  * });
219
+ * ```
275
220
  */
276
221
  getBackupsStream(options = {}) {
277
222
  const gaxOpts = extend(true, {}, options.gaxOptions);
@@ -297,33 +242,6 @@ class Instance extends common.GrpcServiceObject {
297
242
  headers: this.resourceHeader_,
298
243
  });
299
244
  }
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
245
  /**
328
246
  * List pending and completed backup operations for all databases in the instance.
329
247
  *
@@ -338,6 +256,7 @@ class Instance extends common.GrpcServiceObject {
338
256
  * paged list of backup operations.
339
257
  *
340
258
  * @example
259
+ * ```
341
260
  * const {Spanner} = require('@google-cloud/spanner');
342
261
  * const spanner = new Spanner();
343
262
  * const instance = spanner.instance('my-instance');
@@ -358,6 +277,7 @@ class Instance extends common.GrpcServiceObject {
358
277
  * });
359
278
  * pageToken = response.nextPageToken;
360
279
  * } while (pageToken);
280
+ * ```
361
281
  */
362
282
  getBackupOperations(optionsOrCallback, cb) {
363
283
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -392,33 +312,6 @@ class Instance extends common.GrpcServiceObject {
392
312
  callback(err, operations, nextQuery, ...args);
393
313
  });
394
314
  }
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
315
  /**
423
316
  * List pending and completed operations for all databases in the instance.
424
317
  *
@@ -433,6 +326,7 @@ class Instance extends common.GrpcServiceObject {
433
326
  * paged list of database operations.
434
327
  *
435
328
  * @example
329
+ * ```
436
330
  * const {Spanner} = require('@google-cloud/spanner');
437
331
  * const spanner = new Spanner();
438
332
  * const instance = spanner.instance('my-instance');
@@ -454,6 +348,7 @@ class Instance extends common.GrpcServiceObject {
454
348
  * });
455
349
  * pageToken = response.nextPageToken;
456
350
  * } while (pageToken);
351
+ * ```
457
352
  */
458
353
  getDatabaseOperations(optionsOrCallback, cb) {
459
354
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -488,90 +383,6 @@ class Instance extends common.GrpcServiceObject {
488
383
  callback(err, operations, nextQuery, ...args);
489
384
  });
490
385
  }
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
386
  createDatabase(name, optionsOrCallback, cb) {
576
387
  if (!name) {
577
388
  throw new Error('A name is required to create a database.');
@@ -623,11 +434,13 @@ class Instance extends common.GrpcServiceObject {
623
434
  * @return {Database} A Database object.
624
435
  *
625
436
  * @example
437
+ * ```
626
438
  * const {Spanner} = require('@google-cloud/spanner');
627
439
  * const spanner = new Spanner();
628
440
  *
629
441
  * const instance = spanner.instance('my-instance');
630
442
  * const database = instance.database('my-database');
443
+ * ```
631
444
  */
632
445
  database(name, poolOptions, queryOptions) {
633
446
  if (!name) {
@@ -648,50 +461,6 @@ class Instance extends common.GrpcServiceObject {
648
461
  }
649
462
  return this.databases_.get(key);
650
463
  }
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
464
  delete(optionsOrCallback, cb) {
696
465
  const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
697
466
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -718,40 +487,6 @@ class Instance extends common.GrpcServiceObject {
718
487
  });
719
488
  });
720
489
  }
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
490
  exists(optionsOrCallback, cb) {
756
491
  const gaxOptions = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
757
492
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -765,52 +500,6 @@ class Instance extends common.GrpcServiceObject {
765
500
  callback(null, exists);
766
501
  });
767
502
  }
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
503
  get(optionsOrCallback, cb) {
815
504
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
816
505
  const options = typeof optionsOrCallback === 'object'
@@ -849,74 +538,6 @@ class Instance extends common.GrpcServiceObject {
849
538
  callback(null, this, metadata);
850
539
  });
851
540
  }
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
541
  getDatabases(optionsOrCallback, cb) {
921
542
  // eslint-disable-next-line @typescript-eslint/no-this-alias
922
543
  const self = this;
@@ -974,6 +595,7 @@ class Instance extends common.GrpcServiceObject {
974
595
  * instances.
975
596
  *
976
597
  * @example
598
+ * ```
977
599
  * const {Spanner} = require('@google-cloud/spanner');
978
600
  * const spanner = new Spanner();
979
601
  *
@@ -996,6 +618,7 @@ class Instance extends common.GrpcServiceObject {
996
618
  * .on('data', function(database) {
997
619
  * this.end();
998
620
  * });
621
+ * ```
999
622
  */
1000
623
  getDatabasesStream(options = {}) {
1001
624
  const gaxOpts = extend(true, {}, options.gaxOptions);
@@ -1021,65 +644,6 @@ class Instance extends common.GrpcServiceObject {
1021
644
  headers: this.resourceHeader_,
1022
645
  });
1023
646
  }
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
647
  getMetadata(optionsOrCallback, cb) {
1084
648
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
1085
649
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
@@ -1104,52 +668,6 @@ class Instance extends common.GrpcServiceObject {
1104
668
  callback(err, resp);
1105
669
  });
1106
670
  }
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
671
  setMetadata(metadata, optionsOrCallback, cb) {
1154
672
  const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
1155
673
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -1179,8 +697,10 @@ class Instance extends common.GrpcServiceObject {
1179
697
  * @returns {string}
1180
698
  *
1181
699
  * @example
700
+ * ```
1182
701
  * Instance.formatName_('grape-spaceship-123', 'my-instance');
1183
702
  * // 'projects/grape-spaceship-123/instances/my-instance'
703
+ * ```
1184
704
  */
1185
705
  static formatName_(projectId, name) {
1186
706
  if (name.indexOf('/') > -1) {