@google-cloud/spanner-api 0.1.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/README.md +111 -0
- package/build/protos/google/spanner/admin/database/v1/backup.proto +773 -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 +1314 -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 +2184 -0
- package/build/protos/google/spanner/executor/v1/cloud_executor.proto +1610 -0
- package/build/protos/google/spanner/v1/change_stream.proto +451 -0
- package/build/protos/google/spanner/v1/commit_response.proto +80 -0
- package/build/protos/google/spanner/v1/keys.proto +163 -0
- package/build/protos/google/spanner/v1/location.proto +388 -0
- package/build/protos/google/spanner/v1/mutation.proto +156 -0
- package/build/protos/google/spanner/v1/query_plan.proto +156 -0
- package/build/protos/google/spanner/v1/result_set.proto +260 -0
- package/build/protos/google/spanner/v1/spanner.proto +1472 -0
- package/build/protos/google/spanner/v1/transaction.proto +329 -0
- package/build/protos/google/spanner/v1/type.proto +214 -0
- package/build/protos/protos.d.ts +42547 -0
- package/build/protos/protos.js +1 -0
- package/build/protos/protos.json +1 -0
- package/build/src/index.d.ts +20 -0
- package/build/src/index.js +34 -0
- package/build/src/index.js.map +1 -0
- package/build/src/v1/database_admin_client.d.ts +2433 -0
- package/build/src/v1/database_admin_client.js +2938 -0
- package/build/src/v1/database_admin_client.js.map +1 -0
- package/build/src/v1/database_admin_client_config.json +169 -0
- package/build/src/v1/database_admin_proto_list.json +6 -0
- package/build/src/v1/gapic_metadata.json +253 -0
- package/build/src/v1/index.d.ts +4 -0
- package/build/src/v1/index.js +29 -0
- package/build/src/v1/index.js.map +1 -0
- package/build/src/v1/instance_admin_client.d.ts +2162 -0
- package/build/src/v1/instance_admin_client.js +2411 -0
- package/build/src/v1/instance_admin_client.js.map +1 -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 +1353 -0
- package/build/src/v1/spanner_client.js +1456 -0
- package/build/src/v1/spanner_client.js.map +1 -0
- package/build/src/v1/spanner_client_config.json +123 -0
- package/build/src/v1/spanner_executor_proxy_client.d.ts +419 -0
- package/build/src/v1/spanner_executor_proxy_client.js +730 -0
- package/build/src/v1/spanner_executor_proxy_client.js.map +1 -0
- package/build/src/v1/spanner_executor_proxy_client_config.json +30 -0
- package/build/src/v1/spanner_executor_proxy_proto_list.json +15 -0
- package/build/src/v1/spanner_proto_list.json +12 -0
- package/package.json +65 -0
|
@@ -0,0 +1,1456 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2026 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
|
+
const google_gax_1 = require("google-gax");
|
|
24
|
+
/**
|
|
25
|
+
* Client JSON configuration object, loaded from
|
|
26
|
+
* `src/v1/spanner_client_config.json`.
|
|
27
|
+
* This file defines retry strategy and timeouts for all API methods in this library.
|
|
28
|
+
*/
|
|
29
|
+
const gapicConfig = require("./spanner_client_config.json");
|
|
30
|
+
const version = require('../../../package.json').version;
|
|
31
|
+
/**
|
|
32
|
+
* Cloud Spanner API
|
|
33
|
+
*
|
|
34
|
+
* The Cloud Spanner API can be used to manage sessions and execute
|
|
35
|
+
* transactions on data stored in Cloud Spanner databases.
|
|
36
|
+
* @class
|
|
37
|
+
* @memberof v1
|
|
38
|
+
*/
|
|
39
|
+
class SpannerClient {
|
|
40
|
+
_terminated = false;
|
|
41
|
+
_opts;
|
|
42
|
+
_providedCustomServicePath;
|
|
43
|
+
_gaxModule;
|
|
44
|
+
_gaxGrpc;
|
|
45
|
+
_protos;
|
|
46
|
+
_defaults;
|
|
47
|
+
_universeDomain;
|
|
48
|
+
_servicePath;
|
|
49
|
+
_log = google_gax_1.loggingUtils.log('spanner-api');
|
|
50
|
+
auth;
|
|
51
|
+
descriptors = {
|
|
52
|
+
page: {},
|
|
53
|
+
stream: {},
|
|
54
|
+
longrunning: {},
|
|
55
|
+
batching: {},
|
|
56
|
+
};
|
|
57
|
+
warn;
|
|
58
|
+
innerApiCalls;
|
|
59
|
+
pathTemplates;
|
|
60
|
+
spannerStub;
|
|
61
|
+
/**
|
|
62
|
+
* Construct an instance of SpannerClient.
|
|
63
|
+
*
|
|
64
|
+
* @param {object} [options] - The configuration object.
|
|
65
|
+
* The options accepted by the constructor are described in detail
|
|
66
|
+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
|
|
67
|
+
* The common options are:
|
|
68
|
+
* @param {object} [options.credentials] - Credentials object.
|
|
69
|
+
* @param {string} [options.credentials.client_email]
|
|
70
|
+
* @param {string} [options.credentials.private_key]
|
|
71
|
+
* @param {string} [options.email] - Account email address. Required when
|
|
72
|
+
* using a .pem or .p12 keyFilename.
|
|
73
|
+
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
|
|
74
|
+
* .p12 key downloaded from the Google Developers Console. If you provide
|
|
75
|
+
* a path to a JSON file, the projectId option below is not necessary.
|
|
76
|
+
* NOTE: .pem and .p12 require you to specify options.email as well.
|
|
77
|
+
* @param {number} [options.port] - The port on which to connect to
|
|
78
|
+
* the remote host.
|
|
79
|
+
* @param {string} [options.projectId] - The project ID from the Google
|
|
80
|
+
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
|
|
81
|
+
* the environment variable GCLOUD_PROJECT for your project ID. If your
|
|
82
|
+
* app is running in an environment which supports
|
|
83
|
+
* {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
|
|
84
|
+
* your project ID will be detected automatically.
|
|
85
|
+
* @param {string} [options.apiEndpoint] - The domain name of the
|
|
86
|
+
* API remote host.
|
|
87
|
+
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
|
|
88
|
+
* Follows the structure of {@link gapicConfig}.
|
|
89
|
+
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
|
|
90
|
+
* For more information, please check the
|
|
91
|
+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
|
|
92
|
+
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
|
|
93
|
+
* need to avoid loading the default gRPC version and want to use the fallback
|
|
94
|
+
* HTTP implementation. Load only fallback version and pass it to the constructor:
|
|
95
|
+
* ```
|
|
96
|
+
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
|
|
97
|
+
* const client = new SpannerClient({fallback: true}, gax);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
constructor(opts, gaxInstance) {
|
|
101
|
+
// Ensure that options include all the required fields.
|
|
102
|
+
const staticMembers = this.constructor;
|
|
103
|
+
if (opts?.universe_domain &&
|
|
104
|
+
opts?.universeDomain &&
|
|
105
|
+
opts?.universe_domain !== opts?.universeDomain) {
|
|
106
|
+
throw new Error('Please set either universe_domain or universeDomain, but not both.');
|
|
107
|
+
}
|
|
108
|
+
const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
|
|
109
|
+
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
|
|
110
|
+
: undefined;
|
|
111
|
+
this._universeDomain =
|
|
112
|
+
opts?.universeDomain ??
|
|
113
|
+
opts?.universe_domain ??
|
|
114
|
+
universeDomainEnvVar ??
|
|
115
|
+
'googleapis.com';
|
|
116
|
+
this._servicePath = 'spanner.' + this._universeDomain;
|
|
117
|
+
const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
|
|
118
|
+
this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
|
|
119
|
+
const port = opts?.port || staticMembers.port;
|
|
120
|
+
const clientConfig = opts?.clientConfig ?? {};
|
|
121
|
+
const fallback = opts?.fallback ??
|
|
122
|
+
(typeof window !== 'undefined' && typeof window?.fetch === 'function');
|
|
123
|
+
opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
|
|
124
|
+
// Request numeric enum values if REST transport is used.
|
|
125
|
+
opts.numericEnums = true;
|
|
126
|
+
// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
|
|
127
|
+
if (servicePath !== this._servicePath && !('scopes' in opts)) {
|
|
128
|
+
opts['scopes'] = staticMembers.scopes;
|
|
129
|
+
}
|
|
130
|
+
// Load google-gax module synchronously if needed
|
|
131
|
+
if (!gaxInstance) {
|
|
132
|
+
gaxInstance = require('google-gax');
|
|
133
|
+
}
|
|
134
|
+
// Choose either gRPC or proto-over-HTTP implementation of google-gax.
|
|
135
|
+
this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
|
|
136
|
+
// Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
|
|
137
|
+
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
|
|
138
|
+
// Save options to use in initialize() method.
|
|
139
|
+
this._opts = opts;
|
|
140
|
+
// Save the auth object to the client, for use by other methods.
|
|
141
|
+
this.auth = this._gaxGrpc.auth;
|
|
142
|
+
// Set useJWTAccessWithScope on the auth object.
|
|
143
|
+
this.auth.useJWTAccessWithScope = true;
|
|
144
|
+
// Set defaultServicePath on the auth object.
|
|
145
|
+
this.auth.defaultServicePath = this._servicePath;
|
|
146
|
+
// Set the default scopes in auth client if needed.
|
|
147
|
+
if (servicePath === this._servicePath) {
|
|
148
|
+
this.auth.defaultScopes = staticMembers.scopes;
|
|
149
|
+
}
|
|
150
|
+
// Determine the client header string.
|
|
151
|
+
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
|
|
152
|
+
if (typeof process === 'object' && 'versions' in process) {
|
|
153
|
+
clientHeader.push(`gl-node/${process.versions.node}`);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
clientHeader.push(`gl-web/${this._gaxModule.version}`);
|
|
157
|
+
}
|
|
158
|
+
if (!opts.fallback) {
|
|
159
|
+
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
|
|
163
|
+
}
|
|
164
|
+
if (opts.libName && opts.libVersion) {
|
|
165
|
+
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
|
|
166
|
+
}
|
|
167
|
+
// Load the applicable protos.
|
|
168
|
+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
|
|
169
|
+
// This API contains "path templates"; forward-slash-separated
|
|
170
|
+
// identifiers to uniquely identify resources within the API.
|
|
171
|
+
// Create useful helper objects for these.
|
|
172
|
+
this.pathTemplates = {
|
|
173
|
+
databasePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/instances/{instance}/databases/{database}'),
|
|
174
|
+
sessionPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/instances/{instance}/databases/{database}/sessions/{session}'),
|
|
175
|
+
};
|
|
176
|
+
// Some of the methods on this service return "paged" results,
|
|
177
|
+
// (e.g. 50 results at a time, with tokens to get subsequent
|
|
178
|
+
// pages). Denote the keys used for pagination and results.
|
|
179
|
+
this.descriptors.page = {
|
|
180
|
+
listSessions: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'sessions'),
|
|
181
|
+
};
|
|
182
|
+
// Some of the methods on this service provide streaming responses.
|
|
183
|
+
// Provide descriptors for these.
|
|
184
|
+
this.descriptors.stream = {
|
|
185
|
+
executeStreamingSql: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
186
|
+
streamingRead: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
187
|
+
batchWrite: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
188
|
+
fetchCacheUpdate: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
|
|
189
|
+
};
|
|
190
|
+
// Put together the default options sent with requests.
|
|
191
|
+
this._defaults = this._gaxGrpc.constructSettings('google.spanner.v1.Spanner', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
|
|
192
|
+
// Set up a dictionary of "inner API calls"; the core implementation
|
|
193
|
+
// of calling the API is handled in `google-gax`, with this code
|
|
194
|
+
// merely providing the destination and request information.
|
|
195
|
+
this.innerApiCalls = {};
|
|
196
|
+
// Add a warn function to the client constructor so it can be easily tested.
|
|
197
|
+
this.warn = this._gaxModule.warn;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Initialize the client.
|
|
201
|
+
* Performs asynchronous operations (such as authentication) and prepares the client.
|
|
202
|
+
* This function will be called automatically when any class method is called for the
|
|
203
|
+
* first time, but if you need to initialize it before calling an actual method,
|
|
204
|
+
* feel free to call initialize() directly.
|
|
205
|
+
*
|
|
206
|
+
* You can await on this method if you want to make sure the client is initialized.
|
|
207
|
+
*
|
|
208
|
+
* @returns {Promise} A promise that resolves to an authenticated service stub.
|
|
209
|
+
*/
|
|
210
|
+
initialize() {
|
|
211
|
+
// If the client stub promise is already initialized, return immediately.
|
|
212
|
+
if (this.spannerStub) {
|
|
213
|
+
return this.spannerStub;
|
|
214
|
+
}
|
|
215
|
+
// Put together the "service stub" for
|
|
216
|
+
// google.spanner.v1.Spanner.
|
|
217
|
+
this.spannerStub = this._gaxGrpc.createStub(this._opts.fallback
|
|
218
|
+
? this._protos.lookupService('google.spanner.v1.Spanner')
|
|
219
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
220
|
+
this._protos.google.spanner.v1.Spanner, this._opts, this._providedCustomServicePath);
|
|
221
|
+
// Iterate over each of the methods that the service provides
|
|
222
|
+
// and create an API call method for each.
|
|
223
|
+
const spannerStubMethods = [
|
|
224
|
+
'createSession',
|
|
225
|
+
'batchCreateSessions',
|
|
226
|
+
'getSession',
|
|
227
|
+
'listSessions',
|
|
228
|
+
'deleteSession',
|
|
229
|
+
'executeSql',
|
|
230
|
+
'executeStreamingSql',
|
|
231
|
+
'executeBatchDml',
|
|
232
|
+
'read',
|
|
233
|
+
'streamingRead',
|
|
234
|
+
'beginTransaction',
|
|
235
|
+
'commit',
|
|
236
|
+
'rollback',
|
|
237
|
+
'partitionQuery',
|
|
238
|
+
'partitionRead',
|
|
239
|
+
'batchWrite',
|
|
240
|
+
'fetchCacheUpdate',
|
|
241
|
+
];
|
|
242
|
+
for (const methodName of spannerStubMethods) {
|
|
243
|
+
const callPromise = this.spannerStub.then((stub) => (...args) => {
|
|
244
|
+
if (this._terminated) {
|
|
245
|
+
if (methodName in this.descriptors.stream) {
|
|
246
|
+
const stream = new stream_1.PassThrough({ objectMode: true });
|
|
247
|
+
setImmediate(() => {
|
|
248
|
+
stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.'));
|
|
249
|
+
});
|
|
250
|
+
return stream;
|
|
251
|
+
}
|
|
252
|
+
return Promise.reject('The client has already been closed.');
|
|
253
|
+
}
|
|
254
|
+
const func = stub[methodName];
|
|
255
|
+
return func.apply(stub, args);
|
|
256
|
+
}, (err) => () => {
|
|
257
|
+
throw err;
|
|
258
|
+
});
|
|
259
|
+
const descriptor = this.descriptors.page[methodName] ||
|
|
260
|
+
this.descriptors.stream[methodName] ||
|
|
261
|
+
undefined;
|
|
262
|
+
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
|
|
263
|
+
this.innerApiCalls[methodName] = apiCall;
|
|
264
|
+
}
|
|
265
|
+
return this.spannerStub;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* The DNS address for this API service.
|
|
269
|
+
* @deprecated Use the apiEndpoint method of the client instance.
|
|
270
|
+
* @returns {string} The DNS address for this service.
|
|
271
|
+
*/
|
|
272
|
+
static get servicePath() {
|
|
273
|
+
if (typeof process === 'object' &&
|
|
274
|
+
typeof process.emitWarning === 'function') {
|
|
275
|
+
process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
|
|
276
|
+
}
|
|
277
|
+
return 'spanner.googleapis.com';
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* The DNS address for this API service - same as servicePath.
|
|
281
|
+
* @deprecated Use the apiEndpoint method of the client instance.
|
|
282
|
+
* @returns {string} The DNS address for this service.
|
|
283
|
+
*/
|
|
284
|
+
static get apiEndpoint() {
|
|
285
|
+
if (typeof process === 'object' &&
|
|
286
|
+
typeof process.emitWarning === 'function') {
|
|
287
|
+
process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
|
|
288
|
+
}
|
|
289
|
+
return 'spanner.googleapis.com';
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The DNS address for this API service.
|
|
293
|
+
* @returns {string} The DNS address for this service.
|
|
294
|
+
*/
|
|
295
|
+
get apiEndpoint() {
|
|
296
|
+
return this._servicePath;
|
|
297
|
+
}
|
|
298
|
+
get universeDomain() {
|
|
299
|
+
return this._universeDomain;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* The port for this API service.
|
|
303
|
+
* @returns {number} The default port for this service.
|
|
304
|
+
*/
|
|
305
|
+
static get port() {
|
|
306
|
+
return 443;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The scopes needed to make gRPC calls for every method defined
|
|
310
|
+
* in this service.
|
|
311
|
+
* @returns {string[]} List of default scopes.
|
|
312
|
+
*/
|
|
313
|
+
static get scopes() {
|
|
314
|
+
return [
|
|
315
|
+
'https://www.googleapis.com/auth/cloud-platform',
|
|
316
|
+
'https://www.googleapis.com/auth/spanner.data',
|
|
317
|
+
];
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Return the project ID used by this class.
|
|
321
|
+
* @returns {Promise} A promise that resolves to string containing the project ID.
|
|
322
|
+
*/
|
|
323
|
+
getProjectId(callback) {
|
|
324
|
+
if (callback) {
|
|
325
|
+
this.auth.getProjectId(callback);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
return this.auth.getProjectId();
|
|
329
|
+
}
|
|
330
|
+
createSession(request, optionsOrCallback, callback) {
|
|
331
|
+
request = request || {};
|
|
332
|
+
let options;
|
|
333
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
334
|
+
callback = optionsOrCallback;
|
|
335
|
+
options = {};
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
options = optionsOrCallback;
|
|
339
|
+
}
|
|
340
|
+
options = options || {};
|
|
341
|
+
options.otherArgs = options.otherArgs || {};
|
|
342
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
343
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
344
|
+
this._gaxModule.routingHeader.fromParams({
|
|
345
|
+
database: request.database ?? '',
|
|
346
|
+
});
|
|
347
|
+
this.initialize().catch((err) => {
|
|
348
|
+
throw err;
|
|
349
|
+
});
|
|
350
|
+
this._log.info('createSession request %j', request);
|
|
351
|
+
const wrappedCallback = callback
|
|
352
|
+
? (error, response, options, rawResponse) => {
|
|
353
|
+
this._log.info('createSession response %j', response);
|
|
354
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
355
|
+
}
|
|
356
|
+
: undefined;
|
|
357
|
+
return this.innerApiCalls
|
|
358
|
+
.createSession(request, options, wrappedCallback)
|
|
359
|
+
?.then(([response, options, rawResponse]) => {
|
|
360
|
+
this._log.info('createSession response %j', response);
|
|
361
|
+
return [response, options, rawResponse];
|
|
362
|
+
})
|
|
363
|
+
.catch((error) => {
|
|
364
|
+
if (error &&
|
|
365
|
+
'statusDetails' in error &&
|
|
366
|
+
error.statusDetails instanceof Array) {
|
|
367
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
368
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
369
|
+
}
|
|
370
|
+
throw error;
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
batchCreateSessions(request, optionsOrCallback, callback) {
|
|
374
|
+
request = request || {};
|
|
375
|
+
let options;
|
|
376
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
377
|
+
callback = optionsOrCallback;
|
|
378
|
+
options = {};
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
options = optionsOrCallback;
|
|
382
|
+
}
|
|
383
|
+
options = options || {};
|
|
384
|
+
options.otherArgs = options.otherArgs || {};
|
|
385
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
386
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
387
|
+
this._gaxModule.routingHeader.fromParams({
|
|
388
|
+
database: request.database ?? '',
|
|
389
|
+
});
|
|
390
|
+
this.initialize().catch((err) => {
|
|
391
|
+
throw err;
|
|
392
|
+
});
|
|
393
|
+
this._log.info('batchCreateSessions request %j', request);
|
|
394
|
+
const wrappedCallback = callback
|
|
395
|
+
? (error, response, options, rawResponse) => {
|
|
396
|
+
this._log.info('batchCreateSessions response %j', response);
|
|
397
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
398
|
+
}
|
|
399
|
+
: undefined;
|
|
400
|
+
return this.innerApiCalls
|
|
401
|
+
.batchCreateSessions(request, options, wrappedCallback)
|
|
402
|
+
?.then(([response, options, rawResponse]) => {
|
|
403
|
+
this._log.info('batchCreateSessions response %j', response);
|
|
404
|
+
return [response, options, rawResponse];
|
|
405
|
+
})
|
|
406
|
+
.catch((error) => {
|
|
407
|
+
if (error &&
|
|
408
|
+
'statusDetails' in error &&
|
|
409
|
+
error.statusDetails instanceof Array) {
|
|
410
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
411
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
412
|
+
}
|
|
413
|
+
throw error;
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
getSession(request, optionsOrCallback, callback) {
|
|
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
|
+
name: request.name ?? '',
|
|
432
|
+
});
|
|
433
|
+
this.initialize().catch((err) => {
|
|
434
|
+
throw err;
|
|
435
|
+
});
|
|
436
|
+
this._log.info('getSession request %j', request);
|
|
437
|
+
const wrappedCallback = callback
|
|
438
|
+
? (error, response, options, rawResponse) => {
|
|
439
|
+
this._log.info('getSession response %j', response);
|
|
440
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
441
|
+
}
|
|
442
|
+
: undefined;
|
|
443
|
+
return this.innerApiCalls
|
|
444
|
+
.getSession(request, options, wrappedCallback)
|
|
445
|
+
?.then(([response, options, rawResponse]) => {
|
|
446
|
+
this._log.info('getSession response %j', response);
|
|
447
|
+
return [response, options, rawResponse];
|
|
448
|
+
})
|
|
449
|
+
.catch((error) => {
|
|
450
|
+
if (error &&
|
|
451
|
+
'statusDetails' in error &&
|
|
452
|
+
error.statusDetails instanceof Array) {
|
|
453
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
454
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
455
|
+
}
|
|
456
|
+
throw error;
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
deleteSession(request, optionsOrCallback, callback) {
|
|
460
|
+
request = request || {};
|
|
461
|
+
let options;
|
|
462
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
463
|
+
callback = optionsOrCallback;
|
|
464
|
+
options = {};
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
options = optionsOrCallback;
|
|
468
|
+
}
|
|
469
|
+
options = options || {};
|
|
470
|
+
options.otherArgs = options.otherArgs || {};
|
|
471
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
472
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
473
|
+
this._gaxModule.routingHeader.fromParams({
|
|
474
|
+
name: request.name ?? '',
|
|
475
|
+
});
|
|
476
|
+
this.initialize().catch((err) => {
|
|
477
|
+
throw err;
|
|
478
|
+
});
|
|
479
|
+
this._log.info('deleteSession request %j', request);
|
|
480
|
+
const wrappedCallback = callback
|
|
481
|
+
? (error, response, options, rawResponse) => {
|
|
482
|
+
this._log.info('deleteSession response %j', response);
|
|
483
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
484
|
+
}
|
|
485
|
+
: undefined;
|
|
486
|
+
return this.innerApiCalls
|
|
487
|
+
.deleteSession(request, options, wrappedCallback)
|
|
488
|
+
?.then(([response, options, rawResponse]) => {
|
|
489
|
+
this._log.info('deleteSession response %j', response);
|
|
490
|
+
return [response, options, rawResponse];
|
|
491
|
+
})
|
|
492
|
+
.catch((error) => {
|
|
493
|
+
if (error &&
|
|
494
|
+
'statusDetails' in error &&
|
|
495
|
+
error.statusDetails instanceof Array) {
|
|
496
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
497
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
498
|
+
}
|
|
499
|
+
throw error;
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
executeSql(request, optionsOrCallback, callback) {
|
|
503
|
+
request = request || {};
|
|
504
|
+
let options;
|
|
505
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
506
|
+
callback = optionsOrCallback;
|
|
507
|
+
options = {};
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
options = optionsOrCallback;
|
|
511
|
+
}
|
|
512
|
+
options = options || {};
|
|
513
|
+
options.otherArgs = options.otherArgs || {};
|
|
514
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
515
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
516
|
+
this._gaxModule.routingHeader.fromParams({
|
|
517
|
+
session: request.session ?? '',
|
|
518
|
+
});
|
|
519
|
+
this.initialize().catch((err) => {
|
|
520
|
+
throw err;
|
|
521
|
+
});
|
|
522
|
+
this._log.info('executeSql request %j', request);
|
|
523
|
+
const wrappedCallback = callback
|
|
524
|
+
? (error, response, options, rawResponse) => {
|
|
525
|
+
this._log.info('executeSql response %j', response);
|
|
526
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
527
|
+
}
|
|
528
|
+
: undefined;
|
|
529
|
+
return this.innerApiCalls
|
|
530
|
+
.executeSql(request, options, wrappedCallback)
|
|
531
|
+
?.then(([response, options, rawResponse]) => {
|
|
532
|
+
this._log.info('executeSql response %j', response);
|
|
533
|
+
return [response, options, rawResponse];
|
|
534
|
+
})
|
|
535
|
+
.catch((error) => {
|
|
536
|
+
if (error &&
|
|
537
|
+
'statusDetails' in error &&
|
|
538
|
+
error.statusDetails instanceof Array) {
|
|
539
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
540
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
541
|
+
}
|
|
542
|
+
throw error;
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
executeBatchDml(request, optionsOrCallback, callback) {
|
|
546
|
+
request = request || {};
|
|
547
|
+
let options;
|
|
548
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
549
|
+
callback = optionsOrCallback;
|
|
550
|
+
options = {};
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
options = optionsOrCallback;
|
|
554
|
+
}
|
|
555
|
+
options = options || {};
|
|
556
|
+
options.otherArgs = options.otherArgs || {};
|
|
557
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
558
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
559
|
+
this._gaxModule.routingHeader.fromParams({
|
|
560
|
+
session: request.session ?? '',
|
|
561
|
+
});
|
|
562
|
+
this.initialize().catch((err) => {
|
|
563
|
+
throw err;
|
|
564
|
+
});
|
|
565
|
+
this._log.info('executeBatchDml request %j', request);
|
|
566
|
+
const wrappedCallback = callback
|
|
567
|
+
? (error, response, options, rawResponse) => {
|
|
568
|
+
this._log.info('executeBatchDml response %j', response);
|
|
569
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
570
|
+
}
|
|
571
|
+
: undefined;
|
|
572
|
+
return this.innerApiCalls
|
|
573
|
+
.executeBatchDml(request, options, wrappedCallback)
|
|
574
|
+
?.then(([response, options, rawResponse]) => {
|
|
575
|
+
this._log.info('executeBatchDml response %j', response);
|
|
576
|
+
return [response, options, rawResponse];
|
|
577
|
+
})
|
|
578
|
+
.catch((error) => {
|
|
579
|
+
if (error &&
|
|
580
|
+
'statusDetails' in error &&
|
|
581
|
+
error.statusDetails instanceof Array) {
|
|
582
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
583
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
584
|
+
}
|
|
585
|
+
throw error;
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
read(request, optionsOrCallback, callback) {
|
|
589
|
+
request = request || {};
|
|
590
|
+
let options;
|
|
591
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
592
|
+
callback = optionsOrCallback;
|
|
593
|
+
options = {};
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
options = optionsOrCallback;
|
|
597
|
+
}
|
|
598
|
+
options = options || {};
|
|
599
|
+
options.otherArgs = options.otherArgs || {};
|
|
600
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
601
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
602
|
+
this._gaxModule.routingHeader.fromParams({
|
|
603
|
+
session: request.session ?? '',
|
|
604
|
+
});
|
|
605
|
+
this.initialize().catch((err) => {
|
|
606
|
+
throw err;
|
|
607
|
+
});
|
|
608
|
+
this._log.info('read request %j', request);
|
|
609
|
+
const wrappedCallback = callback
|
|
610
|
+
? (error, response, options, rawResponse) => {
|
|
611
|
+
this._log.info('read response %j', response);
|
|
612
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
613
|
+
}
|
|
614
|
+
: undefined;
|
|
615
|
+
return this.innerApiCalls
|
|
616
|
+
.read(request, options, wrappedCallback)
|
|
617
|
+
?.then(([response, options, rawResponse]) => {
|
|
618
|
+
this._log.info('read response %j', response);
|
|
619
|
+
return [response, options, rawResponse];
|
|
620
|
+
})
|
|
621
|
+
.catch((error) => {
|
|
622
|
+
if (error &&
|
|
623
|
+
'statusDetails' in error &&
|
|
624
|
+
error.statusDetails instanceof Array) {
|
|
625
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
626
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
627
|
+
}
|
|
628
|
+
throw error;
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
beginTransaction(request, optionsOrCallback, callback) {
|
|
632
|
+
request = request || {};
|
|
633
|
+
let options;
|
|
634
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
635
|
+
callback = optionsOrCallback;
|
|
636
|
+
options = {};
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
options = optionsOrCallback;
|
|
640
|
+
}
|
|
641
|
+
options = options || {};
|
|
642
|
+
options.otherArgs = options.otherArgs || {};
|
|
643
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
644
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
645
|
+
this._gaxModule.routingHeader.fromParams({
|
|
646
|
+
session: request.session ?? '',
|
|
647
|
+
});
|
|
648
|
+
this.initialize().catch((err) => {
|
|
649
|
+
throw err;
|
|
650
|
+
});
|
|
651
|
+
this._log.info('beginTransaction request %j', request);
|
|
652
|
+
const wrappedCallback = callback
|
|
653
|
+
? (error, response, options, rawResponse) => {
|
|
654
|
+
this._log.info('beginTransaction response %j', response);
|
|
655
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
656
|
+
}
|
|
657
|
+
: undefined;
|
|
658
|
+
return this.innerApiCalls
|
|
659
|
+
.beginTransaction(request, options, wrappedCallback)
|
|
660
|
+
?.then(([response, options, rawResponse]) => {
|
|
661
|
+
this._log.info('beginTransaction response %j', response);
|
|
662
|
+
return [response, options, rawResponse];
|
|
663
|
+
})
|
|
664
|
+
.catch((error) => {
|
|
665
|
+
if (error &&
|
|
666
|
+
'statusDetails' in error &&
|
|
667
|
+
error.statusDetails instanceof Array) {
|
|
668
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
669
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
670
|
+
}
|
|
671
|
+
throw error;
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
commit(request, optionsOrCallback, callback) {
|
|
675
|
+
request = request || {};
|
|
676
|
+
let options;
|
|
677
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
678
|
+
callback = optionsOrCallback;
|
|
679
|
+
options = {};
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
options = optionsOrCallback;
|
|
683
|
+
}
|
|
684
|
+
options = options || {};
|
|
685
|
+
options.otherArgs = options.otherArgs || {};
|
|
686
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
687
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
688
|
+
this._gaxModule.routingHeader.fromParams({
|
|
689
|
+
session: request.session ?? '',
|
|
690
|
+
});
|
|
691
|
+
this.initialize().catch((err) => {
|
|
692
|
+
throw err;
|
|
693
|
+
});
|
|
694
|
+
this._log.info('commit request %j', request);
|
|
695
|
+
const wrappedCallback = callback
|
|
696
|
+
? (error, response, options, rawResponse) => {
|
|
697
|
+
this._log.info('commit response %j', response);
|
|
698
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
699
|
+
}
|
|
700
|
+
: undefined;
|
|
701
|
+
return this.innerApiCalls
|
|
702
|
+
.commit(request, options, wrappedCallback)
|
|
703
|
+
?.then(([response, options, rawResponse]) => {
|
|
704
|
+
this._log.info('commit response %j', response);
|
|
705
|
+
return [response, options, rawResponse];
|
|
706
|
+
})
|
|
707
|
+
.catch((error) => {
|
|
708
|
+
if (error &&
|
|
709
|
+
'statusDetails' in error &&
|
|
710
|
+
error.statusDetails instanceof Array) {
|
|
711
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
712
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
713
|
+
}
|
|
714
|
+
throw error;
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
rollback(request, optionsOrCallback, callback) {
|
|
718
|
+
request = request || {};
|
|
719
|
+
let options;
|
|
720
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
721
|
+
callback = optionsOrCallback;
|
|
722
|
+
options = {};
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
options = optionsOrCallback;
|
|
726
|
+
}
|
|
727
|
+
options = options || {};
|
|
728
|
+
options.otherArgs = options.otherArgs || {};
|
|
729
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
730
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
731
|
+
this._gaxModule.routingHeader.fromParams({
|
|
732
|
+
session: request.session ?? '',
|
|
733
|
+
});
|
|
734
|
+
this.initialize().catch((err) => {
|
|
735
|
+
throw err;
|
|
736
|
+
});
|
|
737
|
+
this._log.info('rollback request %j', request);
|
|
738
|
+
const wrappedCallback = callback
|
|
739
|
+
? (error, response, options, rawResponse) => {
|
|
740
|
+
this._log.info('rollback response %j', response);
|
|
741
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
742
|
+
}
|
|
743
|
+
: undefined;
|
|
744
|
+
return this.innerApiCalls
|
|
745
|
+
.rollback(request, options, wrappedCallback)
|
|
746
|
+
?.then(([response, options, rawResponse]) => {
|
|
747
|
+
this._log.info('rollback response %j', response);
|
|
748
|
+
return [response, options, rawResponse];
|
|
749
|
+
})
|
|
750
|
+
.catch((error) => {
|
|
751
|
+
if (error &&
|
|
752
|
+
'statusDetails' in error &&
|
|
753
|
+
error.statusDetails instanceof Array) {
|
|
754
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
755
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
756
|
+
}
|
|
757
|
+
throw error;
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
partitionQuery(request, optionsOrCallback, callback) {
|
|
761
|
+
request = request || {};
|
|
762
|
+
let options;
|
|
763
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
764
|
+
callback = optionsOrCallback;
|
|
765
|
+
options = {};
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
options = optionsOrCallback;
|
|
769
|
+
}
|
|
770
|
+
options = options || {};
|
|
771
|
+
options.otherArgs = options.otherArgs || {};
|
|
772
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
773
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
774
|
+
this._gaxModule.routingHeader.fromParams({
|
|
775
|
+
session: request.session ?? '',
|
|
776
|
+
});
|
|
777
|
+
this.initialize().catch((err) => {
|
|
778
|
+
throw err;
|
|
779
|
+
});
|
|
780
|
+
this._log.info('partitionQuery request %j', request);
|
|
781
|
+
const wrappedCallback = callback
|
|
782
|
+
? (error, response, options, rawResponse) => {
|
|
783
|
+
this._log.info('partitionQuery response %j', response);
|
|
784
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
785
|
+
}
|
|
786
|
+
: undefined;
|
|
787
|
+
return this.innerApiCalls
|
|
788
|
+
.partitionQuery(request, options, wrappedCallback)
|
|
789
|
+
?.then(([response, options, rawResponse]) => {
|
|
790
|
+
this._log.info('partitionQuery response %j', response);
|
|
791
|
+
return [response, options, rawResponse];
|
|
792
|
+
})
|
|
793
|
+
.catch((error) => {
|
|
794
|
+
if (error &&
|
|
795
|
+
'statusDetails' in error &&
|
|
796
|
+
error.statusDetails instanceof Array) {
|
|
797
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
798
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
799
|
+
}
|
|
800
|
+
throw error;
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
partitionRead(request, optionsOrCallback, callback) {
|
|
804
|
+
request = request || {};
|
|
805
|
+
let options;
|
|
806
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
807
|
+
callback = optionsOrCallback;
|
|
808
|
+
options = {};
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
options = optionsOrCallback;
|
|
812
|
+
}
|
|
813
|
+
options = options || {};
|
|
814
|
+
options.otherArgs = options.otherArgs || {};
|
|
815
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
816
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
817
|
+
this._gaxModule.routingHeader.fromParams({
|
|
818
|
+
session: request.session ?? '',
|
|
819
|
+
});
|
|
820
|
+
this.initialize().catch((err) => {
|
|
821
|
+
throw err;
|
|
822
|
+
});
|
|
823
|
+
this._log.info('partitionRead request %j', request);
|
|
824
|
+
const wrappedCallback = callback
|
|
825
|
+
? (error, response, options, rawResponse) => {
|
|
826
|
+
this._log.info('partitionRead response %j', response);
|
|
827
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
828
|
+
}
|
|
829
|
+
: undefined;
|
|
830
|
+
return this.innerApiCalls
|
|
831
|
+
.partitionRead(request, options, wrappedCallback)
|
|
832
|
+
?.then(([response, options, rawResponse]) => {
|
|
833
|
+
this._log.info('partitionRead response %j', response);
|
|
834
|
+
return [response, options, rawResponse];
|
|
835
|
+
})
|
|
836
|
+
.catch((error) => {
|
|
837
|
+
if (error &&
|
|
838
|
+
'statusDetails' in error &&
|
|
839
|
+
error.statusDetails instanceof Array) {
|
|
840
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
841
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
842
|
+
}
|
|
843
|
+
throw error;
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Like {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, except returns the
|
|
848
|
+
* result set as a stream. Unlike
|
|
849
|
+
* {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, there is no limit on
|
|
850
|
+
* the size of the returned result set. However, no individual row in the
|
|
851
|
+
* result set can exceed 100 MiB, and no column value can exceed 10 MiB.
|
|
852
|
+
*
|
|
853
|
+
* The query string can be SQL or [Graph Query Language
|
|
854
|
+
* (GQL)](https://cloud.google.com/spanner/docs/reference/standard-sql/graph-intro).
|
|
855
|
+
*
|
|
856
|
+
* @param {Object} request
|
|
857
|
+
* The request object that will be sent.
|
|
858
|
+
* @param {string} request.session
|
|
859
|
+
* Required. The session in which the SQL query should be performed.
|
|
860
|
+
* @param {google.spanner.v1.TransactionSelector} request.transaction
|
|
861
|
+
* The transaction to use.
|
|
862
|
+
*
|
|
863
|
+
* For queries, if none is provided, the default is a temporary read-only
|
|
864
|
+
* transaction with strong concurrency.
|
|
865
|
+
*
|
|
866
|
+
* Standard DML statements require a read-write transaction. To protect
|
|
867
|
+
* against replays, single-use transactions are not supported. The caller
|
|
868
|
+
* must either supply an existing transaction ID or begin a new transaction.
|
|
869
|
+
*
|
|
870
|
+
* Partitioned DML requires an existing Partitioned DML transaction ID.
|
|
871
|
+
* @param {string} request.sql
|
|
872
|
+
* Required. The SQL string.
|
|
873
|
+
* @param {google.protobuf.Struct} request.params
|
|
874
|
+
* Parameter names and values that bind to placeholders in the SQL string.
|
|
875
|
+
*
|
|
876
|
+
* A parameter placeholder consists of the `@` character followed by the
|
|
877
|
+
* parameter name (for example, `@firstName`). Parameter names must conform
|
|
878
|
+
* to the naming requirements of identifiers as specified at
|
|
879
|
+
* https://cloud.google.com/spanner/docs/lexical#identifiers.
|
|
880
|
+
*
|
|
881
|
+
* Parameters can appear anywhere that a literal value is expected. The same
|
|
882
|
+
* parameter name can be used more than once, for example:
|
|
883
|
+
*
|
|
884
|
+
* `"WHERE id > @msg_id AND id < @msg_id + 100"`
|
|
885
|
+
*
|
|
886
|
+
* It's an error to execute a SQL statement with unbound parameters.
|
|
887
|
+
* @param {number[]} request.paramTypes
|
|
888
|
+
* It isn't always possible for Cloud Spanner to infer the right SQL type
|
|
889
|
+
* from a JSON value. For example, values of type `BYTES` and values
|
|
890
|
+
* of type `STRING` both appear in
|
|
891
|
+
* {@link protos.google.spanner.v1.ExecuteSqlRequest.params|params} as JSON strings.
|
|
892
|
+
*
|
|
893
|
+
* In these cases, you can use `param_types` to specify the exact
|
|
894
|
+
* SQL type for some or all of the SQL statement parameters. See the
|
|
895
|
+
* definition of {@link protos.google.spanner.v1.Type|Type} for more information
|
|
896
|
+
* about SQL types.
|
|
897
|
+
* @param {Buffer} request.resumeToken
|
|
898
|
+
* If this request is resuming a previously interrupted SQL statement
|
|
899
|
+
* execution, `resume_token` should be copied from the last
|
|
900
|
+
* {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the
|
|
901
|
+
* interruption. Doing this enables the new SQL statement execution to resume
|
|
902
|
+
* where the last one left off. The rest of the request parameters must
|
|
903
|
+
* exactly match the request that yielded this token.
|
|
904
|
+
* @param {google.spanner.v1.ExecuteSqlRequest.QueryMode} request.queryMode
|
|
905
|
+
* Used to control the amount of debugging information returned in
|
|
906
|
+
* {@link protos.google.spanner.v1.ResultSetStats|ResultSetStats}. If
|
|
907
|
+
* {@link protos.google.spanner.v1.ExecuteSqlRequest.partition_token|partition_token} is
|
|
908
|
+
* set, {@link protos.google.spanner.v1.ExecuteSqlRequest.query_mode|query_mode} can only
|
|
909
|
+
* be set to
|
|
910
|
+
* {@link protos.google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL|QueryMode.NORMAL}.
|
|
911
|
+
* @param {Buffer} request.partitionToken
|
|
912
|
+
* If present, results are restricted to the specified partition
|
|
913
|
+
* previously created using `PartitionQuery`. There must be an exact
|
|
914
|
+
* match for the values of fields common to this message and the
|
|
915
|
+
* `PartitionQueryRequest` message used to create this `partition_token`.
|
|
916
|
+
* @param {number} request.seqno
|
|
917
|
+
* A per-transaction sequence number used to identify this request. This field
|
|
918
|
+
* makes each request idempotent such that if the request is received multiple
|
|
919
|
+
* times, at most one succeeds.
|
|
920
|
+
*
|
|
921
|
+
* The sequence number must be monotonically increasing within the
|
|
922
|
+
* transaction. If a request arrives for the first time with an out-of-order
|
|
923
|
+
* sequence number, the transaction can be aborted. Replays of previously
|
|
924
|
+
* handled requests yield the same response as the first execution.
|
|
925
|
+
*
|
|
926
|
+
* Required for DML statements. Ignored for queries.
|
|
927
|
+
* @param {google.spanner.v1.ExecuteSqlRequest.QueryOptions} request.queryOptions
|
|
928
|
+
* Query optimizer configuration to use for the given query.
|
|
929
|
+
* @param {google.spanner.v1.RequestOptions} request.requestOptions
|
|
930
|
+
* Common options for this request.
|
|
931
|
+
* @param {google.spanner.v1.DirectedReadOptions} request.directedReadOptions
|
|
932
|
+
* Directed read options for this request.
|
|
933
|
+
* @param {boolean} request.dataBoostEnabled
|
|
934
|
+
* If this is for a partitioned query and this field is set to `true`, the
|
|
935
|
+
* request is executed with Spanner Data Boost independent compute resources.
|
|
936
|
+
*
|
|
937
|
+
* If the field is set to `true` but the request doesn't set
|
|
938
|
+
* `partition_token`, the API returns an `INVALID_ARGUMENT` error.
|
|
939
|
+
* @param {boolean} [request.lastStatement]
|
|
940
|
+
* Optional. If set to `true`, this statement marks the end of the
|
|
941
|
+
* transaction. After this statement executes, you must commit or abort the
|
|
942
|
+
* transaction. Attempts to execute any other requests against this
|
|
943
|
+
* transaction (including reads and queries) are rejected.
|
|
944
|
+
*
|
|
945
|
+
* For DML statements, setting this option might cause some error reporting to
|
|
946
|
+
* be deferred until commit time (for example, validation of unique
|
|
947
|
+
* constraints). Given this, successful execution of a DML statement shouldn't
|
|
948
|
+
* be assumed until a subsequent `Commit` call completes successfully.
|
|
949
|
+
* @param {google.spanner.v1.RoutingHint} [request.routingHint]
|
|
950
|
+
* Optional. Makes the Spanner requests location-aware if present.
|
|
951
|
+
*
|
|
952
|
+
* It gives the server hints that can be used to route the request
|
|
953
|
+
* to an appropriate server, potentially significantly decreasing latency and
|
|
954
|
+
* improving throughput. To achieve improved performance, most fields must be
|
|
955
|
+
* filled in with accurate values.
|
|
956
|
+
* @param {object} [options]
|
|
957
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
958
|
+
* @returns {Stream}
|
|
959
|
+
* An object stream which emits {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} on 'data' event.
|
|
960
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
|
|
961
|
+
* for more details and examples.
|
|
962
|
+
* @example <caption>include:samples/generated/v1/spanner.execute_streaming_sql.js</caption>
|
|
963
|
+
* region_tag:spanner_v1_generated_Spanner_ExecuteStreamingSql_async
|
|
964
|
+
*/
|
|
965
|
+
executeStreamingSql(request, options) {
|
|
966
|
+
request = request || {};
|
|
967
|
+
options = options || {};
|
|
968
|
+
options.otherArgs = options.otherArgs || {};
|
|
969
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
970
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
971
|
+
this._gaxModule.routingHeader.fromParams({
|
|
972
|
+
session: request.session ?? '',
|
|
973
|
+
});
|
|
974
|
+
this.initialize().catch((err) => {
|
|
975
|
+
throw err;
|
|
976
|
+
});
|
|
977
|
+
this._log.info('executeStreamingSql stream %j', options);
|
|
978
|
+
return this.innerApiCalls.executeStreamingSql(request, options);
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Like {@link protos.google.spanner.v1.Spanner.Read|Read}, except returns the result set
|
|
982
|
+
* as a stream. Unlike {@link protos.google.spanner.v1.Spanner.Read|Read}, there is no
|
|
983
|
+
* limit on the size of the returned result set. However, no individual row in
|
|
984
|
+
* the result set can exceed 100 MiB, and no column value can exceed
|
|
985
|
+
* 10 MiB.
|
|
986
|
+
*
|
|
987
|
+
* @param {Object} request
|
|
988
|
+
* The request object that will be sent.
|
|
989
|
+
* @param {string} request.session
|
|
990
|
+
* Required. The session in which the read should be performed.
|
|
991
|
+
* @param {google.spanner.v1.TransactionSelector} request.transaction
|
|
992
|
+
* The transaction to use. If none is provided, the default is a
|
|
993
|
+
* temporary read-only transaction with strong concurrency.
|
|
994
|
+
* @param {string} request.table
|
|
995
|
+
* Required. The name of the table in the database to be read.
|
|
996
|
+
* @param {string} request.index
|
|
997
|
+
* If non-empty, the name of an index on
|
|
998
|
+
* {@link protos.google.spanner.v1.ReadRequest.table|table}. This index is used instead of
|
|
999
|
+
* the table primary key when interpreting
|
|
1000
|
+
* {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} and sorting result rows.
|
|
1001
|
+
* See {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} for further
|
|
1002
|
+
* information.
|
|
1003
|
+
* @param {string[]} request.columns
|
|
1004
|
+
* Required. The columns of {@link protos.google.spanner.v1.ReadRequest.table|table} to be
|
|
1005
|
+
* returned for each row matching this request.
|
|
1006
|
+
* @param {google.spanner.v1.KeySet} request.keySet
|
|
1007
|
+
* Required. `key_set` identifies the rows to be yielded. `key_set` names the
|
|
1008
|
+
* primary keys of the rows in {@link protos.google.spanner.v1.ReadRequest.table|table} to
|
|
1009
|
+
* be yielded, unless {@link protos.google.spanner.v1.ReadRequest.index|index} is present.
|
|
1010
|
+
* If {@link protos.google.spanner.v1.ReadRequest.index|index} is present, then
|
|
1011
|
+
* {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} instead names index keys
|
|
1012
|
+
* in {@link protos.google.spanner.v1.ReadRequest.index|index}.
|
|
1013
|
+
*
|
|
1014
|
+
* If the {@link protos.google.spanner.v1.ReadRequest.partition_token|partition_token}
|
|
1015
|
+
* field is empty, rows are yielded in table primary key order (if
|
|
1016
|
+
* {@link protos.google.spanner.v1.ReadRequest.index|index} is empty) or index key order
|
|
1017
|
+
* (if {@link protos.google.spanner.v1.ReadRequest.index|index} is non-empty). If the
|
|
1018
|
+
* {@link protos.google.spanner.v1.ReadRequest.partition_token|partition_token} field
|
|
1019
|
+
* isn't empty, rows are yielded in an unspecified order.
|
|
1020
|
+
*
|
|
1021
|
+
* It isn't an error for the `key_set` to name rows that don't
|
|
1022
|
+
* exist in the database. Read yields nothing for nonexistent rows.
|
|
1023
|
+
* @param {number} request.limit
|
|
1024
|
+
* If greater than zero, only the first `limit` rows are yielded. If `limit`
|
|
1025
|
+
* is zero, the default is no limit. A limit can't be specified if
|
|
1026
|
+
* `partition_token` is set.
|
|
1027
|
+
* @param {Buffer} request.resumeToken
|
|
1028
|
+
* If this request is resuming a previously interrupted read,
|
|
1029
|
+
* `resume_token` should be copied from the last
|
|
1030
|
+
* {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the
|
|
1031
|
+
* interruption. Doing this enables the new read to resume where the last read
|
|
1032
|
+
* left off. The rest of the request parameters must exactly match the request
|
|
1033
|
+
* that yielded this token.
|
|
1034
|
+
* @param {Buffer} request.partitionToken
|
|
1035
|
+
* If present, results are restricted to the specified partition
|
|
1036
|
+
* previously created using `PartitionRead`. There must be an exact
|
|
1037
|
+
* match for the values of fields common to this message and the
|
|
1038
|
+
* PartitionReadRequest message used to create this partition_token.
|
|
1039
|
+
* @param {google.spanner.v1.RequestOptions} request.requestOptions
|
|
1040
|
+
* Common options for this request.
|
|
1041
|
+
* @param {google.spanner.v1.DirectedReadOptions} request.directedReadOptions
|
|
1042
|
+
* Directed read options for this request.
|
|
1043
|
+
* @param {boolean} request.dataBoostEnabled
|
|
1044
|
+
* If this is for a partitioned read and this field is set to `true`, the
|
|
1045
|
+
* request is executed with Spanner Data Boost independent compute resources.
|
|
1046
|
+
*
|
|
1047
|
+
* If the field is set to `true` but the request doesn't set
|
|
1048
|
+
* `partition_token`, the API returns an `INVALID_ARGUMENT` error.
|
|
1049
|
+
* @param {google.spanner.v1.ReadRequest.OrderBy} [request.orderBy]
|
|
1050
|
+
* Optional. Order for the returned rows.
|
|
1051
|
+
*
|
|
1052
|
+
* By default, Spanner returns result rows in primary key order except for
|
|
1053
|
+
* PartitionRead requests. For applications that don't require rows to be
|
|
1054
|
+
* returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting
|
|
1055
|
+
* `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval,
|
|
1056
|
+
* resulting in lower latencies in certain cases (for example, bulk point
|
|
1057
|
+
* lookups).
|
|
1058
|
+
* @param {google.spanner.v1.ReadRequest.LockHint} [request.lockHint]
|
|
1059
|
+
* Optional. Lock Hint for the request, it can only be used with read-write
|
|
1060
|
+
* transactions.
|
|
1061
|
+
* @param {google.spanner.v1.RoutingHint} [request.routingHint]
|
|
1062
|
+
* Optional. Makes the Spanner requests location-aware if present.
|
|
1063
|
+
*
|
|
1064
|
+
* It gives the server hints that can be used to route the request
|
|
1065
|
+
* to an appropriate server, potentially significantly decreasing latency and
|
|
1066
|
+
* improving throughput. To achieve improved performance, most fields must be
|
|
1067
|
+
* filled in with accurate values.
|
|
1068
|
+
* @param {object} [options]
|
|
1069
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1070
|
+
* @returns {Stream}
|
|
1071
|
+
* An object stream which emits {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} on 'data' event.
|
|
1072
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
|
|
1073
|
+
* for more details and examples.
|
|
1074
|
+
* @example <caption>include:samples/generated/v1/spanner.streaming_read.js</caption>
|
|
1075
|
+
* region_tag:spanner_v1_generated_Spanner_StreamingRead_async
|
|
1076
|
+
*/
|
|
1077
|
+
streamingRead(request, options) {
|
|
1078
|
+
request = request || {};
|
|
1079
|
+
options = options || {};
|
|
1080
|
+
options.otherArgs = options.otherArgs || {};
|
|
1081
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1082
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
1083
|
+
this._gaxModule.routingHeader.fromParams({
|
|
1084
|
+
session: request.session ?? '',
|
|
1085
|
+
});
|
|
1086
|
+
this.initialize().catch((err) => {
|
|
1087
|
+
throw err;
|
|
1088
|
+
});
|
|
1089
|
+
this._log.info('streamingRead stream %j', options);
|
|
1090
|
+
return this.innerApiCalls.streamingRead(request, options);
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Batches the supplied mutation groups in a collection of efficient
|
|
1094
|
+
* transactions. All mutations in a group are committed atomically. However,
|
|
1095
|
+
* mutations across groups can be committed non-atomically in an unspecified
|
|
1096
|
+
* order and thus, they must be independent of each other. Partial failure is
|
|
1097
|
+
* possible, that is, some groups might have been committed successfully,
|
|
1098
|
+
* while some might have failed. The results of individual batches are
|
|
1099
|
+
* streamed into the response as the batches are applied.
|
|
1100
|
+
*
|
|
1101
|
+
* `BatchWrite` requests are not replay protected, meaning that each mutation
|
|
1102
|
+
* group can be applied more than once. Replays of non-idempotent mutations
|
|
1103
|
+
* can have undesirable effects. For example, replays of an insert mutation
|
|
1104
|
+
* can produce an already exists error or if you use generated or commit
|
|
1105
|
+
* timestamp-based keys, it can result in additional rows being added to the
|
|
1106
|
+
* mutation's table. We recommend structuring your mutation groups to be
|
|
1107
|
+
* idempotent to avoid this issue.
|
|
1108
|
+
*
|
|
1109
|
+
* @param {Object} request
|
|
1110
|
+
* The request object that will be sent.
|
|
1111
|
+
* @param {string} request.session
|
|
1112
|
+
* Required. The session in which the batch request is to be run.
|
|
1113
|
+
* @param {google.spanner.v1.RequestOptions} request.requestOptions
|
|
1114
|
+
* Common options for this request.
|
|
1115
|
+
* @param {number[]} request.mutationGroups
|
|
1116
|
+
* Required. The groups of mutations to be applied.
|
|
1117
|
+
* @param {boolean} [request.excludeTxnFromChangeStreams]
|
|
1118
|
+
* Optional. If you don't set the `exclude_txn_from_change_streams` option or
|
|
1119
|
+
* if it's set to `false`, then any change streams monitoring columns modified
|
|
1120
|
+
* by transactions will capture the updates made within that transaction.
|
|
1121
|
+
* @param {object} [options]
|
|
1122
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1123
|
+
* @returns {Stream}
|
|
1124
|
+
* An object stream which emits {@link protos.google.spanner.v1.BatchWriteResponse|BatchWriteResponse} on 'data' event.
|
|
1125
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
|
|
1126
|
+
* for more details and examples.
|
|
1127
|
+
* @example <caption>include:samples/generated/v1/spanner.batch_write.js</caption>
|
|
1128
|
+
* region_tag:spanner_v1_generated_Spanner_BatchWrite_async
|
|
1129
|
+
*/
|
|
1130
|
+
batchWrite(request, options) {
|
|
1131
|
+
request = request || {};
|
|
1132
|
+
options = options || {};
|
|
1133
|
+
options.otherArgs = options.otherArgs || {};
|
|
1134
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1135
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
1136
|
+
this._gaxModule.routingHeader.fromParams({
|
|
1137
|
+
session: request.session ?? '',
|
|
1138
|
+
});
|
|
1139
|
+
this.initialize().catch((err) => {
|
|
1140
|
+
throw err;
|
|
1141
|
+
});
|
|
1142
|
+
this._log.info('batchWrite stream %j', options);
|
|
1143
|
+
return this.innerApiCalls.batchWrite(request, options);
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Retrieves a cache update for a given database.
|
|
1147
|
+
*
|
|
1148
|
+
* This RPC can be used to warm up the client cache by fetching key recipes
|
|
1149
|
+
* and server information for a given database. It is recommended to call
|
|
1150
|
+
* this RPC at the beginning of the client's lifecycle, prior to any other
|
|
1151
|
+
* data plane operations.
|
|
1152
|
+
*
|
|
1153
|
+
* The cache update is returned as a stream because the response can be too
|
|
1154
|
+
* large to fit into a single `CacheUpdate` message.
|
|
1155
|
+
*
|
|
1156
|
+
* @param {Object} request
|
|
1157
|
+
* The request object that will be sent.
|
|
1158
|
+
* @param {string} request.database
|
|
1159
|
+
* Required. The database for which to retrieve the cache update.
|
|
1160
|
+
* @param {number} [request.maxRecipeCount]
|
|
1161
|
+
* Optional. The maximum number of key recipes to return in the response.
|
|
1162
|
+
* If not set, a default limit of 100 will be used.
|
|
1163
|
+
* @param {number} [request.maxRangeCount]
|
|
1164
|
+
* Optional. The maximum number of ranges to return in the response.
|
|
1165
|
+
* If not set, a default limit of 10000 will be used.
|
|
1166
|
+
* @param {object} [options]
|
|
1167
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1168
|
+
* @returns {Stream}
|
|
1169
|
+
* An object stream which emits {@link protos.google.spanner.v1.CacheUpdate|CacheUpdate} on 'data' event.
|
|
1170
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
|
|
1171
|
+
* for more details and examples.
|
|
1172
|
+
* @example <caption>include:samples/generated/v1/spanner.fetch_cache_update.js</caption>
|
|
1173
|
+
* region_tag:spanner_v1_generated_Spanner_FetchCacheUpdate_async
|
|
1174
|
+
*/
|
|
1175
|
+
fetchCacheUpdate(request, options) {
|
|
1176
|
+
request = request || {};
|
|
1177
|
+
options = options || {};
|
|
1178
|
+
options.otherArgs = options.otherArgs || {};
|
|
1179
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1180
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
1181
|
+
this._gaxModule.routingHeader.fromParams({
|
|
1182
|
+
database: request.database ?? '',
|
|
1183
|
+
});
|
|
1184
|
+
this.initialize().catch((err) => {
|
|
1185
|
+
throw err;
|
|
1186
|
+
});
|
|
1187
|
+
this._log.info('fetchCacheUpdate stream %j', options);
|
|
1188
|
+
return this.innerApiCalls.fetchCacheUpdate(request, options);
|
|
1189
|
+
}
|
|
1190
|
+
listSessions(request, optionsOrCallback, callback) {
|
|
1191
|
+
request = request || {};
|
|
1192
|
+
let options;
|
|
1193
|
+
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
1194
|
+
callback = optionsOrCallback;
|
|
1195
|
+
options = {};
|
|
1196
|
+
}
|
|
1197
|
+
else {
|
|
1198
|
+
options = optionsOrCallback;
|
|
1199
|
+
}
|
|
1200
|
+
options = options || {};
|
|
1201
|
+
options.otherArgs = options.otherArgs || {};
|
|
1202
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1203
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
1204
|
+
this._gaxModule.routingHeader.fromParams({
|
|
1205
|
+
database: request.database ?? '',
|
|
1206
|
+
});
|
|
1207
|
+
this.initialize().catch((err) => {
|
|
1208
|
+
throw err;
|
|
1209
|
+
});
|
|
1210
|
+
const wrappedCallback = callback
|
|
1211
|
+
? (error, values, nextPageRequest, rawResponse) => {
|
|
1212
|
+
this._log.info('listSessions values %j', values);
|
|
1213
|
+
callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
|
|
1214
|
+
}
|
|
1215
|
+
: undefined;
|
|
1216
|
+
this._log.info('listSessions request %j', request);
|
|
1217
|
+
return this.innerApiCalls
|
|
1218
|
+
.listSessions(request, options, wrappedCallback)
|
|
1219
|
+
?.then(([response, input, output]) => {
|
|
1220
|
+
this._log.info('listSessions values %j', response);
|
|
1221
|
+
return [response, input, output];
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Equivalent to `listSessions`, but returns a NodeJS Stream object.
|
|
1226
|
+
* @param {Object} request
|
|
1227
|
+
* The request object that will be sent.
|
|
1228
|
+
* @param {string} request.database
|
|
1229
|
+
* Required. The database in which to list sessions.
|
|
1230
|
+
* @param {number} request.pageSize
|
|
1231
|
+
* Number of sessions to be returned in the response. If 0 or less, defaults
|
|
1232
|
+
* to the server's maximum allowed page size.
|
|
1233
|
+
* @param {string} request.pageToken
|
|
1234
|
+
* If non-empty, `page_token` should contain a
|
|
1235
|
+
* {@link protos.google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token}
|
|
1236
|
+
* from a previous
|
|
1237
|
+
* {@link protos.google.spanner.v1.ListSessionsResponse|ListSessionsResponse}.
|
|
1238
|
+
* @param {string} request.filter
|
|
1239
|
+
* An expression for filtering the results of the request. Filter rules are
|
|
1240
|
+
* case insensitive. The fields eligible for filtering are:
|
|
1241
|
+
*
|
|
1242
|
+
* * `labels.key` where key is the name of a label
|
|
1243
|
+
*
|
|
1244
|
+
* Some examples of using filters are:
|
|
1245
|
+
*
|
|
1246
|
+
* * `labels.env:*` --> The session has the label "env".
|
|
1247
|
+
* * `labels.env:dev` --> The session has the label "env" and the value of
|
|
1248
|
+
* the label contains the string "dev".
|
|
1249
|
+
* @param {object} [options]
|
|
1250
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1251
|
+
* @returns {Stream}
|
|
1252
|
+
* An object stream which emits an object representing {@link protos.google.spanner.v1.Session|Session} on 'data' event.
|
|
1253
|
+
* The client library will perform auto-pagination by default: it will call the API as many
|
|
1254
|
+
* times as needed. Note that it can affect your quota.
|
|
1255
|
+
* We recommend using `listSessionsAsync()`
|
|
1256
|
+
* method described below for async iteration which you can stop as needed.
|
|
1257
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
|
|
1258
|
+
* for more details and examples.
|
|
1259
|
+
*/
|
|
1260
|
+
listSessionsStream(request, options) {
|
|
1261
|
+
request = request || {};
|
|
1262
|
+
options = options || {};
|
|
1263
|
+
options.otherArgs = options.otherArgs || {};
|
|
1264
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1265
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
1266
|
+
this._gaxModule.routingHeader.fromParams({
|
|
1267
|
+
database: request.database ?? '',
|
|
1268
|
+
});
|
|
1269
|
+
const defaultCallSettings = this._defaults['listSessions'];
|
|
1270
|
+
const callSettings = defaultCallSettings.merge(options);
|
|
1271
|
+
this.initialize().catch((err) => {
|
|
1272
|
+
throw err;
|
|
1273
|
+
});
|
|
1274
|
+
this._log.info('listSessions stream %j', request);
|
|
1275
|
+
return this.descriptors.page.listSessions.createStream(this.innerApiCalls.listSessions, request, callSettings);
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Equivalent to `listSessions`, but returns an iterable object.
|
|
1279
|
+
*
|
|
1280
|
+
* `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
|
|
1281
|
+
* @param {Object} request
|
|
1282
|
+
* The request object that will be sent.
|
|
1283
|
+
* @param {string} request.database
|
|
1284
|
+
* Required. The database in which to list sessions.
|
|
1285
|
+
* @param {number} request.pageSize
|
|
1286
|
+
* Number of sessions to be returned in the response. If 0 or less, defaults
|
|
1287
|
+
* to the server's maximum allowed page size.
|
|
1288
|
+
* @param {string} request.pageToken
|
|
1289
|
+
* If non-empty, `page_token` should contain a
|
|
1290
|
+
* {@link protos.google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token}
|
|
1291
|
+
* from a previous
|
|
1292
|
+
* {@link protos.google.spanner.v1.ListSessionsResponse|ListSessionsResponse}.
|
|
1293
|
+
* @param {string} request.filter
|
|
1294
|
+
* An expression for filtering the results of the request. Filter rules are
|
|
1295
|
+
* case insensitive. The fields eligible for filtering are:
|
|
1296
|
+
*
|
|
1297
|
+
* * `labels.key` where key is the name of a label
|
|
1298
|
+
*
|
|
1299
|
+
* Some examples of using filters are:
|
|
1300
|
+
*
|
|
1301
|
+
* * `labels.env:*` --> The session has the label "env".
|
|
1302
|
+
* * `labels.env:dev` --> The session has the label "env" and the value of
|
|
1303
|
+
* the label contains the string "dev".
|
|
1304
|
+
* @param {object} [options]
|
|
1305
|
+
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1306
|
+
* @returns {Object}
|
|
1307
|
+
* An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
|
|
1308
|
+
* When you iterate the returned iterable, each element will be an object representing
|
|
1309
|
+
* {@link protos.google.spanner.v1.Session|Session}. The API will be called under the hood as needed, once per the page,
|
|
1310
|
+
* so you can stop the iteration when you don't need more results.
|
|
1311
|
+
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
|
|
1312
|
+
* for more details and examples.
|
|
1313
|
+
* @example <caption>include:samples/generated/v1/spanner.list_sessions.js</caption>
|
|
1314
|
+
* region_tag:spanner_v1_generated_Spanner_ListSessions_async
|
|
1315
|
+
*/
|
|
1316
|
+
listSessionsAsync(request, options) {
|
|
1317
|
+
request = request || {};
|
|
1318
|
+
options = options || {};
|
|
1319
|
+
options.otherArgs = options.otherArgs || {};
|
|
1320
|
+
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
1321
|
+
options.otherArgs.headers['x-goog-request-params'] =
|
|
1322
|
+
this._gaxModule.routingHeader.fromParams({
|
|
1323
|
+
database: request.database ?? '',
|
|
1324
|
+
});
|
|
1325
|
+
const defaultCallSettings = this._defaults['listSessions'];
|
|
1326
|
+
const callSettings = defaultCallSettings.merge(options);
|
|
1327
|
+
this.initialize().catch((err) => {
|
|
1328
|
+
throw err;
|
|
1329
|
+
});
|
|
1330
|
+
this._log.info('listSessions iterate %j', request);
|
|
1331
|
+
return this.descriptors.page.listSessions.asyncIterate(this.innerApiCalls['listSessions'], request, callSettings);
|
|
1332
|
+
}
|
|
1333
|
+
// --------------------
|
|
1334
|
+
// -- Path templates --
|
|
1335
|
+
// --------------------
|
|
1336
|
+
/**
|
|
1337
|
+
* Return a fully-qualified database resource name string.
|
|
1338
|
+
*
|
|
1339
|
+
* @param {string} project
|
|
1340
|
+
* @param {string} instance
|
|
1341
|
+
* @param {string} database
|
|
1342
|
+
* @returns {string} Resource name string.
|
|
1343
|
+
*/
|
|
1344
|
+
databasePath(project, instance, database) {
|
|
1345
|
+
return this.pathTemplates.databasePathTemplate.render({
|
|
1346
|
+
project: project,
|
|
1347
|
+
instance: instance,
|
|
1348
|
+
database: database,
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Parse the project from Database resource.
|
|
1353
|
+
*
|
|
1354
|
+
* @param {string} databaseName
|
|
1355
|
+
* A fully-qualified path representing Database resource.
|
|
1356
|
+
* @returns {string} A string representing the project.
|
|
1357
|
+
*/
|
|
1358
|
+
matchProjectFromDatabaseName(databaseName) {
|
|
1359
|
+
return this.pathTemplates.databasePathTemplate.match(databaseName).project;
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Parse the instance from Database resource.
|
|
1363
|
+
*
|
|
1364
|
+
* @param {string} databaseName
|
|
1365
|
+
* A fully-qualified path representing Database resource.
|
|
1366
|
+
* @returns {string} A string representing the instance.
|
|
1367
|
+
*/
|
|
1368
|
+
matchInstanceFromDatabaseName(databaseName) {
|
|
1369
|
+
return this.pathTemplates.databasePathTemplate.match(databaseName).instance;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Parse the database from Database resource.
|
|
1373
|
+
*
|
|
1374
|
+
* @param {string} databaseName
|
|
1375
|
+
* A fully-qualified path representing Database resource.
|
|
1376
|
+
* @returns {string} A string representing the database.
|
|
1377
|
+
*/
|
|
1378
|
+
matchDatabaseFromDatabaseName(databaseName) {
|
|
1379
|
+
return this.pathTemplates.databasePathTemplate.match(databaseName).database;
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Return a fully-qualified session resource name string.
|
|
1383
|
+
*
|
|
1384
|
+
* @param {string} project
|
|
1385
|
+
* @param {string} instance
|
|
1386
|
+
* @param {string} database
|
|
1387
|
+
* @param {string} session
|
|
1388
|
+
* @returns {string} Resource name string.
|
|
1389
|
+
*/
|
|
1390
|
+
sessionPath(project, instance, database, session) {
|
|
1391
|
+
return this.pathTemplates.sessionPathTemplate.render({
|
|
1392
|
+
project: project,
|
|
1393
|
+
instance: instance,
|
|
1394
|
+
database: database,
|
|
1395
|
+
session: session,
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Parse the project from Session resource.
|
|
1400
|
+
*
|
|
1401
|
+
* @param {string} sessionName
|
|
1402
|
+
* A fully-qualified path representing Session resource.
|
|
1403
|
+
* @returns {string} A string representing the project.
|
|
1404
|
+
*/
|
|
1405
|
+
matchProjectFromSessionName(sessionName) {
|
|
1406
|
+
return this.pathTemplates.sessionPathTemplate.match(sessionName).project;
|
|
1407
|
+
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Parse the instance from Session resource.
|
|
1410
|
+
*
|
|
1411
|
+
* @param {string} sessionName
|
|
1412
|
+
* A fully-qualified path representing Session resource.
|
|
1413
|
+
* @returns {string} A string representing the instance.
|
|
1414
|
+
*/
|
|
1415
|
+
matchInstanceFromSessionName(sessionName) {
|
|
1416
|
+
return this.pathTemplates.sessionPathTemplate.match(sessionName).instance;
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Parse the database from Session resource.
|
|
1420
|
+
*
|
|
1421
|
+
* @param {string} sessionName
|
|
1422
|
+
* A fully-qualified path representing Session resource.
|
|
1423
|
+
* @returns {string} A string representing the database.
|
|
1424
|
+
*/
|
|
1425
|
+
matchDatabaseFromSessionName(sessionName) {
|
|
1426
|
+
return this.pathTemplates.sessionPathTemplate.match(sessionName).database;
|
|
1427
|
+
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Parse the session from Session resource.
|
|
1430
|
+
*
|
|
1431
|
+
* @param {string} sessionName
|
|
1432
|
+
* A fully-qualified path representing Session resource.
|
|
1433
|
+
* @returns {string} A string representing the session.
|
|
1434
|
+
*/
|
|
1435
|
+
matchSessionFromSessionName(sessionName) {
|
|
1436
|
+
return this.pathTemplates.sessionPathTemplate.match(sessionName).session;
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* Terminate the gRPC channel and close the client.
|
|
1440
|
+
*
|
|
1441
|
+
* The client will no longer be usable and all future behavior is undefined.
|
|
1442
|
+
* @returns {Promise} A promise that resolves when the client is closed.
|
|
1443
|
+
*/
|
|
1444
|
+
close() {
|
|
1445
|
+
if (this.spannerStub && !this._terminated) {
|
|
1446
|
+
return this.spannerStub.then((stub) => {
|
|
1447
|
+
this._log.info('ending gRPC channel');
|
|
1448
|
+
this._terminated = true;
|
|
1449
|
+
stub.close();
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
return Promise.resolve();
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
exports.SpannerClient = SpannerClient;
|
|
1456
|
+
//# sourceMappingURL=spanner_client.js.map
|