@google-cloud/spanner 7.18.0 → 7.18.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.
- package/CHANGELOG.md +7 -0
- package/README.md +1 -0
- package/build/protos/google/spanner/admin/database/v1/backup.proto +757 -0
- package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +230 -0
- package/build/protos/google/spanner/admin/database/v1/common.proto +132 -0
- package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +1209 -0
- package/build/protos/google/spanner/admin/instance/v1/common.proto +64 -0
- package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +2110 -0
- package/build/protos/google/spanner/executor/v1/cloud_executor.proto +1520 -0
- package/build/protos/google/spanner/v1/commit_response.proto +59 -0
- package/build/protos/google/spanner/v1/keys.proto +163 -0
- package/build/protos/google/spanner/v1/mutation.proto +107 -0
- package/build/protos/google/spanner/v1/query_plan.proto +128 -0
- package/build/protos/google/spanner/v1/result_set.proto +237 -0
- package/build/protos/google/spanner/v1/spanner.proto +1389 -0
- package/build/protos/google/spanner/v1/transaction.proto +575 -0
- package/build/protos/google/spanner/v1/type.proto +214 -0
- package/build/protos/protos.d.ts +39317 -0
- package/build/protos/protos.js +100360 -0
- package/build/protos/protos.json +10271 -0
- package/build/src/backup.d.ts +349 -0
- package/build/src/backup.js +246 -0
- package/build/src/batch-transaction.d.ts +247 -0
- package/build/src/batch-transaction.js +384 -0
- package/build/src/codec.d.ts +362 -0
- package/build/src/codec.js +791 -0
- package/build/src/common-grpc/service-object.d.ts +80 -0
- package/build/src/common-grpc/service-object.js +101 -0
- package/build/src/common-grpc/service.d.ts +445 -0
- package/build/src/common-grpc/service.js +826 -0
- package/build/src/common.d.ts +66 -0
- package/build/src/common.js +54 -0
- package/build/src/database.d.ts +2103 -0
- package/build/src/database.js +1655 -0
- package/build/src/extra_proto_list.json +1 -0
- package/build/src/helper.d.ts +45 -0
- package/build/src/helper.js +71 -0
- package/build/src/index.d.ts +1195 -0
- package/build/src/index.js +1059 -0
- package/build/src/instance-config.d.ts +294 -0
- package/build/src/instance-config.js +216 -0
- package/build/src/instance.d.ts +832 -0
- package/build/src/instance.js +781 -0
- package/build/src/instrument.d.ts +85 -0
- package/build/src/instrument.js +215 -0
- package/build/src/multiplexed-session.d.ts +136 -0
- package/build/src/multiplexed-session.js +197 -0
- package/build/src/partial-result-stream.d.ts +253 -0
- package/build/src/partial-result-stream.js +400 -0
- package/build/src/session-factory.d.ts +100 -0
- package/build/src/session-factory.js +93 -0
- package/build/src/session-pool.d.ts +471 -0
- package/build/src/session-pool.js +754 -0
- package/build/src/session.d.ts +258 -0
- package/build/src/session.js +348 -0
- package/build/src/spanner_grpc_config.json +92 -0
- package/build/src/table.d.ts +831 -0
- package/build/src/table.js +277 -0
- package/build/src/transaction-runner.d.ts +185 -0
- package/build/src/transaction-runner.js +282 -0
- package/build/src/transaction.d.ts +1691 -0
- package/build/src/transaction.js +2004 -0
- package/build/src/v1/database_admin_client.d.ts +2301 -0
- package/build/src/v1/database_admin_client.js +2286 -0
- package/build/src/v1/database_admin_client_config.json +160 -0
- package/build/src/v1/database_admin_proto_list.json +6 -0
- package/build/src/v1/gapic_metadata.json +27 -0
- package/build/src/v1/index.d.ts +4 -0
- package/build/src/v1/index.js +29 -0
- package/build/src/v1/instance_admin_client.d.ts +1985 -0
- package/build/src/v1/instance_admin_client.js +1768 -0
- package/build/src/v1/instance_admin_client_config.json +129 -0
- package/build/src/v1/instance_admin_proto_list.json +4 -0
- package/build/src/v1/spanner_client.d.ts +1250 -0
- package/build/src/v1/spanner_client.js +1086 -0
- package/build/src/v1/spanner_client_config.json +119 -0
- package/build/src/v1/spanner_executor_proxy_client.d.ts +418 -0
- package/build/src/v1/spanner_executor_proxy_client.js +706 -0
- package/build/src/v1/spanner_executor_proxy_client_config.json +30 -0
- package/build/src/v1/spanner_executor_proxy_proto_list.json +14 -0
- package/build/src/v1/spanner_proto_list.json +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1086 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2025 Google LLC
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
//
|
|
16
|
+
// ** This file is automatically generated by gapic-generator-typescript. **
|
|
17
|
+
// ** https://github.com/googleapis/gapic-generator-typescript **
|
|
18
|
+
// ** All changes to this file may be overwritten. **
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.SpannerClient = void 0;
|
|
21
|
+
const stream_1 = require("stream");
|
|
22
|
+
const jsonProtos = require("../../protos/protos.json");
|
|
23
|
+
/**
|
|
24
|
+
* Client JSON configuration object, loaded from
|
|
25
|
+
* `src/v1/spanner_client_config.json`.
|
|
26
|
+
* This file defines retry strategy and timeouts for all API methods in this library.
|
|
27
|
+
*/
|
|
28
|
+
const gapicConfig = require("./spanner_client_config.json");
|
|
29
|
+
const version = require('../../../package.json').version;
|
|
30
|
+
/**
|
|
31
|
+
* Cloud Spanner API
|
|
32
|
+
*
|
|
33
|
+
* The Cloud Spanner API can be used to manage sessions and execute
|
|
34
|
+
* transactions on data stored in Cloud Spanner databases.
|
|
35
|
+
* @class
|
|
36
|
+
* @memberof v1
|
|
37
|
+
*/
|
|
38
|
+
class SpannerClient {
|
|
39
|
+
/**
|
|
40
|
+
* Construct an instance of SpannerClient.
|
|
41
|
+
*
|
|
42
|
+
* @param {object} [options] - The configuration object.
|
|
43
|
+
* The options accepted by the constructor are described in detail
|
|
44
|
+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
|
|
45
|
+
* The common options are:
|
|
46
|
+
* @param {object} [options.credentials] - Credentials object.
|
|
47
|
+
* @param {string} [options.credentials.client_email]
|
|
48
|
+
* @param {string} [options.credentials.private_key]
|
|
49
|
+
* @param {string} [options.email] - Account email address. Required when
|
|
50
|
+
* using a .pem or .p12 keyFilename.
|
|
51
|
+
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
|
|
52
|
+
* .p12 key downloaded from the Google Developers Console. If you provide
|
|
53
|
+
* a path to a JSON file, the projectId option below is not necessary.
|
|
54
|
+
* NOTE: .pem and .p12 require you to specify options.email as well.
|
|
55
|
+
* @param {number} [options.port] - The port on which to connect to
|
|
56
|
+
* the remote host.
|
|
57
|
+
* @param {string} [options.projectId] - The project ID from the Google
|
|
58
|
+
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
|
|
59
|
+
* the environment variable GCLOUD_PROJECT for your project ID. If your
|
|
60
|
+
* app is running in an environment which supports
|
|
61
|
+
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
|
|
62
|
+
* your project ID will be detected automatically.
|
|
63
|
+
* @param {string} [options.apiEndpoint] - The domain name of the
|
|
64
|
+
* API remote host.
|
|
65
|
+
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
|
|
66
|
+
* Follows the structure of {@link gapicConfig}.
|
|
67
|
+
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
|
|
68
|
+
* For more information, please check the
|
|
69
|
+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
|
|
70
|
+
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
|
|
71
|
+
* need to avoid loading the default gRPC version and want to use the fallback
|
|
72
|
+
* HTTP implementation. Load only fallback version and pass it to the constructor:
|
|
73
|
+
* ```
|
|
74
|
+
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
|
|
75
|
+
* const client = new SpannerClient({fallback: true}, gax);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
constructor(opts, gaxInstance) {
|
|
79
|
+
var _a, _b, _c, _d, _e;
|
|
80
|
+
this._terminated = false;
|
|
81
|
+
this.descriptors = {
|
|
82
|
+
page: {},
|
|
83
|
+
stream: {},
|
|
84
|
+
longrunning: {},
|
|
85
|
+
batching: {},
|
|
86
|
+
};
|
|
87
|
+
// Ensure that options include all the required fields.
|
|
88
|
+
const staticMembers = this.constructor;
|
|
89
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.universe_domain) &&
|
|
90
|
+
(opts === null || opts === void 0 ? void 0 : opts.universeDomain) &&
|
|
91
|
+
(opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== (opts === null || opts === void 0 ? void 0 : opts.universeDomain)) {
|
|
92
|
+
throw new Error('Please set either universe_domain or universeDomain, but not both.');
|
|
93
|
+
}
|
|
94
|
+
const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
|
|
95
|
+
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
|
|
96
|
+
: undefined;
|
|
97
|
+
this._universeDomain =
|
|
98
|
+
(_c = (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.universeDomain) !== null && _a !== void 0 ? _a : opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== null && _b !== void 0 ? _b : universeDomainEnvVar) !== null && _c !== void 0 ? _c : 'googleapis.com';
|
|
99
|
+
this._servicePath = 'spanner.' + this._universeDomain;
|
|
100
|
+
const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || this._servicePath;
|
|
101
|
+
this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
|
|
102
|
+
const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
|
|
103
|
+
const clientConfig = (_d = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _d !== void 0 ? _d : {};
|
|
104
|
+
const fallback = (_e = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _e !== void 0 ? _e : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
|
|
105
|
+
opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
|
|
106
|
+
// Request numeric enum values if REST transport is used.
|
|
107
|
+
opts.numericEnums = true;
|
|
108
|
+
// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
|
|
109
|
+
if (servicePath !== this._servicePath && !('scopes' in opts)) {
|
|
110
|
+
opts['scopes'] = staticMembers.scopes;
|
|
111
|
+
}
|
|
112
|
+
// Load google-gax module synchronously if needed
|
|
113
|
+
if (!gaxInstance) {
|
|
114
|
+
gaxInstance = require('google-gax');
|
|
115
|
+
}
|
|
116
|
+
// Choose either gRPC or proto-over-HTTP implementation of google-gax.
|
|
117
|
+
this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
|
|
118
|
+
// Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
|
|
119
|
+
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
|
|
120
|
+
// Save options to use in initialize() method.
|
|
121
|
+
this._opts = opts;
|
|
122
|
+
// Save the auth object to the client, for use by other methods.
|
|
123
|
+
this.auth = this._gaxGrpc.auth;
|
|
124
|
+
// Set useJWTAccessWithScope on the auth object.
|
|
125
|
+
this.auth.useJWTAccessWithScope = true;
|
|
126
|
+
// Set defaultServicePath on the auth object.
|
|
127
|
+
this.auth.defaultServicePath = this._servicePath;
|
|
128
|
+
// Set the default scopes in auth client if needed.
|
|
129
|
+
if (servicePath === this._servicePath) {
|
|
130
|
+
this.auth.defaultScopes = staticMembers.scopes;
|
|
131
|
+
}
|
|
132
|
+
// Determine the client header string.
|
|
133
|
+
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
|
|
134
|
+
if (typeof process === 'object' && 'versions' in process) {
|
|
135
|
+
clientHeader.push(`gl-node/${process.versions.node}`);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
clientHeader.push(`gl-web/${this._gaxModule.version}`);
|
|
139
|
+
}
|
|
140
|
+
if (!opts.fallback) {
|
|
141
|
+
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
|
|
145
|
+
}
|
|
146
|
+
if (opts.libName && opts.libVersion) {
|
|
147
|
+
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
|
|
148
|
+
}
|
|
149
|
+
// Load the applicable protos.
|
|
150
|
+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
|
|
151
|
+
// This API contains "path templates"; forward-slash-separated
|
|
152
|
+
// identifiers to uniquely identify resources within the API.
|
|
153
|
+
// Create useful helper objects for these.
|
|
154
|
+
this.pathTemplates = {
|
|
155
|
+
databasePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/instances/{instance}/databases/{database}'),
|
|
156
|
+
sessionPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/instances/{instance}/databases/{database}/sessions/{session}'),
|
|
157
|
+
};
|
|
158
|
+
// Some of the methods on this service return "paged" results,
|
|
159
|
+
// (e.g. 50 results at a time, with tokens to get subsequent
|
|
160
|
+
// pages). Denote the keys used for pagination and results.
|
|
161
|
+
this.descriptors.page = {
|
|
162
|
+
listSessions: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'sessions'),
|
|
163
|
+
};
|
|
164
|
+
// Some of the methods on this service provide streaming responses.
|
|
165
|
+
// Provide descriptors for these.
|
|
166
|
+
this.descriptors.stream = {
|
|
167
|
+
executeStreamingSql: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
168
|
+
streamingRead: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
169
|
+
batchWrite: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
170
|
+
};
|
|
171
|
+
// Put together the default options sent with requests.
|
|
172
|
+
this._defaults = this._gaxGrpc.constructSettings('google.spanner.v1.Spanner', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
|
|
173
|
+
// Set up a dictionary of "inner API calls"; the core implementation
|
|
174
|
+
// of calling the API is handled in `google-gax`, with this code
|
|
175
|
+
// merely providing the destination and request information.
|
|
176
|
+
this.innerApiCalls = {};
|
|
177
|
+
// Add a warn function to the client constructor so it can be easily tested.
|
|
178
|
+
this.warn = this._gaxModule.warn;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Initialize the client.
|
|
182
|
+
* Performs asynchronous operations (such as authentication) and prepares the client.
|
|
183
|
+
* This function will be called automatically when any class method is called for the
|
|
184
|
+
* first time, but if you need to initialize it before calling an actual method,
|
|
185
|
+
* feel free to call initialize() directly.
|
|
186
|
+
*
|
|
187
|
+
* You can await on this method if you want to make sure the client is initialized.
|
|
188
|
+
*
|
|
189
|
+
* @returns {Promise} A promise that resolves to an authenticated service stub.
|
|
190
|
+
*/
|
|
191
|
+
initialize() {
|
|
192
|
+
// If the client stub promise is already initialized, return immediately.
|
|
193
|
+
if (this.spannerStub) {
|
|
194
|
+
return this.spannerStub;
|
|
195
|
+
}
|
|
196
|
+
// Put together the "service stub" for
|
|
197
|
+
// google.spanner.v1.Spanner.
|
|
198
|
+
this.spannerStub = this._gaxGrpc.createStub(this._opts.fallback
|
|
199
|
+
? this._protos.lookupService('google.spanner.v1.Spanner')
|
|
200
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
201
|
+
this._protos.google.spanner.v1.Spanner, this._opts, this._providedCustomServicePath);
|
|
202
|
+
// Iterate over each of the methods that the service provides
|
|
203
|
+
// and create an API call method for each.
|
|
204
|
+
const spannerStubMethods = [
|
|
205
|
+
'createSession',
|
|
206
|
+
'batchCreateSessions',
|
|
207
|
+
'getSession',
|
|
208
|
+
'listSessions',
|
|
209
|
+
'deleteSession',
|
|
210
|
+
'executeSql',
|
|
211
|
+
'executeStreamingSql',
|
|
212
|
+
'executeBatchDml',
|
|
213
|
+
'read',
|
|
214
|
+
'streamingRead',
|
|
215
|
+
'beginTransaction',
|
|
216
|
+
'commit',
|
|
217
|
+
'rollback',
|
|
218
|
+
'partitionQuery',
|
|
219
|
+
'partitionRead',
|
|
220
|
+
'batchWrite',
|
|
221
|
+
];
|
|
222
|
+
for (const methodName of spannerStubMethods) {
|
|
223
|
+
const callPromise = this.spannerStub.then(stub => (...args) => {
|
|
224
|
+
if (this._terminated) {
|
|
225
|
+
if (methodName in this.descriptors.stream) {
|
|
226
|
+
const stream = new stream_1.PassThrough();
|
|
227
|
+
setImmediate(() => {
|
|
228
|
+
stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.'));
|
|
229
|
+
});
|
|
230
|
+
return stream;
|
|
231
|
+
}
|
|
232
|
+
return Promise.reject('The client has already been closed.');
|
|
233
|
+
}
|
|
234
|
+
const func = stub[methodName];
|
|
235
|
+
return func.apply(stub, args);
|
|
236
|
+
}, (err) => () => {
|
|
237
|
+
throw err;
|
|
238
|
+
});
|
|
239
|
+
const descriptor = this.descriptors.page[methodName] ||
|
|
240
|
+
this.descriptors.stream[methodName] ||
|
|
241
|
+
undefined;
|
|
242
|
+
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
|
|
243
|
+
this.innerApiCalls[methodName] = apiCall;
|
|
244
|
+
}
|
|
245
|
+
return this.spannerStub;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The DNS address for this API service.
|
|
249
|
+
* @deprecated Use the apiEndpoint method of the client instance.
|
|
250
|
+
* @returns {string} The DNS address for this service.
|
|
251
|
+
*/
|
|
252
|
+
static get servicePath() {
|
|
253
|
+
if (typeof process === 'object' &&
|
|
254
|
+
typeof process.emitWarning === 'function') {
|
|
255
|
+
process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
|
|
256
|
+
}
|
|
257
|
+
return 'spanner.googleapis.com';
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The DNS address for this API service - same as servicePath.
|
|
261
|
+
* @deprecated Use the apiEndpoint method of the client instance.
|
|
262
|
+
* @returns {string} The DNS address for this service.
|
|
263
|
+
*/
|
|
264
|
+
static get apiEndpoint() {
|
|
265
|
+
if (typeof process === 'object' &&
|
|
266
|
+
typeof process.emitWarning === 'function') {
|
|
267
|
+
process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
|
|
268
|
+
}
|
|
269
|
+
return 'spanner.googleapis.com';
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* The DNS address for this API service.
|
|
273
|
+
* @returns {string} The DNS address for this service.
|
|
274
|
+
*/
|
|
275
|
+
get apiEndpoint() {
|
|
276
|
+
return this._servicePath;
|
|
277
|
+
}
|
|
278
|
+
get universeDomain() {
|
|
279
|
+
return this._universeDomain;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* The port for this API service.
|
|
283
|
+
* @returns {number} The default port for this service.
|
|
284
|
+
*/
|
|
285
|
+
static get port() {
|
|
286
|
+
return 443;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* The scopes needed to make gRPC calls for every method defined
|
|
290
|
+
* in this service.
|
|
291
|
+
* @returns {string[]} List of default scopes.
|
|
292
|
+
*/
|
|
293
|
+
static get scopes() {
|
|
294
|
+
return [
|
|
295
|
+
'https://www.googleapis.com/auth/cloud-platform',
|
|
296
|
+
'https://www.googleapis.com/auth/spanner.data',
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Return the project ID used by this class.
|
|
301
|
+
* @returns {Promise} A promise that resolves to string containing the project ID.
|
|
302
|
+
*/
|
|
303
|
+
getProjectId(callback) {
|
|
304
|
+
if (callback) {
|
|
305
|
+
this.auth.getProjectId(callback);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
return this.auth.getProjectId();
|
|
309
|
+
}
|
|
310
|
+
createSession(request, optionsOrCallback, callback) {
|
|
311
|
+
var _a;
|
|
312
|
+
request = request || {};
|
|
313
|
+
let options;
|
|
314
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
315
|
+
callback = optionsOrCallback;
|
|
316
|
+
options = {};
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
options = optionsOrCallback;
|
|
320
|
+
}
|
|
321
|
+
options = options || {};
|
|
322
|
+
options.otherArgs = options.otherArgs || {};
|
|
323
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
324
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
325
|
+
this._gaxModule.routingHeader.fromParams({
|
|
326
|
+
database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
|
|
327
|
+
});
|
|
328
|
+
this.initialize();
|
|
329
|
+
return this.innerApiCalls.createSession(request, options, callback);
|
|
330
|
+
}
|
|
331
|
+
batchCreateSessions(request, optionsOrCallback, callback) {
|
|
332
|
+
var _a;
|
|
333
|
+
request = request || {};
|
|
334
|
+
let options;
|
|
335
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
336
|
+
callback = optionsOrCallback;
|
|
337
|
+
options = {};
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
options = optionsOrCallback;
|
|
341
|
+
}
|
|
342
|
+
options = options || {};
|
|
343
|
+
options.otherArgs = options.otherArgs || {};
|
|
344
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
345
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
346
|
+
this._gaxModule.routingHeader.fromParams({
|
|
347
|
+
database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
|
|
348
|
+
});
|
|
349
|
+
this.initialize();
|
|
350
|
+
return this.innerApiCalls.batchCreateSessions(request, options, callback);
|
|
351
|
+
}
|
|
352
|
+
getSession(request, optionsOrCallback, callback) {
|
|
353
|
+
var _a;
|
|
354
|
+
request = request || {};
|
|
355
|
+
let options;
|
|
356
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
357
|
+
callback = optionsOrCallback;
|
|
358
|
+
options = {};
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
options = optionsOrCallback;
|
|
362
|
+
}
|
|
363
|
+
options = options || {};
|
|
364
|
+
options.otherArgs = options.otherArgs || {};
|
|
365
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
366
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
367
|
+
this._gaxModule.routingHeader.fromParams({
|
|
368
|
+
name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
|
|
369
|
+
});
|
|
370
|
+
this.initialize();
|
|
371
|
+
return this.innerApiCalls.getSession(request, options, callback);
|
|
372
|
+
}
|
|
373
|
+
deleteSession(request, optionsOrCallback, callback) {
|
|
374
|
+
var _a;
|
|
375
|
+
request = request || {};
|
|
376
|
+
let options;
|
|
377
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
378
|
+
callback = optionsOrCallback;
|
|
379
|
+
options = {};
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
options = optionsOrCallback;
|
|
383
|
+
}
|
|
384
|
+
options = options || {};
|
|
385
|
+
options.otherArgs = options.otherArgs || {};
|
|
386
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
387
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
388
|
+
this._gaxModule.routingHeader.fromParams({
|
|
389
|
+
name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
|
|
390
|
+
});
|
|
391
|
+
this.initialize();
|
|
392
|
+
return this.innerApiCalls.deleteSession(request, options, callback);
|
|
393
|
+
}
|
|
394
|
+
executeSql(request, optionsOrCallback, callback) {
|
|
395
|
+
var _a;
|
|
396
|
+
request = request || {};
|
|
397
|
+
let options;
|
|
398
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
399
|
+
callback = optionsOrCallback;
|
|
400
|
+
options = {};
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
options = optionsOrCallback;
|
|
404
|
+
}
|
|
405
|
+
options = options || {};
|
|
406
|
+
options.otherArgs = options.otherArgs || {};
|
|
407
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
408
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
409
|
+
this._gaxModule.routingHeader.fromParams({
|
|
410
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
411
|
+
});
|
|
412
|
+
this.initialize();
|
|
413
|
+
return this.innerApiCalls.executeSql(request, options, callback);
|
|
414
|
+
}
|
|
415
|
+
executeBatchDml(request, optionsOrCallback, callback) {
|
|
416
|
+
var _a;
|
|
417
|
+
request = request || {};
|
|
418
|
+
let options;
|
|
419
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
420
|
+
callback = optionsOrCallback;
|
|
421
|
+
options = {};
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
options = optionsOrCallback;
|
|
425
|
+
}
|
|
426
|
+
options = options || {};
|
|
427
|
+
options.otherArgs = options.otherArgs || {};
|
|
428
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
429
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
430
|
+
this._gaxModule.routingHeader.fromParams({
|
|
431
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
432
|
+
});
|
|
433
|
+
this.initialize();
|
|
434
|
+
return this.innerApiCalls.executeBatchDml(request, options, callback);
|
|
435
|
+
}
|
|
436
|
+
read(request, optionsOrCallback, callback) {
|
|
437
|
+
var _a;
|
|
438
|
+
request = request || {};
|
|
439
|
+
let options;
|
|
440
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
441
|
+
callback = optionsOrCallback;
|
|
442
|
+
options = {};
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
options = optionsOrCallback;
|
|
446
|
+
}
|
|
447
|
+
options = options || {};
|
|
448
|
+
options.otherArgs = options.otherArgs || {};
|
|
449
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
450
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
451
|
+
this._gaxModule.routingHeader.fromParams({
|
|
452
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
453
|
+
});
|
|
454
|
+
this.initialize();
|
|
455
|
+
return this.innerApiCalls.read(request, options, callback);
|
|
456
|
+
}
|
|
457
|
+
beginTransaction(request, optionsOrCallback, callback) {
|
|
458
|
+
var _a;
|
|
459
|
+
request = request || {};
|
|
460
|
+
let options;
|
|
461
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
462
|
+
callback = optionsOrCallback;
|
|
463
|
+
options = {};
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
options = optionsOrCallback;
|
|
467
|
+
}
|
|
468
|
+
options = options || {};
|
|
469
|
+
options.otherArgs = options.otherArgs || {};
|
|
470
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
471
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
472
|
+
this._gaxModule.routingHeader.fromParams({
|
|
473
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
474
|
+
});
|
|
475
|
+
this.initialize();
|
|
476
|
+
return this.innerApiCalls.beginTransaction(request, options, callback);
|
|
477
|
+
}
|
|
478
|
+
commit(request, optionsOrCallback, callback) {
|
|
479
|
+
var _a;
|
|
480
|
+
request = request || {};
|
|
481
|
+
let options;
|
|
482
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
483
|
+
callback = optionsOrCallback;
|
|
484
|
+
options = {};
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
options = optionsOrCallback;
|
|
488
|
+
}
|
|
489
|
+
options = options || {};
|
|
490
|
+
options.otherArgs = options.otherArgs || {};
|
|
491
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
492
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
493
|
+
this._gaxModule.routingHeader.fromParams({
|
|
494
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
495
|
+
});
|
|
496
|
+
this.initialize();
|
|
497
|
+
return this.innerApiCalls.commit(request, options, callback);
|
|
498
|
+
}
|
|
499
|
+
rollback(request, optionsOrCallback, callback) {
|
|
500
|
+
var _a;
|
|
501
|
+
request = request || {};
|
|
502
|
+
let options;
|
|
503
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
504
|
+
callback = optionsOrCallback;
|
|
505
|
+
options = {};
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
options = optionsOrCallback;
|
|
509
|
+
}
|
|
510
|
+
options = options || {};
|
|
511
|
+
options.otherArgs = options.otherArgs || {};
|
|
512
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
513
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
514
|
+
this._gaxModule.routingHeader.fromParams({
|
|
515
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
516
|
+
});
|
|
517
|
+
this.initialize();
|
|
518
|
+
return this.innerApiCalls.rollback(request, options, callback);
|
|
519
|
+
}
|
|
520
|
+
partitionQuery(request, optionsOrCallback, callback) {
|
|
521
|
+
var _a;
|
|
522
|
+
request = request || {};
|
|
523
|
+
let options;
|
|
524
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
525
|
+
callback = optionsOrCallback;
|
|
526
|
+
options = {};
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
options = optionsOrCallback;
|
|
530
|
+
}
|
|
531
|
+
options = options || {};
|
|
532
|
+
options.otherArgs = options.otherArgs || {};
|
|
533
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
534
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
535
|
+
this._gaxModule.routingHeader.fromParams({
|
|
536
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
537
|
+
});
|
|
538
|
+
this.initialize();
|
|
539
|
+
return this.innerApiCalls.partitionQuery(request, options, callback);
|
|
540
|
+
}
|
|
541
|
+
partitionRead(request, optionsOrCallback, callback) {
|
|
542
|
+
var _a;
|
|
543
|
+
request = request || {};
|
|
544
|
+
let options;
|
|
545
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
546
|
+
callback = optionsOrCallback;
|
|
547
|
+
options = {};
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
options = optionsOrCallback;
|
|
551
|
+
}
|
|
552
|
+
options = options || {};
|
|
553
|
+
options.otherArgs = options.otherArgs || {};
|
|
554
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
555
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
556
|
+
this._gaxModule.routingHeader.fromParams({
|
|
557
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
558
|
+
});
|
|
559
|
+
this.initialize();
|
|
560
|
+
return this.innerApiCalls.partitionRead(request, options, callback);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Like {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, except returns the
|
|
564
|
+
* result set as a stream. Unlike
|
|
565
|
+
* {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, there is no limit on
|
|
566
|
+
* the size of the returned result set. However, no individual row in the
|
|
567
|
+
* result set can exceed 100 MiB, and no column value can exceed 10 MiB.
|
|
568
|
+
*
|
|
569
|
+
* @param {Object} request
|
|
570
|
+
* The request object that will be sent.
|
|
571
|
+
* @param {string} request.session
|
|
572
|
+
* Required. The session in which the SQL query should be performed.
|
|
573
|
+
* @param {google.spanner.v1.TransactionSelector} request.transaction
|
|
574
|
+
* The transaction to use.
|
|
575
|
+
*
|
|
576
|
+
* For queries, if none is provided, the default is a temporary read-only
|
|
577
|
+
* transaction with strong concurrency.
|
|
578
|
+
*
|
|
579
|
+
* Standard DML statements require a read-write transaction. To protect
|
|
580
|
+
* against replays, single-use transactions are not supported. The caller
|
|
581
|
+
* must either supply an existing transaction ID or begin a new transaction.
|
|
582
|
+
*
|
|
583
|
+
* Partitioned DML requires an existing Partitioned DML transaction ID.
|
|
584
|
+
* @param {string} request.sql
|
|
585
|
+
* Required. The SQL string.
|
|
586
|
+
* @param {google.protobuf.Struct} request.params
|
|
587
|
+
* Parameter names and values that bind to placeholders in the SQL string.
|
|
588
|
+
*
|
|
589
|
+
* A parameter placeholder consists of the `@` character followed by the
|
|
590
|
+
* parameter name (for example, `@firstName`). Parameter names must conform
|
|
591
|
+
* to the naming requirements of identifiers as specified at
|
|
592
|
+
* https://cloud.google.com/spanner/docs/lexical#identifiers.
|
|
593
|
+
*
|
|
594
|
+
* Parameters can appear anywhere that a literal value is expected. The same
|
|
595
|
+
* parameter name can be used more than once, for example:
|
|
596
|
+
*
|
|
597
|
+
* `"WHERE id > @msg_id AND id < @msg_id + 100"`
|
|
598
|
+
*
|
|
599
|
+
* It is an error to execute a SQL statement with unbound parameters.
|
|
600
|
+
* @param {number[]} request.paramTypes
|
|
601
|
+
* It is not always possible for Cloud Spanner to infer the right SQL type
|
|
602
|
+
* from a JSON value. For example, values of type `BYTES` and values
|
|
603
|
+
* of type `STRING` both appear in
|
|
604
|
+
* {@link protos.google.spanner.v1.ExecuteSqlRequest.params|params} as JSON strings.
|
|
605
|
+
*
|
|
606
|
+
* In these cases, `param_types` can be used to specify the exact
|
|
607
|
+
* SQL type for some or all of the SQL statement parameters. See the
|
|
608
|
+
* definition of {@link protos.google.spanner.v1.Type|Type} for more information
|
|
609
|
+
* about SQL types.
|
|
610
|
+
* @param {Buffer} request.resumeToken
|
|
611
|
+
* If this request is resuming a previously interrupted SQL statement
|
|
612
|
+
* execution, `resume_token` should be copied from the last
|
|
613
|
+
* {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the
|
|
614
|
+
* interruption. Doing this enables the new SQL statement execution to resume
|
|
615
|
+
* where the last one left off. The rest of the request parameters must
|
|
616
|
+
* exactly match the request that yielded this token.
|
|
617
|
+
* @param {google.spanner.v1.ExecuteSqlRequest.QueryMode} request.queryMode
|
|
618
|
+
* Used to control the amount of debugging information returned in
|
|
619
|
+
* {@link protos.google.spanner.v1.ResultSetStats|ResultSetStats}. If
|
|
620
|
+
* {@link protos.google.spanner.v1.ExecuteSqlRequest.partition_token|partition_token} is
|
|
621
|
+
* set, {@link protos.google.spanner.v1.ExecuteSqlRequest.query_mode|query_mode} can only
|
|
622
|
+
* be set to
|
|
623
|
+
* {@link protos.google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL|QueryMode.NORMAL}.
|
|
624
|
+
* @param {Buffer} request.partitionToken
|
|
625
|
+
* If present, results will be restricted to the specified partition
|
|
626
|
+
* previously created using PartitionQuery(). There must be an exact
|
|
627
|
+
* match for the values of fields common to this message and the
|
|
628
|
+
* PartitionQueryRequest message used to create this partition_token.
|
|
629
|
+
* @param {number} request.seqno
|
|
630
|
+
* A per-transaction sequence number used to identify this request. This field
|
|
631
|
+
* makes each request idempotent such that if the request is received multiple
|
|
632
|
+
* times, at most one will succeed.
|
|
633
|
+
*
|
|
634
|
+
* The sequence number must be monotonically increasing within the
|
|
635
|
+
* transaction. If a request arrives for the first time with an out-of-order
|
|
636
|
+
* sequence number, the transaction may be aborted. Replays of previously
|
|
637
|
+
* handled requests will yield the same response as the first execution.
|
|
638
|
+
*
|
|
639
|
+
* Required for DML statements. Ignored for queries.
|
|
640
|
+
* @param {google.spanner.v1.ExecuteSqlRequest.QueryOptions} request.queryOptions
|
|
641
|
+
* Query optimizer configuration to use for the given query.
|
|
642
|
+
* @param {google.spanner.v1.RequestOptions} request.requestOptions
|
|
643
|
+
* Common options for this request.
|
|
644
|
+
* @param {google.spanner.v1.DirectedReadOptions} request.directedReadOptions
|
|
645
|
+
* Directed read options for this request.
|
|
646
|
+
* @param {boolean} request.dataBoostEnabled
|
|
647
|
+
* If this is for a partitioned query and this field is set to `true`, the
|
|
648
|
+
* request is executed with Spanner Data Boost independent compute resources.
|
|
649
|
+
*
|
|
650
|
+
* If the field is set to `true` but the request does not set
|
|
651
|
+
* `partition_token`, the API returns an `INVALID_ARGUMENT` error.
|
|
652
|
+
* @param {boolean} [request.lastStatement]
|
|
653
|
+
* Optional. If set to true, this statement marks the end of the transaction.
|
|
654
|
+
* The transaction should be committed or aborted after this statement
|
|
655
|
+
* executes, and attempts to execute any other requests against this
|
|
656
|
+
* transaction (including reads and queries) will be rejected.
|
|
657
|
+
*
|
|
658
|
+
* For DML statements, setting this option may cause some error reporting to
|
|
659
|
+
* be deferred until commit time (e.g. validation of unique constraints).
|
|
660
|
+
* Given this, successful execution of a DML statement should not be assumed
|
|
661
|
+
* until a subsequent Commit call completes successfully.
|
|
662
|
+
* @param {object} [options]
|
|
663
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
664
|
+
* @returns {Stream}
|
|
665
|
+
* An object stream which emits {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} on 'data' event.
|
|
666
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
|
|
667
|
+
* for more details and examples.
|
|
668
|
+
*/
|
|
669
|
+
executeStreamingSql(request, options) {
|
|
670
|
+
var _a;
|
|
671
|
+
request = request || {};
|
|
672
|
+
options = options || {};
|
|
673
|
+
options.otherArgs = options.otherArgs || {};
|
|
674
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
675
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
676
|
+
this._gaxModule.routingHeader.fromParams({
|
|
677
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
678
|
+
});
|
|
679
|
+
this.initialize();
|
|
680
|
+
return this.innerApiCalls.executeStreamingSql(request, options);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Like {@link protos.google.spanner.v1.Spanner.Read|Read}, except returns the result set
|
|
684
|
+
* as a stream. Unlike {@link protos.google.spanner.v1.Spanner.Read|Read}, there is no
|
|
685
|
+
* limit on the size of the returned result set. However, no individual row in
|
|
686
|
+
* the result set can exceed 100 MiB, and no column value can exceed
|
|
687
|
+
* 10 MiB.
|
|
688
|
+
*
|
|
689
|
+
* @param {Object} request
|
|
690
|
+
* The request object that will be sent.
|
|
691
|
+
* @param {string} request.session
|
|
692
|
+
* Required. The session in which the read should be performed.
|
|
693
|
+
* @param {google.spanner.v1.TransactionSelector} request.transaction
|
|
694
|
+
* The transaction to use. If none is provided, the default is a
|
|
695
|
+
* temporary read-only transaction with strong concurrency.
|
|
696
|
+
* @param {string} request.table
|
|
697
|
+
* Required. The name of the table in the database to be read.
|
|
698
|
+
* @param {string} request.index
|
|
699
|
+
* If non-empty, the name of an index on
|
|
700
|
+
* {@link protos.google.spanner.v1.ReadRequest.table|table}. This index is used instead of
|
|
701
|
+
* the table primary key when interpreting
|
|
702
|
+
* {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} and sorting result rows.
|
|
703
|
+
* See {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} for further
|
|
704
|
+
* information.
|
|
705
|
+
* @param {string[]} request.columns
|
|
706
|
+
* Required. The columns of {@link protos.google.spanner.v1.ReadRequest.table|table} to be
|
|
707
|
+
* returned for each row matching this request.
|
|
708
|
+
* @param {google.spanner.v1.KeySet} request.keySet
|
|
709
|
+
* Required. `key_set` identifies the rows to be yielded. `key_set` names the
|
|
710
|
+
* primary keys of the rows in {@link protos.google.spanner.v1.ReadRequest.table|table} to
|
|
711
|
+
* be yielded, unless {@link protos.google.spanner.v1.ReadRequest.index|index} is present.
|
|
712
|
+
* If {@link protos.google.spanner.v1.ReadRequest.index|index} is present, then
|
|
713
|
+
* {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} instead names index keys
|
|
714
|
+
* in {@link protos.google.spanner.v1.ReadRequest.index|index}.
|
|
715
|
+
*
|
|
716
|
+
* If the {@link protos.google.spanner.v1.ReadRequest.partition_token|partition_token}
|
|
717
|
+
* field is empty, rows are yielded in table primary key order (if
|
|
718
|
+
* {@link protos.google.spanner.v1.ReadRequest.index|index} is empty) or index key order
|
|
719
|
+
* (if {@link protos.google.spanner.v1.ReadRequest.index|index} is non-empty). If the
|
|
720
|
+
* {@link protos.google.spanner.v1.ReadRequest.partition_token|partition_token} field is
|
|
721
|
+
* not empty, rows will be yielded in an unspecified order.
|
|
722
|
+
*
|
|
723
|
+
* It is not an error for the `key_set` to name rows that do not
|
|
724
|
+
* exist in the database. Read yields nothing for nonexistent rows.
|
|
725
|
+
* @param {number} request.limit
|
|
726
|
+
* If greater than zero, only the first `limit` rows are yielded. If `limit`
|
|
727
|
+
* is zero, the default is no limit. A limit cannot be specified if
|
|
728
|
+
* `partition_token` is set.
|
|
729
|
+
* @param {Buffer} request.resumeToken
|
|
730
|
+
* If this request is resuming a previously interrupted read,
|
|
731
|
+
* `resume_token` should be copied from the last
|
|
732
|
+
* {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the
|
|
733
|
+
* interruption. Doing this enables the new read to resume where the last read
|
|
734
|
+
* left off. The rest of the request parameters must exactly match the request
|
|
735
|
+
* that yielded this token.
|
|
736
|
+
* @param {Buffer} request.partitionToken
|
|
737
|
+
* If present, results will be restricted to the specified partition
|
|
738
|
+
* previously created using PartitionRead(). There must be an exact
|
|
739
|
+
* match for the values of fields common to this message and the
|
|
740
|
+
* PartitionReadRequest message used to create this partition_token.
|
|
741
|
+
* @param {google.spanner.v1.RequestOptions} request.requestOptions
|
|
742
|
+
* Common options for this request.
|
|
743
|
+
* @param {google.spanner.v1.DirectedReadOptions} request.directedReadOptions
|
|
744
|
+
* Directed read options for this request.
|
|
745
|
+
* @param {boolean} request.dataBoostEnabled
|
|
746
|
+
* If this is for a partitioned read and this field is set to `true`, the
|
|
747
|
+
* request is executed with Spanner Data Boost independent compute resources.
|
|
748
|
+
*
|
|
749
|
+
* If the field is set to `true` but the request does not set
|
|
750
|
+
* `partition_token`, the API returns an `INVALID_ARGUMENT` error.
|
|
751
|
+
* @param {google.spanner.v1.ReadRequest.OrderBy} [request.orderBy]
|
|
752
|
+
* Optional. Order for the returned rows.
|
|
753
|
+
*
|
|
754
|
+
* By default, Spanner will return result rows in primary key order except for
|
|
755
|
+
* PartitionRead requests. For applications that do not require rows to be
|
|
756
|
+
* returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting
|
|
757
|
+
* `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval,
|
|
758
|
+
* resulting in lower latencies in certain cases (e.g. bulk point lookups).
|
|
759
|
+
* @param {google.spanner.v1.ReadRequest.LockHint} [request.lockHint]
|
|
760
|
+
* Optional. Lock Hint for the request, it can only be used with read-write
|
|
761
|
+
* transactions.
|
|
762
|
+
* @param {object} [options]
|
|
763
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
764
|
+
* @returns {Stream}
|
|
765
|
+
* An object stream which emits {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} on 'data' event.
|
|
766
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
|
|
767
|
+
* for more details and examples.
|
|
768
|
+
*/
|
|
769
|
+
streamingRead(request, options) {
|
|
770
|
+
var _a;
|
|
771
|
+
request = request || {};
|
|
772
|
+
options = options || {};
|
|
773
|
+
options.otherArgs = options.otherArgs || {};
|
|
774
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
775
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
776
|
+
this._gaxModule.routingHeader.fromParams({
|
|
777
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
778
|
+
});
|
|
779
|
+
this.initialize();
|
|
780
|
+
return this.innerApiCalls.streamingRead(request, options);
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Batches the supplied mutation groups in a collection of efficient
|
|
784
|
+
* transactions. All mutations in a group are committed atomically. However,
|
|
785
|
+
* mutations across groups can be committed non-atomically in an unspecified
|
|
786
|
+
* order and thus, they must be independent of each other. Partial failure is
|
|
787
|
+
* possible, i.e., some groups may have been committed successfully, while
|
|
788
|
+
* some may have failed. The results of individual batches are streamed into
|
|
789
|
+
* the response as the batches are applied.
|
|
790
|
+
*
|
|
791
|
+
* BatchWrite requests are not replay protected, meaning that each mutation
|
|
792
|
+
* group may be applied more than once. Replays of non-idempotent mutations
|
|
793
|
+
* may have undesirable effects. For example, replays of an insert mutation
|
|
794
|
+
* may produce an already exists error or if you use generated or commit
|
|
795
|
+
* timestamp-based keys, it may result in additional rows being added to the
|
|
796
|
+
* mutation's table. We recommend structuring your mutation groups to be
|
|
797
|
+
* idempotent to avoid this issue.
|
|
798
|
+
*
|
|
799
|
+
* @param {Object} request
|
|
800
|
+
* The request object that will be sent.
|
|
801
|
+
* @param {string} request.session
|
|
802
|
+
* Required. The session in which the batch request is to be run.
|
|
803
|
+
* @param {google.spanner.v1.RequestOptions} request.requestOptions
|
|
804
|
+
* Common options for this request.
|
|
805
|
+
* @param {number[]} request.mutationGroups
|
|
806
|
+
* Required. The groups of mutations to be applied.
|
|
807
|
+
* @param {boolean} [request.excludeTxnFromChangeStreams]
|
|
808
|
+
* Optional. When `exclude_txn_from_change_streams` is set to `true`:
|
|
809
|
+
* * Mutations from all transactions in this batch write operation will not
|
|
810
|
+
* be recorded in change streams with DDL option `allow_txn_exclusion=true`
|
|
811
|
+
* that are tracking columns modified by these transactions.
|
|
812
|
+
* * Mutations from all transactions in this batch write operation will be
|
|
813
|
+
* recorded in change streams with DDL option `allow_txn_exclusion=false or
|
|
814
|
+
* not set` that are tracking columns modified by these transactions.
|
|
815
|
+
*
|
|
816
|
+
* When `exclude_txn_from_change_streams` is set to `false` or not set,
|
|
817
|
+
* mutations from all transactions in this batch write operation will be
|
|
818
|
+
* recorded in all change streams that are tracking columns modified by these
|
|
819
|
+
* transactions.
|
|
820
|
+
* @param {object} [options]
|
|
821
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
822
|
+
* @returns {Stream}
|
|
823
|
+
* An object stream which emits {@link protos.google.spanner.v1.BatchWriteResponse|BatchWriteResponse} on 'data' event.
|
|
824
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
|
|
825
|
+
* for more details and examples.
|
|
826
|
+
*/
|
|
827
|
+
batchWrite(request, options) {
|
|
828
|
+
var _a;
|
|
829
|
+
request = request || {};
|
|
830
|
+
options = options || {};
|
|
831
|
+
options.otherArgs = options.otherArgs || {};
|
|
832
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
833
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
834
|
+
this._gaxModule.routingHeader.fromParams({
|
|
835
|
+
session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
|
|
836
|
+
});
|
|
837
|
+
this.initialize();
|
|
838
|
+
return this.innerApiCalls.batchWrite(request, options);
|
|
839
|
+
}
|
|
840
|
+
listSessions(request, optionsOrCallback, callback) {
|
|
841
|
+
var _a;
|
|
842
|
+
request = request || {};
|
|
843
|
+
let options;
|
|
844
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
845
|
+
callback = optionsOrCallback;
|
|
846
|
+
options = {};
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
options = optionsOrCallback;
|
|
850
|
+
}
|
|
851
|
+
options = options || {};
|
|
852
|
+
options.otherArgs = options.otherArgs || {};
|
|
853
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
854
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
855
|
+
this._gaxModule.routingHeader.fromParams({
|
|
856
|
+
database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
|
|
857
|
+
});
|
|
858
|
+
this.initialize();
|
|
859
|
+
return this.innerApiCalls.listSessions(request, options, callback);
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
|
|
863
|
+
* @param {Object} request
|
|
864
|
+
* The request object that will be sent.
|
|
865
|
+
* @param {string} request.database
|
|
866
|
+
* Required. The database in which to list sessions.
|
|
867
|
+
* @param {number} request.pageSize
|
|
868
|
+
* Number of sessions to be returned in the response. If 0 or less, defaults
|
|
869
|
+
* to the server's maximum allowed page size.
|
|
870
|
+
* @param {string} request.pageToken
|
|
871
|
+
* If non-empty, `page_token` should contain a
|
|
872
|
+
* {@link protos.google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token}
|
|
873
|
+
* from a previous
|
|
874
|
+
* {@link protos.google.spanner.v1.ListSessionsResponse|ListSessionsResponse}.
|
|
875
|
+
* @param {string} request.filter
|
|
876
|
+
* An expression for filtering the results of the request. Filter rules are
|
|
877
|
+
* case insensitive. The fields eligible for filtering are:
|
|
878
|
+
*
|
|
879
|
+
* * `labels.key` where key is the name of a label
|
|
880
|
+
*
|
|
881
|
+
* Some examples of using filters are:
|
|
882
|
+
*
|
|
883
|
+
* * `labels.env:*` --> The session has the label "env".
|
|
884
|
+
* * `labels.env:dev` --> The session has the label "env" and the value of
|
|
885
|
+
* the label contains the string "dev".
|
|
886
|
+
* @param {object} [options]
|
|
887
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
888
|
+
* @returns {Stream}
|
|
889
|
+
* An object stream which emits an object representing {@link protos.google.spanner.v1.Session|Session} on 'data' event.
|
|
890
|
+
* The client library will perform auto-pagination by default: it will call the API as many
|
|
891
|
+
* times as needed. Note that it can affect your quota.
|
|
892
|
+
* We recommend using `listSessionsAsync()`
|
|
893
|
+
* method described below for async iteration which you can stop as needed.
|
|
894
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
|
|
895
|
+
* for more details and examples.
|
|
896
|
+
*/
|
|
897
|
+
listSessionsStream(request, options) {
|
|
898
|
+
var _a;
|
|
899
|
+
request = request || {};
|
|
900
|
+
options = options || {};
|
|
901
|
+
options.otherArgs = options.otherArgs || {};
|
|
902
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
903
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
904
|
+
this._gaxModule.routingHeader.fromParams({
|
|
905
|
+
database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
|
|
906
|
+
});
|
|
907
|
+
const defaultCallSettings = this._defaults['listSessions'];
|
|
908
|
+
const callSettings = defaultCallSettings.merge(options);
|
|
909
|
+
this.initialize();
|
|
910
|
+
return this.descriptors.page.listSessions.createStream(this.innerApiCalls.listSessions, request, callSettings);
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Equivalent to `listSessions`, but returns an iterable object.
|
|
914
|
+
*
|
|
915
|
+
* `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
|
|
916
|
+
* @param {Object} request
|
|
917
|
+
* The request object that will be sent.
|
|
918
|
+
* @param {string} request.database
|
|
919
|
+
* Required. The database in which to list sessions.
|
|
920
|
+
* @param {number} request.pageSize
|
|
921
|
+
* Number of sessions to be returned in the response. If 0 or less, defaults
|
|
922
|
+
* to the server's maximum allowed page size.
|
|
923
|
+
* @param {string} request.pageToken
|
|
924
|
+
* If non-empty, `page_token` should contain a
|
|
925
|
+
* {@link protos.google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token}
|
|
926
|
+
* from a previous
|
|
927
|
+
* {@link protos.google.spanner.v1.ListSessionsResponse|ListSessionsResponse}.
|
|
928
|
+
* @param {string} request.filter
|
|
929
|
+
* An expression for filtering the results of the request. Filter rules are
|
|
930
|
+
* case insensitive. The fields eligible for filtering are:
|
|
931
|
+
*
|
|
932
|
+
* * `labels.key` where key is the name of a label
|
|
933
|
+
*
|
|
934
|
+
* Some examples of using filters are:
|
|
935
|
+
*
|
|
936
|
+
* * `labels.env:*` --> The session has the label "env".
|
|
937
|
+
* * `labels.env:dev` --> The session has the label "env" and the value of
|
|
938
|
+
* the label contains the string "dev".
|
|
939
|
+
* @param {object} [options]
|
|
940
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
941
|
+
* @returns {Object}
|
|
942
|
+
* An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
|
|
943
|
+
* When you iterate the returned iterable, each element will be an object representing
|
|
944
|
+
* {@link protos.google.spanner.v1.Session|Session}. The API will be called under the hood as needed, once per the page,
|
|
945
|
+
* so you can stop the iteration when you don't need more results.
|
|
946
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
|
|
947
|
+
* for more details and examples.
|
|
948
|
+
*/
|
|
949
|
+
listSessionsAsync(request, options) {
|
|
950
|
+
var _a;
|
|
951
|
+
request = request || {};
|
|
952
|
+
options = options || {};
|
|
953
|
+
options.otherArgs = options.otherArgs || {};
|
|
954
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
955
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
956
|
+
this._gaxModule.routingHeader.fromParams({
|
|
957
|
+
database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
|
|
958
|
+
});
|
|
959
|
+
const defaultCallSettings = this._defaults['listSessions'];
|
|
960
|
+
const callSettings = defaultCallSettings.merge(options);
|
|
961
|
+
this.initialize();
|
|
962
|
+
return this.descriptors.page.listSessions.asyncIterate(this.innerApiCalls['listSessions'], request, callSettings);
|
|
963
|
+
}
|
|
964
|
+
// --------------------
|
|
965
|
+
// -- Path templates --
|
|
966
|
+
// --------------------
|
|
967
|
+
/**
|
|
968
|
+
* Return a fully-qualified database resource name string.
|
|
969
|
+
*
|
|
970
|
+
* @param {string} project
|
|
971
|
+
* @param {string} instance
|
|
972
|
+
* @param {string} database
|
|
973
|
+
* @returns {string} Resource name string.
|
|
974
|
+
*/
|
|
975
|
+
databasePath(project, instance, database) {
|
|
976
|
+
return this.pathTemplates.databasePathTemplate.render({
|
|
977
|
+
project: project,
|
|
978
|
+
instance: instance,
|
|
979
|
+
database: database,
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Parse the project from Database resource.
|
|
984
|
+
*
|
|
985
|
+
* @param {string} databaseName
|
|
986
|
+
* A fully-qualified path representing Database resource.
|
|
987
|
+
* @returns {string} A string representing the project.
|
|
988
|
+
*/
|
|
989
|
+
matchProjectFromDatabaseName(databaseName) {
|
|
990
|
+
return this.pathTemplates.databasePathTemplate.match(databaseName).project;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Parse the instance from Database resource.
|
|
994
|
+
*
|
|
995
|
+
* @param {string} databaseName
|
|
996
|
+
* A fully-qualified path representing Database resource.
|
|
997
|
+
* @returns {string} A string representing the instance.
|
|
998
|
+
*/
|
|
999
|
+
matchInstanceFromDatabaseName(databaseName) {
|
|
1000
|
+
return this.pathTemplates.databasePathTemplate.match(databaseName).instance;
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Parse the database from Database resource.
|
|
1004
|
+
*
|
|
1005
|
+
* @param {string} databaseName
|
|
1006
|
+
* A fully-qualified path representing Database resource.
|
|
1007
|
+
* @returns {string} A string representing the database.
|
|
1008
|
+
*/
|
|
1009
|
+
matchDatabaseFromDatabaseName(databaseName) {
|
|
1010
|
+
return this.pathTemplates.databasePathTemplate.match(databaseName).database;
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Return a fully-qualified session resource name string.
|
|
1014
|
+
*
|
|
1015
|
+
* @param {string} project
|
|
1016
|
+
* @param {string} instance
|
|
1017
|
+
* @param {string} database
|
|
1018
|
+
* @param {string} session
|
|
1019
|
+
* @returns {string} Resource name string.
|
|
1020
|
+
*/
|
|
1021
|
+
sessionPath(project, instance, database, session) {
|
|
1022
|
+
return this.pathTemplates.sessionPathTemplate.render({
|
|
1023
|
+
project: project,
|
|
1024
|
+
instance: instance,
|
|
1025
|
+
database: database,
|
|
1026
|
+
session: session,
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Parse the project from Session resource.
|
|
1031
|
+
*
|
|
1032
|
+
* @param {string} sessionName
|
|
1033
|
+
* A fully-qualified path representing Session resource.
|
|
1034
|
+
* @returns {string} A string representing the project.
|
|
1035
|
+
*/
|
|
1036
|
+
matchProjectFromSessionName(sessionName) {
|
|
1037
|
+
return this.pathTemplates.sessionPathTemplate.match(sessionName).project;
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Parse the instance from Session resource.
|
|
1041
|
+
*
|
|
1042
|
+
* @param {string} sessionName
|
|
1043
|
+
* A fully-qualified path representing Session resource.
|
|
1044
|
+
* @returns {string} A string representing the instance.
|
|
1045
|
+
*/
|
|
1046
|
+
matchInstanceFromSessionName(sessionName) {
|
|
1047
|
+
return this.pathTemplates.sessionPathTemplate.match(sessionName).instance;
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Parse the database from Session resource.
|
|
1051
|
+
*
|
|
1052
|
+
* @param {string} sessionName
|
|
1053
|
+
* A fully-qualified path representing Session resource.
|
|
1054
|
+
* @returns {string} A string representing the database.
|
|
1055
|
+
*/
|
|
1056
|
+
matchDatabaseFromSessionName(sessionName) {
|
|
1057
|
+
return this.pathTemplates.sessionPathTemplate.match(sessionName).database;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Parse the session from Session resource.
|
|
1061
|
+
*
|
|
1062
|
+
* @param {string} sessionName
|
|
1063
|
+
* A fully-qualified path representing Session resource.
|
|
1064
|
+
* @returns {string} A string representing the session.
|
|
1065
|
+
*/
|
|
1066
|
+
matchSessionFromSessionName(sessionName) {
|
|
1067
|
+
return this.pathTemplates.sessionPathTemplate.match(sessionName).session;
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Terminate the gRPC channel and close the client.
|
|
1071
|
+
*
|
|
1072
|
+
* The client will no longer be usable and all future behavior is undefined.
|
|
1073
|
+
* @returns {Promise} A promise that resolves when the client is closed.
|
|
1074
|
+
*/
|
|
1075
|
+
close() {
|
|
1076
|
+
if (this.spannerStub && !this._terminated) {
|
|
1077
|
+
return this.spannerStub.then(stub => {
|
|
1078
|
+
this._terminated = true;
|
|
1079
|
+
stub.close();
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
return Promise.resolve();
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
exports.SpannerClient = SpannerClient;
|
|
1086
|
+
//# sourceMappingURL=spanner_client.js.map
|