@google-cloud/spanner 6.4.0 → 6.6.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.
- package/CHANGELOG.md +26 -0
- package/README.md +4 -0
- package/build/src/backup.d.ts +12 -12
- package/build/src/codec.d.ts +1 -1
- package/build/src/common.d.ts +4 -4
- package/build/src/database.d.ts +210 -30
- package/build/src/database.js +89 -31
- package/build/src/index.d.ts +16 -15
- package/build/src/index.js +33 -27
- package/build/src/instance-config.d.ts +10 -10
- package/build/src/instance.d.ts +30 -30
- package/build/src/partial-result-stream.d.ts +1 -1
- package/build/src/session-pool.d.ts +65 -81
- package/build/src/session-pool.js +129 -252
- package/build/src/session.d.ts +16 -9
- package/build/src/session.js +5 -0
- package/build/src/table.d.ts +20 -20
- package/build/src/transaction-runner.d.ts +1 -1
- package/build/src/transaction-runner.js +4 -1
- package/build/src/transaction.d.ts +34 -11
- package/build/src/transaction.js +102 -13
- package/package.json +4 -4
package/build/src/database.js
CHANGED
|
@@ -141,6 +141,9 @@ class Database extends common.GrpcServiceObject {
|
|
|
141
141
|
typeof poolOptions === 'function'
|
|
142
142
|
? new poolOptions(this, null)
|
|
143
143
|
: new session_pool_1.SessionPool(this, poolOptions);
|
|
144
|
+
if (typeof poolOptions === 'object') {
|
|
145
|
+
this.databaseRole = poolOptions.databaseRole || null;
|
|
146
|
+
}
|
|
144
147
|
this.formattedName_ = formattedName_;
|
|
145
148
|
this.instance = instance;
|
|
146
149
|
this.resourceHeader_ = {
|
|
@@ -170,9 +173,10 @@ class Database extends common.GrpcServiceObject {
|
|
|
170
173
|
}
|
|
171
174
|
const count = options.count;
|
|
172
175
|
const labels = options.labels || {};
|
|
176
|
+
const databaseRole = options.databaseRole || this.databaseRole || null;
|
|
173
177
|
const reqOpts = {
|
|
174
178
|
database: this.formattedName_,
|
|
175
|
-
sessionTemplate: { labels },
|
|
179
|
+
sessionTemplate: { labels: labels, creatorRole: databaseRole },
|
|
176
180
|
sessionCount: count,
|
|
177
181
|
};
|
|
178
182
|
this.request({
|
|
@@ -241,7 +245,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
241
245
|
const options = typeof optionsOrCallback === 'object'
|
|
242
246
|
? optionsOrCallback
|
|
243
247
|
: {};
|
|
244
|
-
this.pool_.
|
|
248
|
+
this.pool_.getSession((err, session) => {
|
|
245
249
|
if (err) {
|
|
246
250
|
callback(err, null, undefined);
|
|
247
251
|
return;
|
|
@@ -265,9 +269,12 @@ class Database extends common.GrpcServiceObject {
|
|
|
265
269
|
const reqOpts = {
|
|
266
270
|
database: this.formattedName_,
|
|
267
271
|
};
|
|
272
|
+
reqOpts.session = {};
|
|
268
273
|
if (options.labels) {
|
|
269
|
-
reqOpts.session =
|
|
274
|
+
reqOpts.session.labels = options.labels;
|
|
270
275
|
}
|
|
276
|
+
reqOpts.session.creatorRole =
|
|
277
|
+
options.databaseRole || this.databaseRole || null;
|
|
271
278
|
this.request({
|
|
272
279
|
client: 'SpannerClient',
|
|
273
280
|
method: 'createSession',
|
|
@@ -425,6 +432,25 @@ class Database extends common.GrpcServiceObject {
|
|
|
425
432
|
callback(err, statements ? statements.statements : null, ...args);
|
|
426
433
|
});
|
|
427
434
|
}
|
|
435
|
+
getIamPolicy(optionsOrCallback, cb) {
|
|
436
|
+
const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
|
|
437
|
+
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
|
|
438
|
+
const reqOpts = {
|
|
439
|
+
resource: this.formattedName_,
|
|
440
|
+
options: {
|
|
441
|
+
requestedPolicyVersion: options.requestedPolicyVersion || null,
|
|
442
|
+
},
|
|
443
|
+
};
|
|
444
|
+
this.request({
|
|
445
|
+
client: 'DatabaseAdminClient',
|
|
446
|
+
method: 'getIamPolicy',
|
|
447
|
+
reqOpts,
|
|
448
|
+
gaxOpts: options.gaxOptions,
|
|
449
|
+
headers: this.resourceHeader_,
|
|
450
|
+
}, (err, resp) => {
|
|
451
|
+
callback(err, resp);
|
|
452
|
+
});
|
|
453
|
+
}
|
|
428
454
|
getSessions(optionsOrCallback, cb) {
|
|
429
455
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
430
456
|
const self = this;
|
|
@@ -539,7 +565,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
539
565
|
const options = typeof optionsOrCallback === 'object'
|
|
540
566
|
? optionsOrCallback
|
|
541
567
|
: {};
|
|
542
|
-
this.pool_.
|
|
568
|
+
this.pool_.getSession((err, session) => {
|
|
543
569
|
if (err) {
|
|
544
570
|
callback(err);
|
|
545
571
|
return;
|
|
@@ -564,7 +590,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
564
590
|
});
|
|
565
591
|
}
|
|
566
592
|
getTransaction(callback) {
|
|
567
|
-
this.pool_.
|
|
593
|
+
this.pool_.getSession((err, session, transaction) => {
|
|
568
594
|
if (!err) {
|
|
569
595
|
this._releaseOnEnd(session, transaction);
|
|
570
596
|
}
|
|
@@ -586,9 +612,38 @@ class Database extends common.GrpcServiceObject {
|
|
|
586
612
|
};
|
|
587
613
|
return this.instance.getDatabaseOperations(dbSpecificQuery);
|
|
588
614
|
}
|
|
615
|
+
getDatabaseRoles(optionsOrCallback, cb) {
|
|
616
|
+
const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
|
|
617
|
+
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
|
|
618
|
+
let reqOpts = {
|
|
619
|
+
parent: this.formattedName_,
|
|
620
|
+
};
|
|
621
|
+
// Copy over pageSize and pageToken values from gaxOptions.
|
|
622
|
+
// However, values set on options take precedence.
|
|
623
|
+
if (gaxOpts) {
|
|
624
|
+
reqOpts = extend({}, {
|
|
625
|
+
pageSize: gaxOpts.pageSize,
|
|
626
|
+
pageToken: gaxOpts.pageToken,
|
|
627
|
+
}, reqOpts);
|
|
628
|
+
delete gaxOpts.pageSize;
|
|
629
|
+
delete gaxOpts.pageToken;
|
|
630
|
+
}
|
|
631
|
+
this.request({
|
|
632
|
+
client: 'DatabaseAdminClient',
|
|
633
|
+
method: 'listDatabaseRoles',
|
|
634
|
+
reqOpts,
|
|
635
|
+
gaxOpts,
|
|
636
|
+
headers: this.resourceHeader_,
|
|
637
|
+
}, (err, roles, nextPageRequest, ...args) => {
|
|
638
|
+
const nextQuery = nextPageRequest
|
|
639
|
+
? extend({}, gaxOpts, nextPageRequest)
|
|
640
|
+
: null;
|
|
641
|
+
callback(err, roles, nextQuery, ...args);
|
|
642
|
+
});
|
|
643
|
+
}
|
|
589
644
|
makePooledRequest_(config, callback) {
|
|
590
645
|
const pool = this.pool_;
|
|
591
|
-
pool.
|
|
646
|
+
pool.getSession((err, session) => {
|
|
592
647
|
if (err) {
|
|
593
648
|
callback(err, null);
|
|
594
649
|
return;
|
|
@@ -632,7 +687,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
632
687
|
}
|
|
633
688
|
}
|
|
634
689
|
waitForSessionStream.on('reading', () => {
|
|
635
|
-
pool.
|
|
690
|
+
pool.getSession((err, session_) => {
|
|
636
691
|
if (err) {
|
|
637
692
|
destroyStream(err);
|
|
638
693
|
return;
|
|
@@ -706,7 +761,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
706
761
|
});
|
|
707
762
|
}
|
|
708
763
|
runPartitionedUpdate(query, callback) {
|
|
709
|
-
this.pool_.
|
|
764
|
+
this.pool_.getSession((err, session) => {
|
|
710
765
|
if (err) {
|
|
711
766
|
callback(err, 0);
|
|
712
767
|
return;
|
|
@@ -866,7 +921,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
866
921
|
*/
|
|
867
922
|
runStream(query, options) {
|
|
868
923
|
const proxyStream = through.obj();
|
|
869
|
-
this.pool_.
|
|
924
|
+
this.pool_.getSession((err, session) => {
|
|
870
925
|
if (err) {
|
|
871
926
|
proxyStream.destroy(err);
|
|
872
927
|
return;
|
|
@@ -915,7 +970,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
915
970
|
const options = typeof optionsOrRunFn === 'object' && optionsOrRunFn
|
|
916
971
|
? optionsOrRunFn
|
|
917
972
|
: {};
|
|
918
|
-
this.pool_.
|
|
973
|
+
this.pool_.getSession((err, session, transaction) => {
|
|
919
974
|
if (err && (0, session_pool_1.isSessionNotFoundError)(err)) {
|
|
920
975
|
this.runTransaction(options, runFn);
|
|
921
976
|
return;
|
|
@@ -1004,13 +1059,13 @@ class Database extends common.GrpcServiceObject {
|
|
|
1004
1059
|
const options = typeof optionsOrRunFn === 'object'
|
|
1005
1060
|
? optionsOrRunFn
|
|
1006
1061
|
: {};
|
|
1007
|
-
const
|
|
1062
|
+
const getSession = this.pool_.getSession.bind(this.pool_);
|
|
1008
1063
|
// Loop to retry 'Session not found' errors.
|
|
1009
1064
|
// (and yes, we like while (true) more than for (;;) here)
|
|
1010
1065
|
// eslint-disable-next-line no-constant-condition
|
|
1011
1066
|
while (true) {
|
|
1012
1067
|
try {
|
|
1013
|
-
const [session, transaction] = await (0, promisify_1.promisify)(
|
|
1068
|
+
const [session, transaction] = await (0, promisify_1.promisify)(getSession)();
|
|
1014
1069
|
transaction.requestOptions = Object.assign(transaction.requestOptions || {}, options.requestOptions);
|
|
1015
1070
|
const runner = new transaction_runner_1.AsyncTransactionRunner(session, transaction, runFn, options);
|
|
1016
1071
|
try {
|
|
@@ -1045,25 +1100,27 @@ class Database extends common.GrpcServiceObject {
|
|
|
1045
1100
|
session(name) {
|
|
1046
1101
|
return new session_1.Session(this, name);
|
|
1047
1102
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1103
|
+
setIamPolicy(policy, optionsOrCallback, cb) {
|
|
1104
|
+
const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
|
|
1105
|
+
const callback = typeof optionsOrCallback === 'function'
|
|
1106
|
+
? optionsOrCallback
|
|
1107
|
+
: cb;
|
|
1108
|
+
const gaxOpts = options;
|
|
1109
|
+
const reqOpts = {
|
|
1110
|
+
resource: this.formattedName_,
|
|
1111
|
+
policy: policy.policy,
|
|
1112
|
+
updateMask: policy.updateMask || null,
|
|
1113
|
+
};
|
|
1114
|
+
this.request({
|
|
1115
|
+
client: 'DatabaseAdminClient',
|
|
1116
|
+
method: 'setIamPolicy',
|
|
1117
|
+
reqOpts,
|
|
1118
|
+
gaxOpts: gaxOpts,
|
|
1119
|
+
headers: this.resourceHeader_,
|
|
1120
|
+
}, (err, resp) => {
|
|
1121
|
+
callback(err, resp);
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1067
1124
|
table(name) {
|
|
1068
1125
|
if (!name) {
|
|
1069
1126
|
throw new google_gax_1.GoogleError('A name is required to access a Table object.');
|
|
@@ -1155,6 +1212,7 @@ exports.Database = Database;
|
|
|
1155
1212
|
'getSessions',
|
|
1156
1213
|
'getSnapshot',
|
|
1157
1214
|
'getTransaction',
|
|
1215
|
+
'getIamPolicy',
|
|
1158
1216
|
'restore',
|
|
1159
1217
|
'run',
|
|
1160
1218
|
'runPartitionedUpdate',
|
package/build/src/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { GrpcService } from './common-grpc/service';
|
|
|
18
18
|
import { PreciseDate } from '@google-cloud/precise-date';
|
|
19
19
|
import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
|
|
20
20
|
import { common as p } from 'protobufjs';
|
|
21
|
-
import { Float, Int, Numeric, PGNumeric, PGJsonb, Struct } from './codec';
|
|
21
|
+
import { Float, Int, Numeric, PGNumeric, PGJsonb, SpannerDate, Struct } from './codec';
|
|
22
22
|
import { Backup } from './backup';
|
|
23
23
|
import { Database } from './database';
|
|
24
24
|
import { Instance, CreateInstanceCallback, CreateInstanceResponse } from './instance';
|
|
@@ -31,21 +31,21 @@ import { SessionPool } from './session-pool';
|
|
|
31
31
|
import { Table } from './table';
|
|
32
32
|
import { PartitionedDml, Snapshot, Transaction } from './transaction';
|
|
33
33
|
import * as v1 from './v1';
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
34
|
+
export type IOperation = instanceAdmin.longrunning.IOperation;
|
|
35
|
+
export type GetInstancesOptions = PagedOptionsWithFilter;
|
|
36
|
+
export type GetInstancesResponse = PagedResponse<Instance, instanceAdmin.spanner.admin.instance.v1.IListInstancesResponse>;
|
|
37
|
+
export type GetInstancesCallback = PagedCallback<Instance, instanceAdmin.spanner.admin.instance.v1.IListInstancesResponse>;
|
|
38
|
+
export type GetInstanceConfigsOptions = PagedOptions;
|
|
39
|
+
export type GetInstanceConfigsResponse = PagedResponse<instanceAdmin.spanner.admin.instance.v1.IInstanceConfig, instanceAdmin.spanner.admin.instance.v1.IListInstanceConfigsResponse>;
|
|
40
|
+
export type GetInstanceConfigsCallback = PagedCallback<instanceAdmin.spanner.admin.instance.v1.IInstanceConfig, instanceAdmin.spanner.admin.instance.v1.IListInstanceConfigsResponse>;
|
|
41
41
|
export interface GetInstanceConfigOptions {
|
|
42
42
|
gaxOptions?: CallOptions;
|
|
43
43
|
}
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
44
|
+
export type GetInstanceConfigResponse = [IInstanceConfig];
|
|
45
|
+
export type GetInstanceConfigCallback = NormalCallback<IInstanceConfig>;
|
|
46
|
+
export type GetInstanceConfigOperationsOptions = PagedOptionsWithFilter;
|
|
47
|
+
export type GetInstanceConfigOperationsResponse = PagedResponse<IOperation, instanceAdmin.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse>;
|
|
48
|
+
export type GetInstanceConfigOperationsCallback = PagedCallback<IOperation, instanceAdmin.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse>;
|
|
49
49
|
export interface SpannerOptions extends GrpcClientOptions {
|
|
50
50
|
apiEndpoint?: string;
|
|
51
51
|
servicePath?: string;
|
|
@@ -87,7 +87,7 @@ export interface CreateInstanceConfigRequest {
|
|
|
87
87
|
*
|
|
88
88
|
* @param E enum type.
|
|
89
89
|
*/
|
|
90
|
-
export
|
|
90
|
+
export type EnumKey<E extends {
|
|
91
91
|
[index: string]: unknown;
|
|
92
92
|
}> = keyof E;
|
|
93
93
|
/**
|
|
@@ -98,7 +98,7 @@ export declare type EnumKey<E extends {
|
|
|
98
98
|
* @param U name of the enum property.
|
|
99
99
|
* @param E enum type to translate.
|
|
100
100
|
*/
|
|
101
|
-
export
|
|
101
|
+
export type TranslateEnumKeys<T, U extends keyof T, E extends {
|
|
102
102
|
[index: string]: unknown;
|
|
103
103
|
}> = {
|
|
104
104
|
[P in keyof T]: P extends U ? EnumKey<E> | null | undefined : T[P];
|
|
@@ -1070,3 +1070,4 @@ declare const _default: {
|
|
|
1070
1070
|
Spanner: typeof Spanner;
|
|
1071
1071
|
};
|
|
1072
1072
|
export default _default;
|
|
1073
|
+
export { Float, Int, Struct, Numeric, PGNumeric, SpannerDate };
|
package/build/src/index.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.protos = exports.v1 = exports.Transaction = exports.Snapshot = exports.PartitionedDml = exports.Table = exports.SessionPool = exports.Session = exports.Backup = exports.Database = exports.InstanceConfig = exports.Instance = exports.Spanner = void 0;
|
|
18
|
+
exports.SpannerDate = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.protos = exports.v1 = exports.Transaction = exports.Snapshot = exports.PartitionedDml = exports.Table = exports.SessionPool = exports.Session = exports.Backup = exports.Database = exports.InstanceConfig = exports.Instance = exports.Spanner = void 0;
|
|
19
19
|
const service_1 = require("./common-grpc/service");
|
|
20
20
|
const precise_date_1 = require("@google-cloud/precise-date");
|
|
21
21
|
const projectify_1 = require("@google-cloud/projectify");
|
|
@@ -26,6 +26,12 @@ const path = require("path");
|
|
|
26
26
|
const streamEvents = require("stream-events");
|
|
27
27
|
const through = require("through2");
|
|
28
28
|
const codec_1 = require("./codec");
|
|
29
|
+
Object.defineProperty(exports, "Float", { enumerable: true, get: function () { return codec_1.Float; } });
|
|
30
|
+
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return codec_1.Int; } });
|
|
31
|
+
Object.defineProperty(exports, "Numeric", { enumerable: true, get: function () { return codec_1.Numeric; } });
|
|
32
|
+
Object.defineProperty(exports, "PGNumeric", { enumerable: true, get: function () { return codec_1.PGNumeric; } });
|
|
33
|
+
Object.defineProperty(exports, "SpannerDate", { enumerable: true, get: function () { return codec_1.SpannerDate; } });
|
|
34
|
+
Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return codec_1.Struct; } });
|
|
29
35
|
const backup_1 = require("./backup");
|
|
30
36
|
Object.defineProperty(exports, "Backup", { enumerable: true, get: function () { return backup_1.Backup; } });
|
|
31
37
|
const database_1 = require("./database");
|
|
@@ -94,6 +100,32 @@ const gcpApiConfig = require('./spanner_grpc_config.json');
|
|
|
94
100
|
* @param {ClientConfig} [options] Configuration options.
|
|
95
101
|
*/
|
|
96
102
|
class Spanner extends service_1.GrpcService {
|
|
103
|
+
/**
|
|
104
|
+
* Gets the configured Spanner emulator host from an environment variable.
|
|
105
|
+
*/
|
|
106
|
+
static getSpannerEmulatorHost() {
|
|
107
|
+
const endpointWithPort = process.env.SPANNER_EMULATOR_HOST;
|
|
108
|
+
if (endpointWithPort) {
|
|
109
|
+
if (endpointWithPort.startsWith('http:') ||
|
|
110
|
+
endpointWithPort.startsWith('https:')) {
|
|
111
|
+
throw new google_gax_1.GoogleError('SPANNER_EMULATOR_HOST must not start with a protocol specification (http/https)');
|
|
112
|
+
}
|
|
113
|
+
const index = endpointWithPort.indexOf(':');
|
|
114
|
+
if (index > -1) {
|
|
115
|
+
const portName = endpointWithPort.substring(index + 1);
|
|
116
|
+
const port = +portName;
|
|
117
|
+
if (!port || port < 1 || port > 65535) {
|
|
118
|
+
throw new google_gax_1.GoogleError(`Invalid port number: ${portName}`);
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
endpoint: endpointWithPort.substring(0, index),
|
|
122
|
+
port: +endpointWithPort.substring(index + 1),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return { endpoint: endpointWithPort };
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
97
129
|
constructor(options) {
|
|
98
130
|
const scopes = [];
|
|
99
131
|
const clientClasses = [
|
|
@@ -152,32 +184,6 @@ class Spanner extends service_1.GrpcService {
|
|
|
152
184
|
[common_1.CLOUD_RESOURCE_HEADER]: this.projectFormattedName_,
|
|
153
185
|
};
|
|
154
186
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Gets the configured Spanner emulator host from an environment variable.
|
|
157
|
-
*/
|
|
158
|
-
static getSpannerEmulatorHost() {
|
|
159
|
-
const endpointWithPort = process.env.SPANNER_EMULATOR_HOST;
|
|
160
|
-
if (endpointWithPort) {
|
|
161
|
-
if (endpointWithPort.startsWith('http:') ||
|
|
162
|
-
endpointWithPort.startsWith('https:')) {
|
|
163
|
-
throw new google_gax_1.GoogleError('SPANNER_EMULATOR_HOST must not start with a protocol specification (http/https)');
|
|
164
|
-
}
|
|
165
|
-
const index = endpointWithPort.indexOf(':');
|
|
166
|
-
if (index > -1) {
|
|
167
|
-
const portName = endpointWithPort.substring(index + 1);
|
|
168
|
-
const port = +portName;
|
|
169
|
-
if (!port || port < 1 || port > 65535) {
|
|
170
|
-
throw new google_gax_1.GoogleError(`Invalid port number: ${portName}`);
|
|
171
|
-
}
|
|
172
|
-
return {
|
|
173
|
-
endpoint: endpointWithPort.substring(0, index),
|
|
174
|
-
port: +endpointWithPort.substring(index + 1),
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
return { endpoint: endpointWithPort };
|
|
178
|
-
}
|
|
179
|
-
return undefined;
|
|
180
|
-
}
|
|
181
187
|
/** Closes this Spanner client and cleans up all resources used by it. */
|
|
182
188
|
close() {
|
|
183
189
|
this.clients_.forEach(c => {
|
|
@@ -18,20 +18,20 @@ import { Operation as GaxOperation } from 'google-gax/build/src/longRunningCalls
|
|
|
18
18
|
import { LongRunningCallback, RequestCallback, ResourceCallback, NormalCallback } from './common';
|
|
19
19
|
import { GetInstanceConfigCallback, GetInstanceConfigOptions, GetInstanceConfigResponse, RequestConfig, Spanner } from './index';
|
|
20
20
|
import { CallOptions } from 'google-gax';
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
21
|
+
export type IOperation = instanceAdmin.longrunning.IOperation;
|
|
22
|
+
export type CreateInstanceConfigCallback = LongRunningCallback<InstanceConfig>;
|
|
23
|
+
export type SetInstanceConfigMetadataCallback = ResourceCallback<GaxOperation, IOperation>;
|
|
24
|
+
export type DeleteInstanceConfigCallback = NormalCallback<instanceAdmin.protobuf.IEmpty>;
|
|
25
|
+
export type ExistsInstanceConfigCallback = NormalCallback<boolean>;
|
|
26
|
+
export type CreateInstanceConfigResponse = [
|
|
27
27
|
InstanceConfig,
|
|
28
28
|
GaxOperation,
|
|
29
29
|
IOperation
|
|
30
30
|
];
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
31
|
+
export type SetInstanceConfigMetadataResponse = [GaxOperation, IOperation];
|
|
32
|
+
export type DeleteInstanceConfigResponse = [instanceAdmin.protobuf.IEmpty];
|
|
33
|
+
export type ExistsInstanceConfigResponse = boolean;
|
|
34
|
+
export type IInstanceConfig = instanceAdmin.spanner.admin.instance.v1.IInstanceConfig;
|
|
35
35
|
interface InstanceConfigRequest {
|
|
36
36
|
(config: RequestConfig, callback: ResourceCallback<GaxOperation, IOperation>): void;
|
|
37
37
|
<T>(config: RequestConfig, callback: RequestCallback<T>): void;
|
package/build/src/instance.d.ts
CHANGED
|
@@ -28,46 +28,46 @@ import { google as instanceAdmin } from '../protos/protos';
|
|
|
28
28
|
import { google as databaseAdmin } from '../protos/protos';
|
|
29
29
|
import { google as spannerClient } from '../protos/protos';
|
|
30
30
|
import { CreateInstanceRequest } from './index';
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
31
|
+
export type IBackup = databaseAdmin.spanner.admin.database.v1.IBackup;
|
|
32
|
+
export type IDatabase = databaseAdmin.spanner.admin.database.v1.IDatabase;
|
|
33
|
+
export type IInstance = instanceAdmin.spanner.admin.instance.v1.IInstance;
|
|
34
|
+
export type IOperation = instanceAdmin.longrunning.IOperation;
|
|
35
|
+
export type CreateInstanceResponse = [Instance, GaxOperation, IOperation];
|
|
36
|
+
export type CreateDatabaseResponse = [Database, GaxOperation, IOperation];
|
|
37
|
+
export type DeleteInstanceResponse = [instanceAdmin.protobuf.IEmpty];
|
|
38
|
+
export type ExistsInstanceResponse = [boolean];
|
|
39
|
+
export type GetInstanceResponse = [Instance, IInstance];
|
|
40
|
+
export type GetInstanceMetadataResponse = [IInstance];
|
|
41
41
|
export interface GetInstanceMetadataOptions {
|
|
42
42
|
fieldNames?: string | string[];
|
|
43
43
|
gaxOptions?: CallOptions;
|
|
44
44
|
}
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
45
|
+
export type GetDatabasesResponse = PagedResponse<Database, databaseAdmin.spanner.admin.database.v1.IListDatabasesResponse>;
|
|
46
|
+
export type SetInstanceMetadataResponse = [GaxOperation, IOperation];
|
|
47
|
+
export type GetBackupsResponse = PagedResponse<Backup, databaseAdmin.spanner.admin.database.v1.IListBackupsResponse>;
|
|
48
|
+
export type GetBackupOperationsResponse = PagedResponse<IOperation, databaseAdmin.spanner.admin.database.v1.IListBackupOperationsResponse>;
|
|
49
|
+
export type GetDatabaseOperationsResponse = PagedResponse<IOperation, databaseAdmin.spanner.admin.database.v1.IListDatabaseOperationsResponse>;
|
|
50
50
|
export interface CreateDatabaseOptions extends databaseAdmin.spanner.admin.database.v1.ICreateDatabaseRequest {
|
|
51
51
|
poolOptions?: SessionPoolOptions;
|
|
52
52
|
poolCtor?: SessionPool;
|
|
53
53
|
schema?: string | string[];
|
|
54
54
|
gaxOptions?: CallOptions;
|
|
55
55
|
}
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
export
|
|
56
|
+
export type GetDatabasesOptions = PagedOptions;
|
|
57
|
+
export type CreateInstanceCallback = LongRunningCallback<Instance>;
|
|
58
|
+
export type CreateDatabaseCallback = LongRunningCallback<Database>;
|
|
59
|
+
export type DeleteInstanceCallback = NormalCallback<instanceAdmin.protobuf.IEmpty>;
|
|
60
|
+
export type ExistsInstanceCallback = NormalCallback<boolean>;
|
|
61
|
+
export type GetDatabasesCallback = RequestCallback<Database, databaseAdmin.spanner.admin.database.v1.IListDatabasesResponse>;
|
|
62
|
+
export type GetInstanceCallback = ResourceCallback<Instance, IInstance>;
|
|
63
|
+
export type GetInstanceMetadataCallback = NormalCallback<IInstance>;
|
|
64
|
+
export type SetInstanceMetadataCallback = ResourceCallback<GaxOperation, IOperation>;
|
|
65
|
+
export type GetBackupsOptions = PagedOptionsWithFilter;
|
|
66
|
+
export type GetBackupsCallback = RequestCallback<Backup, databaseAdmin.spanner.admin.database.v1.IListBackupsResponse>;
|
|
67
|
+
export type GetBackupOperationsOptions = PagedOptionsWithFilter;
|
|
68
|
+
export type GetBackupOperationsCallback = RequestCallback<IOperation, databaseAdmin.spanner.admin.database.v1.IListBackupOperationsResponse>;
|
|
69
|
+
export type GetDatabaseOperationsOptions = PagedOptionsWithFilter;
|
|
70
|
+
export type GetDatabaseOperationsCallback = RequestCallback<IOperation, databaseAdmin.spanner.admin.database.v1.IListDatabaseOperationsResponse>;
|
|
71
71
|
export interface GetInstanceConfig extends GetConfig, CreateInstanceRequest, GetInstanceMetadataOptions {
|
|
72
72
|
}
|
|
73
73
|
interface InstanceRequest {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { Readable, Transform } from 'stream';
|
|
18
18
|
import { JSONOptions, Json, Field, Value } from './codec';
|
|
19
19
|
import { google } from '../protos/protos';
|
|
20
|
-
export
|
|
20
|
+
export type ResumeToken = string | Uint8Array;
|
|
21
21
|
/**
|
|
22
22
|
* @callback RequestFunction
|
|
23
23
|
* @param {string} [resumeToken] The token used to resume getting results.
|