@google-cloud/spanner 5.14.0 → 5.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,39 +104,581 @@ export declare class SpannerClient {
104
104
  static get scopes(): string[];
105
105
  getProjectId(): Promise<string>;
106
106
  getProjectId(callback: Callback<string, undefined, undefined>): void;
107
+ /**
108
+ * Creates a new session. A session can be used to perform
109
+ * transactions that read and/or modify data in a Cloud Spanner database.
110
+ * Sessions are meant to be reused for many consecutive
111
+ * transactions.
112
+ *
113
+ * Sessions can only execute one transaction at a time. To execute
114
+ * multiple concurrent read-write/write-only transactions, create
115
+ * multiple sessions. Note that standalone reads and queries use a
116
+ * transaction internally, and count toward the one transaction
117
+ * limit.
118
+ *
119
+ * Active sessions use additional server resources, so it is a good idea to
120
+ * delete idle and unneeded sessions.
121
+ * Aside from explicit deletes, Cloud Spanner may delete sessions for which no
122
+ * operations are sent for more than an hour. If a session is deleted,
123
+ * requests to it return `NOT_FOUND`.
124
+ *
125
+ * Idle sessions can be kept alive by sending a trivial SQL query
126
+ * periodically, e.g., `"SELECT 1"`.
127
+ *
128
+ * @param {Object} request
129
+ * The request object that will be sent.
130
+ * @param {string} request.database
131
+ * Required. The database in which the new session is created.
132
+ * @param {google.spanner.v1.Session} request.session
133
+ * The session to create.
134
+ * @param {object} [options]
135
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
136
+ * @returns {Promise} - The promise which resolves to an array.
137
+ * The first element of the array is an object representing [Session]{@link google.spanner.v1.Session}.
138
+ * Please see the
139
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
140
+ * for more details and examples.
141
+ * @example <caption>include:samples/generated/v1/spanner.create_session.js</caption>
142
+ * region_tag:spanner_v1_generated_Spanner_CreateSession_async
143
+ */
107
144
  createSession(request?: protos.google.spanner.v1.ICreateSessionRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.ISession, protos.google.spanner.v1.ICreateSessionRequest | undefined, {} | undefined]>;
108
145
  createSession(request: protos.google.spanner.v1.ICreateSessionRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.ICreateSessionRequest | null | undefined, {} | null | undefined>): void;
109
146
  createSession(request: protos.google.spanner.v1.ICreateSessionRequest, callback: Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.ICreateSessionRequest | null | undefined, {} | null | undefined>): void;
147
+ /**
148
+ * Creates multiple new sessions.
149
+ *
150
+ * This API can be used to initialize a session cache on the clients.
151
+ * See https://goo.gl/TgSFN2 for best practices on session cache management.
152
+ *
153
+ * @param {Object} request
154
+ * The request object that will be sent.
155
+ * @param {string} request.database
156
+ * Required. The database in which the new sessions are created.
157
+ * @param {google.spanner.v1.Session} request.sessionTemplate
158
+ * Parameters to be applied to each created session.
159
+ * @param {number} request.sessionCount
160
+ * Required. The number of sessions to be created in this batch call.
161
+ * The API may return fewer than the requested number of sessions. If a
162
+ * specific number of sessions are desired, the client can make additional
163
+ * calls to BatchCreateSessions (adjusting
164
+ * {@link google.spanner.v1.BatchCreateSessionsRequest.session_count|session_count} as necessary).
165
+ * @param {object} [options]
166
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
167
+ * @returns {Promise} - The promise which resolves to an array.
168
+ * The first element of the array is an object representing [BatchCreateSessionsResponse]{@link google.spanner.v1.BatchCreateSessionsResponse}.
169
+ * Please see the
170
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
171
+ * for more details and examples.
172
+ * @example <caption>include:samples/generated/v1/spanner.batch_create_sessions.js</caption>
173
+ * region_tag:spanner_v1_generated_Spanner_BatchCreateSessions_async
174
+ */
110
175
  batchCreateSessions(request?: protos.google.spanner.v1.IBatchCreateSessionsRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.IBatchCreateSessionsResponse, protos.google.spanner.v1.IBatchCreateSessionsRequest | undefined, {} | undefined]>;
111
176
  batchCreateSessions(request: protos.google.spanner.v1.IBatchCreateSessionsRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IBatchCreateSessionsResponse, protos.google.spanner.v1.IBatchCreateSessionsRequest | null | undefined, {} | null | undefined>): void;
112
177
  batchCreateSessions(request: protos.google.spanner.v1.IBatchCreateSessionsRequest, callback: Callback<protos.google.spanner.v1.IBatchCreateSessionsResponse, protos.google.spanner.v1.IBatchCreateSessionsRequest | null | undefined, {} | null | undefined>): void;
178
+ /**
179
+ * Gets a session. Returns `NOT_FOUND` if the session does not exist.
180
+ * This is mainly useful for determining whether a session is still
181
+ * alive.
182
+ *
183
+ * @param {Object} request
184
+ * The request object that will be sent.
185
+ * @param {string} request.name
186
+ * Required. The name of the session to retrieve.
187
+ * @param {object} [options]
188
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
189
+ * @returns {Promise} - The promise which resolves to an array.
190
+ * The first element of the array is an object representing [Session]{@link google.spanner.v1.Session}.
191
+ * Please see the
192
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
193
+ * for more details and examples.
194
+ * @example <caption>include:samples/generated/v1/spanner.get_session.js</caption>
195
+ * region_tag:spanner_v1_generated_Spanner_GetSession_async
196
+ */
113
197
  getSession(request?: protos.google.spanner.v1.IGetSessionRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.ISession, protos.google.spanner.v1.IGetSessionRequest | undefined, {} | undefined]>;
114
198
  getSession(request: protos.google.spanner.v1.IGetSessionRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.IGetSessionRequest | null | undefined, {} | null | undefined>): void;
115
199
  getSession(request: protos.google.spanner.v1.IGetSessionRequest, callback: Callback<protos.google.spanner.v1.ISession, protos.google.spanner.v1.IGetSessionRequest | null | undefined, {} | null | undefined>): void;
200
+ /**
201
+ * Ends a session, releasing server resources associated with it. This will
202
+ * asynchronously trigger cancellation of any operations that are running with
203
+ * this session.
204
+ *
205
+ * @param {Object} request
206
+ * The request object that will be sent.
207
+ * @param {string} request.name
208
+ * Required. The name of the session to delete.
209
+ * @param {object} [options]
210
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
211
+ * @returns {Promise} - The promise which resolves to an array.
212
+ * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}.
213
+ * Please see the
214
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
215
+ * for more details and examples.
216
+ * @example <caption>include:samples/generated/v1/spanner.delete_session.js</caption>
217
+ * region_tag:spanner_v1_generated_Spanner_DeleteSession_async
218
+ */
116
219
  deleteSession(request?: protos.google.spanner.v1.IDeleteSessionRequest, options?: CallOptions): Promise<[protos.google.protobuf.IEmpty, protos.google.spanner.v1.IDeleteSessionRequest | undefined, {} | undefined]>;
117
220
  deleteSession(request: protos.google.spanner.v1.IDeleteSessionRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IDeleteSessionRequest | null | undefined, {} | null | undefined>): void;
118
221
  deleteSession(request: protos.google.spanner.v1.IDeleteSessionRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IDeleteSessionRequest | null | undefined, {} | null | undefined>): void;
222
+ /**
223
+ * Executes an SQL statement, returning all results in a single reply. This
224
+ * method cannot be used to return a result set larger than 10 MiB;
225
+ * if the query yields more data than that, the query fails with
226
+ * a `FAILED_PRECONDITION` error.
227
+ *
228
+ * Operations inside read-write transactions might return `ABORTED`. If
229
+ * this occurs, the application should restart the transaction from
230
+ * the beginning. See {@link google.spanner.v1.Transaction|Transaction} for more details.
231
+ *
232
+ * Larger result sets can be fetched in streaming fashion by calling
233
+ * {@link google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} instead.
234
+ *
235
+ * @param {Object} request
236
+ * The request object that will be sent.
237
+ * @param {string} request.session
238
+ * Required. The session in which the SQL query should be performed.
239
+ * @param {google.spanner.v1.TransactionSelector} request.transaction
240
+ * The transaction to use.
241
+ *
242
+ * For queries, if none is provided, the default is a temporary read-only
243
+ * transaction with strong concurrency.
244
+ *
245
+ * Standard DML statements require a read-write transaction. To protect
246
+ * against replays, single-use transactions are not supported. The caller
247
+ * must either supply an existing transaction ID or begin a new transaction.
248
+ *
249
+ * Partitioned DML requires an existing Partitioned DML transaction ID.
250
+ * @param {string} request.sql
251
+ * Required. The SQL string.
252
+ * @param {google.protobuf.Struct} request.params
253
+ * Parameter names and values that bind to placeholders in the SQL string.
254
+ *
255
+ * A parameter placeholder consists of the `@` character followed by the
256
+ * parameter name (for example, `@firstName`). Parameter names must conform
257
+ * to the naming requirements of identifiers as specified at
258
+ * https://cloud.google.com/spanner/docs/lexical#identifiers.
259
+ *
260
+ * Parameters can appear anywhere that a literal value is expected. The same
261
+ * parameter name can be used more than once, for example:
262
+ *
263
+ * `"WHERE id > @msg_id AND id < @msg_id + 100"`
264
+ *
265
+ * It is an error to execute a SQL statement with unbound parameters.
266
+ * @param {number[]} request.paramTypes
267
+ * It is not always possible for Cloud Spanner to infer the right SQL type
268
+ * from a JSON value. For example, values of type `BYTES` and values
269
+ * of type `STRING` both appear in {@link google.spanner.v1.ExecuteSqlRequest.params|params} as JSON strings.
270
+ *
271
+ * In these cases, `param_types` can be used to specify the exact
272
+ * SQL type for some or all of the SQL statement parameters. See the
273
+ * definition of {@link google.spanner.v1.Type|Type} for more information
274
+ * about SQL types.
275
+ * @param {Buffer} request.resumeToken
276
+ * If this request is resuming a previously interrupted SQL statement
277
+ * execution, `resume_token` should be copied from the last
278
+ * {@link google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the interruption. Doing this
279
+ * enables the new SQL statement execution to resume where the last one left
280
+ * off. The rest of the request parameters must exactly match the
281
+ * request that yielded this token.
282
+ * @param {google.spanner.v1.ExecuteSqlRequest.QueryMode} request.queryMode
283
+ * Used to control the amount of debugging information returned in
284
+ * {@link google.spanner.v1.ResultSetStats|ResultSetStats}. If {@link google.spanner.v1.ExecuteSqlRequest.partition_token|partition_token} is set, {@link google.spanner.v1.ExecuteSqlRequest.query_mode|query_mode} can only
285
+ * be set to {@link google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL|QueryMode.NORMAL}.
286
+ * @param {Buffer} request.partitionToken
287
+ * If present, results will be restricted to the specified partition
288
+ * previously created using PartitionQuery(). There must be an exact
289
+ * match for the values of fields common to this message and the
290
+ * PartitionQueryRequest message used to create this partition_token.
291
+ * @param {number} request.seqno
292
+ * A per-transaction sequence number used to identify this request. This field
293
+ * makes each request idempotent such that if the request is received multiple
294
+ * times, at most one will succeed.
295
+ *
296
+ * The sequence number must be monotonically increasing within the
297
+ * transaction. If a request arrives for the first time with an out-of-order
298
+ * sequence number, the transaction may be aborted. Replays of previously
299
+ * handled requests will yield the same response as the first execution.
300
+ *
301
+ * Required for DML statements. Ignored for queries.
302
+ * @param {google.spanner.v1.ExecuteSqlRequest.QueryOptions} request.queryOptions
303
+ * Query optimizer configuration to use for the given query.
304
+ * @param {google.spanner.v1.RequestOptions} request.requestOptions
305
+ * Common options for this request.
306
+ * @param {object} [options]
307
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
308
+ * @returns {Promise} - The promise which resolves to an array.
309
+ * The first element of the array is an object representing [ResultSet]{@link google.spanner.v1.ResultSet}.
310
+ * Please see the
311
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
312
+ * for more details and examples.
313
+ * @example <caption>include:samples/generated/v1/spanner.execute_sql.js</caption>
314
+ * region_tag:spanner_v1_generated_Spanner_ExecuteSql_async
315
+ */
119
316
  executeSql(request?: protos.google.spanner.v1.IExecuteSqlRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IExecuteSqlRequest | undefined, {} | undefined]>;
120
317
  executeSql(request: protos.google.spanner.v1.IExecuteSqlRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IExecuteSqlRequest | null | undefined, {} | null | undefined>): void;
121
318
  executeSql(request: protos.google.spanner.v1.IExecuteSqlRequest, callback: Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IExecuteSqlRequest | null | undefined, {} | null | undefined>): void;
319
+ /**
320
+ * Executes a batch of SQL DML statements. This method allows many statements
321
+ * to be run with lower latency than submitting them sequentially with
322
+ * {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}.
323
+ *
324
+ * Statements are executed in sequential order. A request can succeed even if
325
+ * a statement fails. The {@link google.spanner.v1.ExecuteBatchDmlResponse.status|ExecuteBatchDmlResponse.status} field in the
326
+ * response provides information about the statement that failed. Clients must
327
+ * inspect this field to determine whether an error occurred.
328
+ *
329
+ * Execution stops after the first failed statement; the remaining statements
330
+ * are not executed.
331
+ *
332
+ * @param {Object} request
333
+ * The request object that will be sent.
334
+ * @param {string} request.session
335
+ * Required. The session in which the DML statements should be performed.
336
+ * @param {google.spanner.v1.TransactionSelector} request.transaction
337
+ * Required. The transaction to use. Must be a read-write transaction.
338
+ *
339
+ * To protect against replays, single-use transactions are not supported. The
340
+ * caller must either supply an existing transaction ID or begin a new
341
+ * transaction.
342
+ * @param {number[]} request.statements
343
+ * Required. The list of statements to execute in this batch. Statements are executed
344
+ * serially, such that the effects of statement `i` are visible to statement
345
+ * `i+1`. Each statement must be a DML statement. Execution stops at the
346
+ * first failed statement; the remaining statements are not executed.
347
+ *
348
+ * Callers must provide at least one statement.
349
+ * @param {number} request.seqno
350
+ * Required. A per-transaction sequence number used to identify this request. This field
351
+ * makes each request idempotent such that if the request is received multiple
352
+ * times, at most one will succeed.
353
+ *
354
+ * The sequence number must be monotonically increasing within the
355
+ * transaction. If a request arrives for the first time with an out-of-order
356
+ * sequence number, the transaction may be aborted. Replays of previously
357
+ * handled requests will yield the same response as the first execution.
358
+ * @param {google.spanner.v1.RequestOptions} request.requestOptions
359
+ * Common options for this request.
360
+ * @param {object} [options]
361
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
362
+ * @returns {Promise} - The promise which resolves to an array.
363
+ * The first element of the array is an object representing [ExecuteBatchDmlResponse]{@link google.spanner.v1.ExecuteBatchDmlResponse}.
364
+ * Please see the
365
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
366
+ * for more details and examples.
367
+ * @example <caption>include:samples/generated/v1/spanner.execute_batch_dml.js</caption>
368
+ * region_tag:spanner_v1_generated_Spanner_ExecuteBatchDml_async
369
+ */
122
370
  executeBatchDml(request?: protos.google.spanner.v1.IExecuteBatchDmlRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.IExecuteBatchDmlResponse, protos.google.spanner.v1.IExecuteBatchDmlRequest | undefined, {} | undefined]>;
123
371
  executeBatchDml(request: protos.google.spanner.v1.IExecuteBatchDmlRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IExecuteBatchDmlResponse, protos.google.spanner.v1.IExecuteBatchDmlRequest | null | undefined, {} | null | undefined>): void;
124
372
  executeBatchDml(request: protos.google.spanner.v1.IExecuteBatchDmlRequest, callback: Callback<protos.google.spanner.v1.IExecuteBatchDmlResponse, protos.google.spanner.v1.IExecuteBatchDmlRequest | null | undefined, {} | null | undefined>): void;
373
+ /**
374
+ * Reads rows from the database using key lookups and scans, as a
375
+ * simple key/value style alternative to
376
+ * {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}. This method cannot be used to
377
+ * return a result set larger than 10 MiB; if the read matches more
378
+ * data than that, the read fails with a `FAILED_PRECONDITION`
379
+ * error.
380
+ *
381
+ * Reads inside read-write transactions might return `ABORTED`. If
382
+ * this occurs, the application should restart the transaction from
383
+ * the beginning. See {@link google.spanner.v1.Transaction|Transaction} for more details.
384
+ *
385
+ * Larger result sets can be yielded in streaming fashion by calling
386
+ * {@link google.spanner.v1.Spanner.StreamingRead|StreamingRead} instead.
387
+ *
388
+ * @param {Object} request
389
+ * The request object that will be sent.
390
+ * @param {string} request.session
391
+ * Required. The session in which the read should be performed.
392
+ * @param {google.spanner.v1.TransactionSelector} request.transaction
393
+ * The transaction to use. If none is provided, the default is a
394
+ * temporary read-only transaction with strong concurrency.
395
+ * @param {string} request.table
396
+ * Required. The name of the table in the database to be read.
397
+ * @param {string} request.index
398
+ * If non-empty, the name of an index on {@link google.spanner.v1.ReadRequest.table|table}. This index is
399
+ * used instead of the table primary key when interpreting {@link google.spanner.v1.ReadRequest.key_set|key_set}
400
+ * and sorting result rows. See {@link google.spanner.v1.ReadRequest.key_set|key_set} for further information.
401
+ * @param {string[]} request.columns
402
+ * Required. The columns of {@link google.spanner.v1.ReadRequest.table|table} to be returned for each row matching
403
+ * this request.
404
+ * @param {google.spanner.v1.KeySet} request.keySet
405
+ * Required. `key_set` identifies the rows to be yielded. `key_set` names the
406
+ * primary keys of the rows in {@link google.spanner.v1.ReadRequest.table|table} to be yielded, unless {@link google.spanner.v1.ReadRequest.index|index}
407
+ * is present. If {@link google.spanner.v1.ReadRequest.index|index} is present, then {@link google.spanner.v1.ReadRequest.key_set|key_set} instead names
408
+ * index keys in {@link google.spanner.v1.ReadRequest.index|index}.
409
+ *
410
+ * If the {@link google.spanner.v1.ReadRequest.partition_token|partition_token} field is empty, rows are yielded
411
+ * in table primary key order (if {@link google.spanner.v1.ReadRequest.index|index} is empty) or index key order
412
+ * (if {@link google.spanner.v1.ReadRequest.index|index} is non-empty). If the {@link google.spanner.v1.ReadRequest.partition_token|partition_token} field is not
413
+ * empty, rows will be yielded in an unspecified order.
414
+ *
415
+ * It is not an error for the `key_set` to name rows that do not
416
+ * exist in the database. Read yields nothing for nonexistent rows.
417
+ * @param {number} request.limit
418
+ * If greater than zero, only the first `limit` rows are yielded. If `limit`
419
+ * is zero, the default is no limit. A limit cannot be specified if
420
+ * `partition_token` is set.
421
+ * @param {Buffer} request.resumeToken
422
+ * If this request is resuming a previously interrupted read,
423
+ * `resume_token` should be copied from the last
424
+ * {@link google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the interruption. Doing this
425
+ * enables the new read to resume where the last read left off. The
426
+ * rest of the request parameters must exactly match the request
427
+ * that yielded this token.
428
+ * @param {Buffer} request.partitionToken
429
+ * If present, results will be restricted to the specified partition
430
+ * previously created using PartitionRead(). There must be an exact
431
+ * match for the values of fields common to this message and the
432
+ * PartitionReadRequest message used to create this partition_token.
433
+ * @param {google.spanner.v1.RequestOptions} request.requestOptions
434
+ * Common options for this request.
435
+ * @param {object} [options]
436
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
437
+ * @returns {Promise} - The promise which resolves to an array.
438
+ * The first element of the array is an object representing [ResultSet]{@link google.spanner.v1.ResultSet}.
439
+ * Please see the
440
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
441
+ * for more details and examples.
442
+ * @example <caption>include:samples/generated/v1/spanner.read.js</caption>
443
+ * region_tag:spanner_v1_generated_Spanner_Read_async
444
+ */
125
445
  read(request?: protos.google.spanner.v1.IReadRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IReadRequest | undefined, {} | undefined]>;
126
446
  read(request: protos.google.spanner.v1.IReadRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IReadRequest | null | undefined, {} | null | undefined>): void;
127
447
  read(request: protos.google.spanner.v1.IReadRequest, callback: Callback<protos.google.spanner.v1.IResultSet, protos.google.spanner.v1.IReadRequest | null | undefined, {} | null | undefined>): void;
448
+ /**
449
+ * Begins a new transaction. This step can often be skipped:
450
+ * {@link google.spanner.v1.Spanner.Read|Read}, {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql} and
451
+ * {@link google.spanner.v1.Spanner.Commit|Commit} can begin a new transaction as a
452
+ * side-effect.
453
+ *
454
+ * @param {Object} request
455
+ * The request object that will be sent.
456
+ * @param {string} request.session
457
+ * Required. The session in which the transaction runs.
458
+ * @param {google.spanner.v1.TransactionOptions} request.options
459
+ * Required. Options for the new transaction.
460
+ * @param {google.spanner.v1.RequestOptions} request.requestOptions
461
+ * Common options for this request.
462
+ * Priority is ignored for this request. Setting the priority in this
463
+ * request_options struct will not do anything. To set the priority for a
464
+ * transaction, set it on the reads and writes that are part of this
465
+ * transaction instead.
466
+ * @param {object} [options]
467
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
468
+ * @returns {Promise} - The promise which resolves to an array.
469
+ * The first element of the array is an object representing [Transaction]{@link google.spanner.v1.Transaction}.
470
+ * Please see the
471
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
472
+ * for more details and examples.
473
+ * @example <caption>include:samples/generated/v1/spanner.begin_transaction.js</caption>
474
+ * region_tag:spanner_v1_generated_Spanner_BeginTransaction_async
475
+ */
128
476
  beginTransaction(request?: protos.google.spanner.v1.IBeginTransactionRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.ITransaction, protos.google.spanner.v1.IBeginTransactionRequest | undefined, {} | undefined]>;
129
477
  beginTransaction(request: protos.google.spanner.v1.IBeginTransactionRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.ITransaction, protos.google.spanner.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void;
130
478
  beginTransaction(request: protos.google.spanner.v1.IBeginTransactionRequest, callback: Callback<protos.google.spanner.v1.ITransaction, protos.google.spanner.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void;
479
+ /**
480
+ * Commits a transaction. The request includes the mutations to be
481
+ * applied to rows in the database.
482
+ *
483
+ * `Commit` might return an `ABORTED` error. This can occur at any time;
484
+ * commonly, the cause is conflicts with concurrent
485
+ * transactions. However, it can also happen for a variety of other
486
+ * reasons. If `Commit` returns `ABORTED`, the caller should re-attempt
487
+ * the transaction from the beginning, re-using the same session.
488
+ *
489
+ * On very rare occasions, `Commit` might return `UNKNOWN`. This can happen,
490
+ * for example, if the client job experiences a 1+ hour networking failure.
491
+ * At that point, Cloud Spanner has lost track of the transaction outcome and
492
+ * we recommend that you perform another read from the database to see the
493
+ * state of things as they are now.
494
+ *
495
+ * @param {Object} request
496
+ * The request object that will be sent.
497
+ * @param {string} request.session
498
+ * Required. The session in which the transaction to be committed is running.
499
+ * @param {Buffer} request.transactionId
500
+ * Commit a previously-started transaction.
501
+ * @param {google.spanner.v1.TransactionOptions} request.singleUseTransaction
502
+ * Execute mutations in a temporary transaction. Note that unlike
503
+ * commit of a previously-started transaction, commit with a
504
+ * temporary transaction is non-idempotent. That is, if the
505
+ * `CommitRequest` is sent to Cloud Spanner more than once (for
506
+ * instance, due to retries in the application, or in the
507
+ * transport library), it is possible that the mutations are
508
+ * executed more than once. If this is undesirable, use
509
+ * {@link google.spanner.v1.Spanner.BeginTransaction|BeginTransaction} and
510
+ * {@link google.spanner.v1.Spanner.Commit|Commit} instead.
511
+ * @param {number[]} request.mutations
512
+ * The mutations to be executed when this transaction commits. All
513
+ * mutations are applied atomically, in the order they appear in
514
+ * this list.
515
+ * @param {boolean} request.returnCommitStats
516
+ * If `true`, then statistics related to the transaction will be included in
517
+ * the {@link google.spanner.v1.CommitResponse.commit_stats|CommitResponse}. Default value is
518
+ * `false`.
519
+ * @param {google.spanner.v1.RequestOptions} request.requestOptions
520
+ * Common options for this request.
521
+ * @param {object} [options]
522
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
523
+ * @returns {Promise} - The promise which resolves to an array.
524
+ * The first element of the array is an object representing [CommitResponse]{@link google.spanner.v1.CommitResponse}.
525
+ * Please see the
526
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
527
+ * for more details and examples.
528
+ * @example <caption>include:samples/generated/v1/spanner.commit.js</caption>
529
+ * region_tag:spanner_v1_generated_Spanner_Commit_async
530
+ */
131
531
  commit(request?: protos.google.spanner.v1.ICommitRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.ICommitResponse, protos.google.spanner.v1.ICommitRequest | undefined, {} | undefined]>;
132
532
  commit(request: protos.google.spanner.v1.ICommitRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.ICommitResponse, protos.google.spanner.v1.ICommitRequest | null | undefined, {} | null | undefined>): void;
133
533
  commit(request: protos.google.spanner.v1.ICommitRequest, callback: Callback<protos.google.spanner.v1.ICommitResponse, protos.google.spanner.v1.ICommitRequest | null | undefined, {} | null | undefined>): void;
534
+ /**
535
+ * Rolls back a transaction, releasing any locks it holds. It is a good
536
+ * idea to call this for any transaction that includes one or more
537
+ * {@link google.spanner.v1.Spanner.Read|Read} or {@link google.spanner.v1.Spanner.ExecuteSql|ExecuteSql} requests and
538
+ * ultimately decides not to commit.
539
+ *
540
+ * `Rollback` returns `OK` if it successfully aborts the transaction, the
541
+ * transaction was already aborted, or the transaction is not
542
+ * found. `Rollback` never returns `ABORTED`.
543
+ *
544
+ * @param {Object} request
545
+ * The request object that will be sent.
546
+ * @param {string} request.session
547
+ * Required. The session in which the transaction to roll back is running.
548
+ * @param {Buffer} request.transactionId
549
+ * Required. The transaction to roll back.
550
+ * @param {object} [options]
551
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
552
+ * @returns {Promise} - The promise which resolves to an array.
553
+ * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}.
554
+ * Please see the
555
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
556
+ * for more details and examples.
557
+ * @example <caption>include:samples/generated/v1/spanner.rollback.js</caption>
558
+ * region_tag:spanner_v1_generated_Spanner_Rollback_async
559
+ */
134
560
  rollback(request?: protos.google.spanner.v1.IRollbackRequest, options?: CallOptions): Promise<[protos.google.protobuf.IEmpty, protos.google.spanner.v1.IRollbackRequest | undefined, {} | undefined]>;
135
561
  rollback(request: protos.google.spanner.v1.IRollbackRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IRollbackRequest | null | undefined, {} | null | undefined>): void;
136
562
  rollback(request: protos.google.spanner.v1.IRollbackRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.spanner.v1.IRollbackRequest | null | undefined, {} | null | undefined>): void;
563
+ /**
564
+ * Creates a set of partition tokens that can be used to execute a query
565
+ * operation in parallel. Each of the returned partition tokens can be used
566
+ * by {@link google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} to specify a subset
567
+ * of the query result to read. The same session and read-only transaction
568
+ * must be used by the PartitionQueryRequest used to create the
569
+ * partition tokens and the ExecuteSqlRequests that use the partition tokens.
570
+ *
571
+ * Partition tokens become invalid when the session used to create them
572
+ * is deleted, is idle for too long, begins a new transaction, or becomes too
573
+ * old. When any of these happen, it is not possible to resume the query, and
574
+ * the whole operation must be restarted from the beginning.
575
+ *
576
+ * @param {Object} request
577
+ * The request object that will be sent.
578
+ * @param {string} request.session
579
+ * Required. The session used to create the partitions.
580
+ * @param {google.spanner.v1.TransactionSelector} request.transaction
581
+ * Read only snapshot transactions are supported, read/write and single use
582
+ * transactions are not.
583
+ * @param {string} request.sql
584
+ * Required. The query request to generate partitions for. The request will fail if
585
+ * the query is not root partitionable. The query plan of a root
586
+ * partitionable query has a single distributed union operator. A distributed
587
+ * union operator conceptually divides one or more tables into multiple
588
+ * splits, remotely evaluates a subquery independently on each split, and
589
+ * then unions all results.
590
+ *
591
+ * This must not contain DML commands, such as INSERT, UPDATE, or
592
+ * DELETE. Use {@link google.spanner.v1.Spanner.ExecuteStreamingSql|ExecuteStreamingSql} with a
593
+ * PartitionedDml transaction for large, partition-friendly DML operations.
594
+ * @param {google.protobuf.Struct} request.params
595
+ * Parameter names and values that bind to placeholders in the SQL string.
596
+ *
597
+ * A parameter placeholder consists of the `@` character followed by the
598
+ * parameter name (for example, `@firstName`). Parameter names can contain
599
+ * letters, numbers, and underscores.
600
+ *
601
+ * Parameters can appear anywhere that a literal value is expected. The same
602
+ * parameter name can be used more than once, for example:
603
+ *
604
+ * `"WHERE id > @msg_id AND id < @msg_id + 100"`
605
+ *
606
+ * It is an error to execute a SQL statement with unbound parameters.
607
+ * @param {number[]} request.paramTypes
608
+ * It is not always possible for Cloud Spanner to infer the right SQL type
609
+ * from a JSON value. For example, values of type `BYTES` and values
610
+ * of type `STRING` both appear in {@link google.spanner.v1.PartitionQueryRequest.params|params} as JSON strings.
611
+ *
612
+ * In these cases, `param_types` can be used to specify the exact
613
+ * SQL type for some or all of the SQL query parameters. See the
614
+ * definition of {@link google.spanner.v1.Type|Type} for more information
615
+ * about SQL types.
616
+ * @param {google.spanner.v1.PartitionOptions} request.partitionOptions
617
+ * Additional options that affect how many partitions are created.
618
+ * @param {object} [options]
619
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
620
+ * @returns {Promise} - The promise which resolves to an array.
621
+ * The first element of the array is an object representing [PartitionResponse]{@link google.spanner.v1.PartitionResponse}.
622
+ * Please see the
623
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
624
+ * for more details and examples.
625
+ * @example <caption>include:samples/generated/v1/spanner.partition_query.js</caption>
626
+ * region_tag:spanner_v1_generated_Spanner_PartitionQuery_async
627
+ */
137
628
  partitionQuery(request?: protos.google.spanner.v1.IPartitionQueryRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionQueryRequest | undefined, {} | undefined]>;
138
629
  partitionQuery(request: protos.google.spanner.v1.IPartitionQueryRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionQueryRequest | null | undefined, {} | null | undefined>): void;
139
630
  partitionQuery(request: protos.google.spanner.v1.IPartitionQueryRequest, callback: Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionQueryRequest | null | undefined, {} | null | undefined>): void;
631
+ /**
632
+ * Creates a set of partition tokens that can be used to execute a read
633
+ * operation in parallel. Each of the returned partition tokens can be used
634
+ * by {@link google.spanner.v1.Spanner.StreamingRead|StreamingRead} to specify a subset of the read
635
+ * result to read. The same session and read-only transaction must be used by
636
+ * the PartitionReadRequest used to create the partition tokens and the
637
+ * ReadRequests that use the partition tokens. There are no ordering
638
+ * guarantees on rows returned among the returned partition tokens, or even
639
+ * within each individual StreamingRead call issued with a partition_token.
640
+ *
641
+ * Partition tokens become invalid when the session used to create them
642
+ * is deleted, is idle for too long, begins a new transaction, or becomes too
643
+ * old. When any of these happen, it is not possible to resume the read, and
644
+ * the whole operation must be restarted from the beginning.
645
+ *
646
+ * @param {Object} request
647
+ * The request object that will be sent.
648
+ * @param {string} request.session
649
+ * Required. The session used to create the partitions.
650
+ * @param {google.spanner.v1.TransactionSelector} request.transaction
651
+ * Read only snapshot transactions are supported, read/write and single use
652
+ * transactions are not.
653
+ * @param {string} request.table
654
+ * Required. The name of the table in the database to be read.
655
+ * @param {string} request.index
656
+ * If non-empty, the name of an index on {@link google.spanner.v1.PartitionReadRequest.table|table}. This index is
657
+ * used instead of the table primary key when interpreting {@link google.spanner.v1.PartitionReadRequest.key_set|key_set}
658
+ * and sorting result rows. See {@link google.spanner.v1.PartitionReadRequest.key_set|key_set} for further information.
659
+ * @param {string[]} request.columns
660
+ * The columns of {@link google.spanner.v1.PartitionReadRequest.table|table} to be returned for each row matching
661
+ * this request.
662
+ * @param {google.spanner.v1.KeySet} request.keySet
663
+ * Required. `key_set` identifies the rows to be yielded. `key_set` names the
664
+ * primary keys of the rows in {@link google.spanner.v1.PartitionReadRequest.table|table} to be yielded, unless {@link google.spanner.v1.PartitionReadRequest.index|index}
665
+ * is present. If {@link google.spanner.v1.PartitionReadRequest.index|index} is present, then {@link google.spanner.v1.PartitionReadRequest.key_set|key_set} instead names
666
+ * index keys in {@link google.spanner.v1.PartitionReadRequest.index|index}.
667
+ *
668
+ * It is not an error for the `key_set` to name rows that do not
669
+ * exist in the database. Read yields nothing for nonexistent rows.
670
+ * @param {google.spanner.v1.PartitionOptions} request.partitionOptions
671
+ * Additional options that affect how many partitions are created.
672
+ * @param {object} [options]
673
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
674
+ * @returns {Promise} - The promise which resolves to an array.
675
+ * The first element of the array is an object representing [PartitionResponse]{@link google.spanner.v1.PartitionResponse}.
676
+ * Please see the
677
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
678
+ * for more details and examples.
679
+ * @example <caption>include:samples/generated/v1/spanner.partition_read.js</caption>
680
+ * region_tag:spanner_v1_generated_Spanner_PartitionRead_async
681
+ */
140
682
  partitionRead(request?: protos.google.spanner.v1.IPartitionReadRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionReadRequest | undefined, {} | undefined]>;
141
683
  partitionRead(request: protos.google.spanner.v1.IPartitionReadRequest, options: CallOptions, callback: Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionReadRequest | null | undefined, {} | null | undefined>): void;
142
684
  partitionRead(request: protos.google.spanner.v1.IPartitionReadRequest, callback: Callback<protos.google.spanner.v1.IPartitionResponse, protos.google.spanner.v1.IPartitionReadRequest | null | undefined, {} | null | undefined>): void;
@@ -225,10 +767,8 @@ export declare class SpannerClient {
225
767
  * Please see the
226
768
  * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming)
227
769
  * for more details and examples.
228
- * @example
229
- * const stream = client.executeStreamingSql(request);
230
- * stream.on('data', (response) => { ... });
231
- * stream.on('end', () => { ... });
770
+ * @example <caption>include:samples/generated/v1/spanner.execute_streaming_sql.js</caption>
771
+ * region_tag:spanner_v1_generated_Spanner_ExecuteStreamingSql_async
232
772
  */
233
773
  executeStreamingSql(request?: protos.google.spanner.v1.IExecuteSqlRequest, options?: CallOptions): gax.CancellableStream;
234
774
  /**
@@ -292,12 +832,48 @@ export declare class SpannerClient {
292
832
  * Please see the
293
833
  * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming)
294
834
  * for more details and examples.
295
- * @example
296
- * const stream = client.streamingRead(request);
297
- * stream.on('data', (response) => { ... });
298
- * stream.on('end', () => { ... });
835
+ * @example <caption>include:samples/generated/v1/spanner.streaming_read.js</caption>
836
+ * region_tag:spanner_v1_generated_Spanner_StreamingRead_async
299
837
  */
300
838
  streamingRead(request?: protos.google.spanner.v1.IReadRequest, options?: CallOptions): gax.CancellableStream;
839
+ /**
840
+ * Lists all sessions in a given database.
841
+ *
842
+ * @param {Object} request
843
+ * The request object that will be sent.
844
+ * @param {string} request.database
845
+ * Required. The database in which to list sessions.
846
+ * @param {number} request.pageSize
847
+ * Number of sessions to be returned in the response. If 0 or less, defaults
848
+ * to the server's maximum allowed page size.
849
+ * @param {string} request.pageToken
850
+ * If non-empty, `page_token` should contain a
851
+ * {@link google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token} from a previous
852
+ * {@link google.spanner.v1.ListSessionsResponse|ListSessionsResponse}.
853
+ * @param {string} request.filter
854
+ * An expression for filtering the results of the request. Filter rules are
855
+ * case insensitive. The fields eligible for filtering are:
856
+ *
857
+ * * `labels.key` where key is the name of a label
858
+ *
859
+ * Some examples of using filters are:
860
+ *
861
+ * * `labels.env:*` --> The session has the label "env".
862
+ * * `labels.env:dev` --> The session has the label "env" and the value of
863
+ * the label contains the string "dev".
864
+ * @param {object} [options]
865
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
866
+ * @returns {Promise} - The promise which resolves to an array.
867
+ * The first element of the array is Array of [Session]{@link google.spanner.v1.Session}.
868
+ * The client library will perform auto-pagination by default: it will call the API as many
869
+ * times as needed and will merge results from all the pages into this array.
870
+ * Note that it can affect your quota.
871
+ * We recommend using `listSessionsAsync()`
872
+ * method described below for async iteration which you can stop as needed.
873
+ * Please see the
874
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
875
+ * for more details and examples.
876
+ */
301
877
  listSessions(request?: protos.google.spanner.v1.IListSessionsRequest, options?: CallOptions): Promise<[protos.google.spanner.v1.ISession[], protos.google.spanner.v1.IListSessionsRequest | null, protos.google.spanner.v1.IListSessionsResponse]>;
302
878
  listSessions(request: protos.google.spanner.v1.IListSessionsRequest, options: CallOptions, callback: PaginationCallback<protos.google.spanner.v1.IListSessionsRequest, protos.google.spanner.v1.IListSessionsResponse | null | undefined, protos.google.spanner.v1.ISession>): void;
303
879
  listSessions(request: protos.google.spanner.v1.IListSessionsRequest, callback: PaginationCallback<protos.google.spanner.v1.IListSessionsRequest, protos.google.spanner.v1.IListSessionsResponse | null | undefined, protos.google.spanner.v1.ISession>): void;
@@ -374,11 +950,8 @@ export declare class SpannerClient {
374
950
  * Please see the
375
951
  * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
376
952
  * for more details and examples.
377
- * @example
378
- * const iterable = client.listSessionsAsync(request);
379
- * for await (const response of iterable) {
380
- * // process response
381
- * }
953
+ * @example <caption>include:samples/generated/v1/spanner.list_sessions.js</caption>
954
+ * region_tag:spanner_v1_generated_Spanner_ListSessions_async
382
955
  */
383
956
  listSessionsAsync(request?: protos.google.spanner.v1.IListSessionsRequest, options?: CallOptions): AsyncIterable<protos.google.spanner.v1.ISession>;
384
957
  /**