@google-cloud/spanner 7.18.0 → 7.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -0
  3. package/build/protos/google/spanner/admin/database/v1/backup.proto +757 -0
  4. package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +230 -0
  5. package/build/protos/google/spanner/admin/database/v1/common.proto +132 -0
  6. package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +1209 -0
  7. package/build/protos/google/spanner/admin/instance/v1/common.proto +64 -0
  8. package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +2110 -0
  9. package/build/protos/google/spanner/executor/v1/cloud_executor.proto +1520 -0
  10. package/build/protos/google/spanner/v1/commit_response.proto +59 -0
  11. package/build/protos/google/spanner/v1/keys.proto +163 -0
  12. package/build/protos/google/spanner/v1/mutation.proto +107 -0
  13. package/build/protos/google/spanner/v1/query_plan.proto +128 -0
  14. package/build/protos/google/spanner/v1/result_set.proto +237 -0
  15. package/build/protos/google/spanner/v1/spanner.proto +1389 -0
  16. package/build/protos/google/spanner/v1/transaction.proto +575 -0
  17. package/build/protos/google/spanner/v1/type.proto +214 -0
  18. package/build/protos/protos.d.ts +39317 -0
  19. package/build/protos/protos.js +100360 -0
  20. package/build/protos/protos.json +10271 -0
  21. package/build/src/backup.d.ts +349 -0
  22. package/build/src/backup.js +246 -0
  23. package/build/src/batch-transaction.d.ts +247 -0
  24. package/build/src/batch-transaction.js +384 -0
  25. package/build/src/codec.d.ts +362 -0
  26. package/build/src/codec.js +791 -0
  27. package/build/src/common-grpc/service-object.d.ts +80 -0
  28. package/build/src/common-grpc/service-object.js +101 -0
  29. package/build/src/common-grpc/service.d.ts +445 -0
  30. package/build/src/common-grpc/service.js +826 -0
  31. package/build/src/common.d.ts +66 -0
  32. package/build/src/common.js +54 -0
  33. package/build/src/database.d.ts +2103 -0
  34. package/build/src/database.js +1655 -0
  35. package/build/src/extra_proto_list.json +1 -0
  36. package/build/src/helper.d.ts +45 -0
  37. package/build/src/helper.js +71 -0
  38. package/build/src/index.d.ts +1195 -0
  39. package/build/src/index.js +1059 -0
  40. package/build/src/instance-config.d.ts +294 -0
  41. package/build/src/instance-config.js +216 -0
  42. package/build/src/instance.d.ts +832 -0
  43. package/build/src/instance.js +781 -0
  44. package/build/src/instrument.d.ts +85 -0
  45. package/build/src/instrument.js +215 -0
  46. package/build/src/multiplexed-session.d.ts +136 -0
  47. package/build/src/multiplexed-session.js +197 -0
  48. package/build/src/partial-result-stream.d.ts +253 -0
  49. package/build/src/partial-result-stream.js +400 -0
  50. package/build/src/session-factory.d.ts +100 -0
  51. package/build/src/session-factory.js +93 -0
  52. package/build/src/session-pool.d.ts +471 -0
  53. package/build/src/session-pool.js +754 -0
  54. package/build/src/session.d.ts +258 -0
  55. package/build/src/session.js +348 -0
  56. package/build/src/spanner_grpc_config.json +92 -0
  57. package/build/src/table.d.ts +831 -0
  58. package/build/src/table.js +277 -0
  59. package/build/src/transaction-runner.d.ts +185 -0
  60. package/build/src/transaction-runner.js +282 -0
  61. package/build/src/transaction.d.ts +1691 -0
  62. package/build/src/transaction.js +2004 -0
  63. package/build/src/v1/database_admin_client.d.ts +2301 -0
  64. package/build/src/v1/database_admin_client.js +2286 -0
  65. package/build/src/v1/database_admin_client_config.json +160 -0
  66. package/build/src/v1/database_admin_proto_list.json +6 -0
  67. package/build/src/v1/gapic_metadata.json +27 -0
  68. package/build/src/v1/index.d.ts +4 -0
  69. package/build/src/v1/index.js +29 -0
  70. package/build/src/v1/instance_admin_client.d.ts +1985 -0
  71. package/build/src/v1/instance_admin_client.js +1768 -0
  72. package/build/src/v1/instance_admin_client_config.json +129 -0
  73. package/build/src/v1/instance_admin_proto_list.json +4 -0
  74. package/build/src/v1/spanner_client.d.ts +1250 -0
  75. package/build/src/v1/spanner_client.js +1086 -0
  76. package/build/src/v1/spanner_client_config.json +119 -0
  77. package/build/src/v1/spanner_executor_proxy_client.d.ts +418 -0
  78. package/build/src/v1/spanner_executor_proxy_client.js +706 -0
  79. package/build/src/v1/spanner_executor_proxy_client_config.json +30 -0
  80. package/build/src/v1/spanner_executor_proxy_proto_list.json +14 -0
  81. package/build/src/v1/spanner_proto_list.json +10 -0
  82. package/package.json +1 -1
@@ -0,0 +1,1389 @@
1
+ // Copyright 2024 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ syntax = "proto3";
16
+
17
+ package google.spanner.v1;
18
+
19
+ import public "google/spanner/v1/commit_response.proto";
20
+
21
+ import "google/api/annotations.proto";
22
+ import "google/api/client.proto";
23
+ import "google/api/field_behavior.proto";
24
+ import "google/api/resource.proto";
25
+ import "google/protobuf/duration.proto";
26
+ import "google/protobuf/empty.proto";
27
+ import "google/protobuf/struct.proto";
28
+ import "google/protobuf/timestamp.proto";
29
+ import "google/rpc/status.proto";
30
+ import "google/spanner/v1/keys.proto";
31
+ import "google/spanner/v1/mutation.proto";
32
+ import "google/spanner/v1/result_set.proto";
33
+ import "google/spanner/v1/transaction.proto";
34
+ import "google/spanner/v1/type.proto";
35
+
36
+ option csharp_namespace = "Google.Cloud.Spanner.V1";
37
+ option go_package = "cloud.google.com/go/spanner/apiv1/spannerpb;spannerpb";
38
+ option java_multiple_files = true;
39
+ option java_outer_classname = "SpannerProto";
40
+ option java_package = "com.google.spanner.v1";
41
+ option php_namespace = "Google\\Cloud\\Spanner\\V1";
42
+ option ruby_package = "Google::Cloud::Spanner::V1";
43
+ option (google.api.resource_definition) = {
44
+ type: "spanner.googleapis.com/Database"
45
+ pattern: "projects/{project}/instances/{instance}/databases/{database}"
46
+ };
47
+
48
+ // Cloud Spanner API
49
+ //
50
+ // The Cloud Spanner API can be used to manage sessions and execute
51
+ // transactions on data stored in Cloud Spanner databases.
52
+ service Spanner {
53
+ option (google.api.default_host) = "spanner.googleapis.com";
54
+ option (google.api.oauth_scopes) =
55
+ "https://www.googleapis.com/auth/cloud-platform,"
56
+ "https://www.googleapis.com/auth/spanner.data";
57
+
58
+ // Creates a new session. A session can be used to perform
59
+ // transactions that read and/or modify data in a Cloud Spanner database.
60
+ // Sessions are meant to be reused for many consecutive
61
+ // transactions.
62
+ //
63
+ // Sessions can only execute one transaction at a time. To execute
64
+ // multiple concurrent read-write/write-only transactions, create
65
+ // multiple sessions. Note that standalone reads and queries use a
66
+ // transaction internally, and count toward the one transaction
67
+ // limit.
68
+ //
69
+ // Active sessions use additional server resources, so it is a good idea to
70
+ // delete idle and unneeded sessions.
71
+ // Aside from explicit deletes, Cloud Spanner may delete sessions for which no
72
+ // operations are sent for more than an hour. If a session is deleted,
73
+ // requests to it return `NOT_FOUND`.
74
+ //
75
+ // Idle sessions can be kept alive by sending a trivial SQL query
76
+ // periodically, e.g., `"SELECT 1"`.
77
+ rpc CreateSession(CreateSessionRequest) returns (Session) {
78
+ option (google.api.http) = {
79
+ post: "/v1/{database=projects/*/instances/*/databases/*}/sessions"
80
+ body: "*"
81
+ };
82
+ option (google.api.method_signature) = "database";
83
+ }
84
+
85
+ // Creates multiple new sessions.
86
+ //
87
+ // This API can be used to initialize a session cache on the clients.
88
+ // See https://goo.gl/TgSFN2 for best practices on session cache management.
89
+ rpc BatchCreateSessions(BatchCreateSessionsRequest)
90
+ returns (BatchCreateSessionsResponse) {
91
+ option (google.api.http) = {
92
+ post: "/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate"
93
+ body: "*"
94
+ };
95
+ option (google.api.method_signature) = "database,session_count";
96
+ }
97
+
98
+ // Gets a session. Returns `NOT_FOUND` if the session does not exist.
99
+ // This is mainly useful for determining whether a session is still
100
+ // alive.
101
+ rpc GetSession(GetSessionRequest) returns (Session) {
102
+ option (google.api.http) = {
103
+ get: "/v1/{name=projects/*/instances/*/databases/*/sessions/*}"
104
+ };
105
+ option (google.api.method_signature) = "name";
106
+ }
107
+
108
+ // Lists all sessions in a given database.
109
+ rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse) {
110
+ option (google.api.http) = {
111
+ get: "/v1/{database=projects/*/instances/*/databases/*}/sessions"
112
+ };
113
+ option (google.api.method_signature) = "database";
114
+ }
115
+
116
+ // Ends a session, releasing server resources associated with it. This will
117
+ // asynchronously trigger cancellation of any operations that are running with
118
+ // this session.
119
+ rpc DeleteSession(DeleteSessionRequest) returns (google.protobuf.Empty) {
120
+ option (google.api.http) = {
121
+ delete: "/v1/{name=projects/*/instances/*/databases/*/sessions/*}"
122
+ };
123
+ option (google.api.method_signature) = "name";
124
+ }
125
+
126
+ // Executes an SQL statement, returning all results in a single reply. This
127
+ // method cannot be used to return a result set larger than 10 MiB;
128
+ // if the query yields more data than that, the query fails with
129
+ // a `FAILED_PRECONDITION` error.
130
+ //
131
+ // Operations inside read-write transactions might return `ABORTED`. If
132
+ // this occurs, the application should restart the transaction from
133
+ // the beginning. See [Transaction][google.spanner.v1.Transaction] for more
134
+ // details.
135
+ //
136
+ // Larger result sets can be fetched in streaming fashion by calling
137
+ // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql]
138
+ // instead.
139
+ rpc ExecuteSql(ExecuteSqlRequest) returns (ResultSet) {
140
+ option (google.api.http) = {
141
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql"
142
+ body: "*"
143
+ };
144
+ }
145
+
146
+ // Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the
147
+ // result set as a stream. Unlike
148
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there is no limit on
149
+ // the size of the returned result set. However, no individual row in the
150
+ // result set can exceed 100 MiB, and no column value can exceed 10 MiB.
151
+ rpc ExecuteStreamingSql(ExecuteSqlRequest) returns (stream PartialResultSet) {
152
+ option (google.api.http) = {
153
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql"
154
+ body: "*"
155
+ };
156
+ }
157
+
158
+ // Executes a batch of SQL DML statements. This method allows many statements
159
+ // to be run with lower latency than submitting them sequentially with
160
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
161
+ //
162
+ // Statements are executed in sequential order. A request can succeed even if
163
+ // a statement fails. The
164
+ // [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status]
165
+ // field in the response provides information about the statement that failed.
166
+ // Clients must inspect this field to determine whether an error occurred.
167
+ //
168
+ // Execution stops after the first failed statement; the remaining statements
169
+ // are not executed.
170
+ rpc ExecuteBatchDml(ExecuteBatchDmlRequest)
171
+ returns (ExecuteBatchDmlResponse) {
172
+ option (google.api.http) = {
173
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml"
174
+ body: "*"
175
+ };
176
+ }
177
+
178
+ // Reads rows from the database using key lookups and scans, as a
179
+ // simple key/value style alternative to
180
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be
181
+ // used to return a result set larger than 10 MiB; if the read matches more
182
+ // data than that, the read fails with a `FAILED_PRECONDITION`
183
+ // error.
184
+ //
185
+ // Reads inside read-write transactions might return `ABORTED`. If
186
+ // this occurs, the application should restart the transaction from
187
+ // the beginning. See [Transaction][google.spanner.v1.Transaction] for more
188
+ // details.
189
+ //
190
+ // Larger result sets can be yielded in streaming fashion by calling
191
+ // [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead.
192
+ rpc Read(ReadRequest) returns (ResultSet) {
193
+ option (google.api.http) = {
194
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read"
195
+ body: "*"
196
+ };
197
+ }
198
+
199
+ // Like [Read][google.spanner.v1.Spanner.Read], except returns the result set
200
+ // as a stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no
201
+ // limit on the size of the returned result set. However, no individual row in
202
+ // the result set can exceed 100 MiB, and no column value can exceed
203
+ // 10 MiB.
204
+ rpc StreamingRead(ReadRequest) returns (stream PartialResultSet) {
205
+ option (google.api.http) = {
206
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead"
207
+ body: "*"
208
+ };
209
+ }
210
+
211
+ // Begins a new transaction. This step can often be skipped:
212
+ // [Read][google.spanner.v1.Spanner.Read],
213
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
214
+ // [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a
215
+ // side-effect.
216
+ rpc BeginTransaction(BeginTransactionRequest) returns (Transaction) {
217
+ option (google.api.http) = {
218
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction"
219
+ body: "*"
220
+ };
221
+ option (google.api.method_signature) = "session,options";
222
+ }
223
+
224
+ // Commits a transaction. The request includes the mutations to be
225
+ // applied to rows in the database.
226
+ //
227
+ // `Commit` might return an `ABORTED` error. This can occur at any time;
228
+ // commonly, the cause is conflicts with concurrent
229
+ // transactions. However, it can also happen for a variety of other
230
+ // reasons. If `Commit` returns `ABORTED`, the caller should re-attempt
231
+ // the transaction from the beginning, re-using the same session.
232
+ //
233
+ // On very rare occasions, `Commit` might return `UNKNOWN`. This can happen,
234
+ // for example, if the client job experiences a 1+ hour networking failure.
235
+ // At that point, Cloud Spanner has lost track of the transaction outcome and
236
+ // we recommend that you perform another read from the database to see the
237
+ // state of things as they are now.
238
+ rpc Commit(CommitRequest) returns (CommitResponse) {
239
+ option (google.api.http) = {
240
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit"
241
+ body: "*"
242
+ };
243
+ option (google.api.method_signature) = "session,transaction_id,mutations";
244
+ option (google.api.method_signature) =
245
+ "session,single_use_transaction,mutations";
246
+ }
247
+
248
+ // Rolls back a transaction, releasing any locks it holds. It is a good
249
+ // idea to call this for any transaction that includes one or more
250
+ // [Read][google.spanner.v1.Spanner.Read] or
251
+ // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and ultimately
252
+ // decides not to commit.
253
+ //
254
+ // `Rollback` returns `OK` if it successfully aborts the transaction, the
255
+ // transaction was already aborted, or the transaction is not
256
+ // found. `Rollback` never returns `ABORTED`.
257
+ rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) {
258
+ option (google.api.http) = {
259
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback"
260
+ body: "*"
261
+ };
262
+ option (google.api.method_signature) = "session,transaction_id";
263
+ }
264
+
265
+ // Creates a set of partition tokens that can be used to execute a query
266
+ // operation in parallel. Each of the returned partition tokens can be used
267
+ // by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to
268
+ // specify a subset of the query result to read. The same session and
269
+ // read-only transaction must be used by the PartitionQueryRequest used to
270
+ // create the partition tokens and the ExecuteSqlRequests that use the
271
+ // partition tokens.
272
+ //
273
+ // Partition tokens become invalid when the session used to create them
274
+ // is deleted, is idle for too long, begins a new transaction, or becomes too
275
+ // old. When any of these happen, it is not possible to resume the query, and
276
+ // the whole operation must be restarted from the beginning.
277
+ rpc PartitionQuery(PartitionQueryRequest) returns (PartitionResponse) {
278
+ option (google.api.http) = {
279
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery"
280
+ body: "*"
281
+ };
282
+ }
283
+
284
+ // Creates a set of partition tokens that can be used to execute a read
285
+ // operation in parallel. Each of the returned partition tokens can be used
286
+ // by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a
287
+ // subset of the read result to read. The same session and read-only
288
+ // transaction must be used by the PartitionReadRequest used to create the
289
+ // partition tokens and the ReadRequests that use the partition tokens. There
290
+ // are no ordering guarantees on rows returned among the returned partition
291
+ // tokens, or even within each individual StreamingRead call issued with a
292
+ // partition_token.
293
+ //
294
+ // Partition tokens become invalid when the session used to create them
295
+ // is deleted, is idle for too long, begins a new transaction, or becomes too
296
+ // old. When any of these happen, it is not possible to resume the read, and
297
+ // the whole operation must be restarted from the beginning.
298
+ rpc PartitionRead(PartitionReadRequest) returns (PartitionResponse) {
299
+ option (google.api.http) = {
300
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionRead"
301
+ body: "*"
302
+ };
303
+ }
304
+
305
+ // Batches the supplied mutation groups in a collection of efficient
306
+ // transactions. All mutations in a group are committed atomically. However,
307
+ // mutations across groups can be committed non-atomically in an unspecified
308
+ // order and thus, they must be independent of each other. Partial failure is
309
+ // possible, i.e., some groups may have been committed successfully, while
310
+ // some may have failed. The results of individual batches are streamed into
311
+ // the response as the batches are applied.
312
+ //
313
+ // BatchWrite requests are not replay protected, meaning that each mutation
314
+ // group may be applied more than once. Replays of non-idempotent mutations
315
+ // may have undesirable effects. For example, replays of an insert mutation
316
+ // may produce an already exists error or if you use generated or commit
317
+ // timestamp-based keys, it may result in additional rows being added to the
318
+ // mutation's table. We recommend structuring your mutation groups to be
319
+ // idempotent to avoid this issue.
320
+ rpc BatchWrite(BatchWriteRequest) returns (stream BatchWriteResponse) {
321
+ option (google.api.http) = {
322
+ post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:batchWrite"
323
+ body: "*"
324
+ };
325
+ option (google.api.method_signature) = "session,mutation_groups";
326
+ }
327
+ }
328
+
329
+ // The request for [CreateSession][google.spanner.v1.Spanner.CreateSession].
330
+ message CreateSessionRequest {
331
+ // Required. The database in which the new session is created.
332
+ string database = 1 [
333
+ (google.api.field_behavior) = REQUIRED,
334
+ (google.api.resource_reference) = {
335
+ type: "spanner.googleapis.com/Database"
336
+ }
337
+ ];
338
+
339
+ // Required. The session to create.
340
+ Session session = 2 [(google.api.field_behavior) = REQUIRED];
341
+ }
342
+
343
+ // The request for
344
+ // [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
345
+ message BatchCreateSessionsRequest {
346
+ // Required. The database in which the new sessions are created.
347
+ string database = 1 [
348
+ (google.api.field_behavior) = REQUIRED,
349
+ (google.api.resource_reference) = {
350
+ type: "spanner.googleapis.com/Database"
351
+ }
352
+ ];
353
+
354
+ // Parameters to be applied to each created session.
355
+ Session session_template = 2;
356
+
357
+ // Required. The number of sessions to be created in this batch call.
358
+ // The API may return fewer than the requested number of sessions. If a
359
+ // specific number of sessions are desired, the client can make additional
360
+ // calls to BatchCreateSessions (adjusting
361
+ // [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count]
362
+ // as necessary).
363
+ int32 session_count = 3 [(google.api.field_behavior) = REQUIRED];
364
+ }
365
+
366
+ // The response for
367
+ // [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
368
+ message BatchCreateSessionsResponse {
369
+ // The freshly created sessions.
370
+ repeated Session session = 1;
371
+ }
372
+
373
+ // A session in the Cloud Spanner API.
374
+ message Session {
375
+ option (google.api.resource) = {
376
+ type: "spanner.googleapis.com/Session"
377
+ pattern: "projects/{project}/instances/{instance}/databases/{database}/sessions/{session}"
378
+ };
379
+
380
+ // Output only. The name of the session. This is always system-assigned.
381
+ string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
382
+
383
+ // The labels for the session.
384
+ //
385
+ // * Label keys must be between 1 and 63 characters long and must conform to
386
+ // the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.
387
+ // * Label values must be between 0 and 63 characters long and must conform
388
+ // to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
389
+ // * No more than 64 labels can be associated with a given session.
390
+ //
391
+ // See https://goo.gl/xmQnxf for more information on and examples of labels.
392
+ map<string, string> labels = 2;
393
+
394
+ // Output only. The timestamp when the session is created.
395
+ google.protobuf.Timestamp create_time = 3
396
+ [(google.api.field_behavior) = OUTPUT_ONLY];
397
+
398
+ // Output only. The approximate timestamp when the session is last used. It is
399
+ // typically earlier than the actual last use time.
400
+ google.protobuf.Timestamp approximate_last_use_time = 4
401
+ [(google.api.field_behavior) = OUTPUT_ONLY];
402
+
403
+ // The database role which created this session.
404
+ string creator_role = 5;
405
+
406
+ // Optional. If true, specifies a multiplexed session. A multiplexed session
407
+ // may be used for multiple, concurrent read-only operations but can not be
408
+ // used for read-write transactions, partitioned reads, or partitioned
409
+ // queries. Multiplexed sessions can be created via
410
+ // [CreateSession][google.spanner.v1.Spanner.CreateSession] but not via
411
+ // [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
412
+ // Multiplexed sessions may not be deleted nor listed.
413
+ bool multiplexed = 6 [(google.api.field_behavior) = OPTIONAL];
414
+ }
415
+
416
+ // The request for [GetSession][google.spanner.v1.Spanner.GetSession].
417
+ message GetSessionRequest {
418
+ // Required. The name of the session to retrieve.
419
+ string name = 1 [
420
+ (google.api.field_behavior) = REQUIRED,
421
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
422
+ ];
423
+ }
424
+
425
+ // The request for [ListSessions][google.spanner.v1.Spanner.ListSessions].
426
+ message ListSessionsRequest {
427
+ // Required. The database in which to list sessions.
428
+ string database = 1 [
429
+ (google.api.field_behavior) = REQUIRED,
430
+ (google.api.resource_reference) = {
431
+ type: "spanner.googleapis.com/Database"
432
+ }
433
+ ];
434
+
435
+ // Number of sessions to be returned in the response. If 0 or less, defaults
436
+ // to the server's maximum allowed page size.
437
+ int32 page_size = 2;
438
+
439
+ // If non-empty, `page_token` should contain a
440
+ // [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token]
441
+ // from a previous
442
+ // [ListSessionsResponse][google.spanner.v1.ListSessionsResponse].
443
+ string page_token = 3;
444
+
445
+ // An expression for filtering the results of the request. Filter rules are
446
+ // case insensitive. The fields eligible for filtering are:
447
+ //
448
+ // * `labels.key` where key is the name of a label
449
+ //
450
+ // Some examples of using filters are:
451
+ //
452
+ // * `labels.env:*` --> The session has the label "env".
453
+ // * `labels.env:dev` --> The session has the label "env" and the value of
454
+ // the label contains the string "dev".
455
+ string filter = 4;
456
+ }
457
+
458
+ // The response for [ListSessions][google.spanner.v1.Spanner.ListSessions].
459
+ message ListSessionsResponse {
460
+ // The list of requested sessions.
461
+ repeated Session sessions = 1;
462
+
463
+ // `next_page_token` can be sent in a subsequent
464
+ // [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more
465
+ // of the matching sessions.
466
+ string next_page_token = 2;
467
+ }
468
+
469
+ // The request for [DeleteSession][google.spanner.v1.Spanner.DeleteSession].
470
+ message DeleteSessionRequest {
471
+ // Required. The name of the session to delete.
472
+ string name = 1 [
473
+ (google.api.field_behavior) = REQUIRED,
474
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
475
+ ];
476
+ }
477
+
478
+ // Common request options for various APIs.
479
+ message RequestOptions {
480
+ // The relative priority for requests. Note that priority is not applicable
481
+ // for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
482
+ //
483
+ // The priority acts as a hint to the Cloud Spanner scheduler and does not
484
+ // guarantee priority or order of execution. For example:
485
+ //
486
+ // * Some parts of a write operation always execute at `PRIORITY_HIGH`,
487
+ // regardless of the specified priority. This may cause you to see an
488
+ // increase in high priority workload even when executing a low priority
489
+ // request. This can also potentially cause a priority inversion where a
490
+ // lower priority request will be fulfilled ahead of a higher priority
491
+ // request.
492
+ // * If a transaction contains multiple operations with different priorities,
493
+ // Cloud Spanner does not guarantee to process the higher priority
494
+ // operations first. There may be other constraints to satisfy, such as
495
+ // order of operations.
496
+ enum Priority {
497
+ // `PRIORITY_UNSPECIFIED` is equivalent to `PRIORITY_HIGH`.
498
+ PRIORITY_UNSPECIFIED = 0;
499
+
500
+ // This specifies that the request is low priority.
501
+ PRIORITY_LOW = 1;
502
+
503
+ // This specifies that the request is medium priority.
504
+ PRIORITY_MEDIUM = 2;
505
+
506
+ // This specifies that the request is high priority.
507
+ PRIORITY_HIGH = 3;
508
+ }
509
+
510
+ // Priority for the request.
511
+ Priority priority = 1;
512
+
513
+ // A per-request tag which can be applied to queries or reads, used for
514
+ // statistics collection.
515
+ // Both request_tag and transaction_tag can be specified for a read or query
516
+ // that belongs to a transaction.
517
+ // This field is ignored for requests where it's not applicable (e.g.
518
+ // CommitRequest).
519
+ // Legal characters for `request_tag` values are all printable characters
520
+ // (ASCII 32 - 126) and the length of a request_tag is limited to 50
521
+ // characters. Values that exceed this limit are truncated.
522
+ // Any leading underscore (_) characters will be removed from the string.
523
+ string request_tag = 2;
524
+
525
+ // A tag used for statistics collection about this transaction.
526
+ // Both request_tag and transaction_tag can be specified for a read or query
527
+ // that belongs to a transaction.
528
+ // The value of transaction_tag should be the same for all requests belonging
529
+ // to the same transaction.
530
+ // If this request doesn't belong to any transaction, transaction_tag will be
531
+ // ignored.
532
+ // Legal characters for `transaction_tag` values are all printable characters
533
+ // (ASCII 32 - 126) and the length of a transaction_tag is limited to 50
534
+ // characters. Values that exceed this limit are truncated.
535
+ // Any leading underscore (_) characters will be removed from the string.
536
+ string transaction_tag = 3;
537
+ }
538
+
539
+ // The DirectedReadOptions can be used to indicate which replicas or regions
540
+ // should be used for non-transactional reads or queries.
541
+ //
542
+ // DirectedReadOptions may only be specified for a read-only transaction,
543
+ // otherwise the API will return an `INVALID_ARGUMENT` error.
544
+ message DirectedReadOptions {
545
+ // The directed read replica selector.
546
+ // Callers must provide one or more of the following fields for replica
547
+ // selection:
548
+ //
549
+ // * `location` - The location must be one of the regions within the
550
+ // multi-region configuration of your database.
551
+ // * `type` - The type of the replica.
552
+ //
553
+ // Some examples of using replica_selectors are:
554
+ //
555
+ // * `location:us-east1` --> The "us-east1" replica(s) of any available type
556
+ // will be used to process the request.
557
+ // * `type:READ_ONLY` --> The "READ_ONLY" type replica(s) in nearest
558
+ // available location will be used to process the
559
+ // request.
560
+ // * `location:us-east1 type:READ_ONLY` --> The "READ_ONLY" type replica(s)
561
+ // in location "us-east1" will be used to process
562
+ // the request.
563
+ message ReplicaSelection {
564
+ // Indicates the type of replica.
565
+ enum Type {
566
+ // Not specified.
567
+ TYPE_UNSPECIFIED = 0;
568
+
569
+ // Read-write replicas support both reads and writes.
570
+ READ_WRITE = 1;
571
+
572
+ // Read-only replicas only support reads (not writes).
573
+ READ_ONLY = 2;
574
+ }
575
+
576
+ // The location or region of the serving requests, e.g. "us-east1".
577
+ string location = 1;
578
+
579
+ // The type of replica.
580
+ Type type = 2;
581
+ }
582
+
583
+ // An IncludeReplicas contains a repeated set of ReplicaSelection which
584
+ // indicates the order in which replicas should be considered.
585
+ message IncludeReplicas {
586
+ // The directed read replica selector.
587
+ repeated ReplicaSelection replica_selections = 1;
588
+
589
+ // If true, Spanner will not route requests to a replica outside the
590
+ // include_replicas list when all of the specified replicas are unavailable
591
+ // or unhealthy. Default value is `false`.
592
+ bool auto_failover_disabled = 2;
593
+ }
594
+
595
+ // An ExcludeReplicas contains a repeated set of ReplicaSelection that should
596
+ // be excluded from serving requests.
597
+ message ExcludeReplicas {
598
+ // The directed read replica selector.
599
+ repeated ReplicaSelection replica_selections = 1;
600
+ }
601
+
602
+ // Required. At most one of either include_replicas or exclude_replicas
603
+ // should be present in the message.
604
+ oneof replicas {
605
+ // Include_replicas indicates the order of replicas (as they appear in
606
+ // this list) to process the request. If auto_failover_disabled is set to
607
+ // true and all replicas are exhausted without finding a healthy replica,
608
+ // Spanner will wait for a replica in the list to become available, requests
609
+ // may fail due to `DEADLINE_EXCEEDED` errors.
610
+ IncludeReplicas include_replicas = 1;
611
+
612
+ // Exclude_replicas indicates that specified replicas should be excluded
613
+ // from serving requests. Spanner will not route requests to the replicas
614
+ // in this list.
615
+ ExcludeReplicas exclude_replicas = 2;
616
+ }
617
+ }
618
+
619
+ // The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
620
+ // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
621
+ message ExecuteSqlRequest {
622
+ // Mode in which the statement must be processed.
623
+ enum QueryMode {
624
+ // The default mode. Only the statement results are returned.
625
+ NORMAL = 0;
626
+
627
+ // This mode returns only the query plan, without any results or
628
+ // execution statistics information.
629
+ PLAN = 1;
630
+
631
+ // This mode returns the query plan, overall execution statistics,
632
+ // operator level execution statistics along with the results. This has a
633
+ // performance overhead compared to the other modes. It is not recommended
634
+ // to use this mode for production traffic.
635
+ PROFILE = 2;
636
+
637
+ // This mode returns the overall (but not operator-level) execution
638
+ // statistics along with the results.
639
+ WITH_STATS = 3;
640
+
641
+ // This mode returns the query plan, overall (but not operator-level)
642
+ // execution statistics along with the results.
643
+ WITH_PLAN_AND_STATS = 4;
644
+ }
645
+
646
+ // Query optimizer configuration.
647
+ message QueryOptions {
648
+ // An option to control the selection of optimizer version.
649
+ //
650
+ // This parameter allows individual queries to pick different query
651
+ // optimizer versions.
652
+ //
653
+ // Specifying `latest` as a value instructs Cloud Spanner to use the
654
+ // latest supported query optimizer version. If not specified, Cloud Spanner
655
+ // uses the optimizer version set at the database level options. Any other
656
+ // positive integer (from the list of supported optimizer versions)
657
+ // overrides the default optimizer version for query execution.
658
+ //
659
+ // The list of supported optimizer versions can be queried from
660
+ // SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS.
661
+ //
662
+ // Executing a SQL statement with an invalid optimizer version fails with
663
+ // an `INVALID_ARGUMENT` error.
664
+ //
665
+ // See
666
+ // https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer
667
+ // for more information on managing the query optimizer.
668
+ //
669
+ // The `optimizer_version` statement hint has precedence over this setting.
670
+ string optimizer_version = 1;
671
+
672
+ // An option to control the selection of optimizer statistics package.
673
+ //
674
+ // This parameter allows individual queries to use a different query
675
+ // optimizer statistics package.
676
+ //
677
+ // Specifying `latest` as a value instructs Cloud Spanner to use the latest
678
+ // generated statistics package. If not specified, Cloud Spanner uses
679
+ // the statistics package set at the database level options, or the latest
680
+ // package if the database option is not set.
681
+ //
682
+ // The statistics package requested by the query has to be exempt from
683
+ // garbage collection. This can be achieved with the following DDL
684
+ // statement:
685
+ //
686
+ // ```
687
+ // ALTER STATISTICS <package_name> SET OPTIONS (allow_gc=false)
688
+ // ```
689
+ //
690
+ // The list of available statistics packages can be queried from
691
+ // `INFORMATION_SCHEMA.SPANNER_STATISTICS`.
692
+ //
693
+ // Executing a SQL statement with an invalid optimizer statistics package
694
+ // or with a statistics package that allows garbage collection fails with
695
+ // an `INVALID_ARGUMENT` error.
696
+ string optimizer_statistics_package = 2;
697
+ }
698
+
699
+ // Required. The session in which the SQL query should be performed.
700
+ string session = 1 [
701
+ (google.api.field_behavior) = REQUIRED,
702
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
703
+ ];
704
+
705
+ // The transaction to use.
706
+ //
707
+ // For queries, if none is provided, the default is a temporary read-only
708
+ // transaction with strong concurrency.
709
+ //
710
+ // Standard DML statements require a read-write transaction. To protect
711
+ // against replays, single-use transactions are not supported. The caller
712
+ // must either supply an existing transaction ID or begin a new transaction.
713
+ //
714
+ // Partitioned DML requires an existing Partitioned DML transaction ID.
715
+ TransactionSelector transaction = 2;
716
+
717
+ // Required. The SQL string.
718
+ string sql = 3 [(google.api.field_behavior) = REQUIRED];
719
+
720
+ // Parameter names and values that bind to placeholders in the SQL string.
721
+ //
722
+ // A parameter placeholder consists of the `@` character followed by the
723
+ // parameter name (for example, `@firstName`). Parameter names must conform
724
+ // to the naming requirements of identifiers as specified at
725
+ // https://cloud.google.com/spanner/docs/lexical#identifiers.
726
+ //
727
+ // Parameters can appear anywhere that a literal value is expected. The same
728
+ // parameter name can be used more than once, for example:
729
+ //
730
+ // `"WHERE id > @msg_id AND id < @msg_id + 100"`
731
+ //
732
+ // It is an error to execute a SQL statement with unbound parameters.
733
+ google.protobuf.Struct params = 4;
734
+
735
+ // It is not always possible for Cloud Spanner to infer the right SQL type
736
+ // from a JSON value. For example, values of type `BYTES` and values
737
+ // of type `STRING` both appear in
738
+ // [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings.
739
+ //
740
+ // In these cases, `param_types` can be used to specify the exact
741
+ // SQL type for some or all of the SQL statement parameters. See the
742
+ // definition of [Type][google.spanner.v1.Type] for more information
743
+ // about SQL types.
744
+ map<string, Type> param_types = 5;
745
+
746
+ // If this request is resuming a previously interrupted SQL statement
747
+ // execution, `resume_token` should be copied from the last
748
+ // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
749
+ // interruption. Doing this enables the new SQL statement execution to resume
750
+ // where the last one left off. The rest of the request parameters must
751
+ // exactly match the request that yielded this token.
752
+ bytes resume_token = 6;
753
+
754
+ // Used to control the amount of debugging information returned in
755
+ // [ResultSetStats][google.spanner.v1.ResultSetStats]. If
756
+ // [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is
757
+ // set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only
758
+ // be set to
759
+ // [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL].
760
+ QueryMode query_mode = 7;
761
+
762
+ // If present, results will be restricted to the specified partition
763
+ // previously created using PartitionQuery(). There must be an exact
764
+ // match for the values of fields common to this message and the
765
+ // PartitionQueryRequest message used to create this partition_token.
766
+ bytes partition_token = 8;
767
+
768
+ // A per-transaction sequence number used to identify this request. This field
769
+ // makes each request idempotent such that if the request is received multiple
770
+ // times, at most one will succeed.
771
+ //
772
+ // The sequence number must be monotonically increasing within the
773
+ // transaction. If a request arrives for the first time with an out-of-order
774
+ // sequence number, the transaction may be aborted. Replays of previously
775
+ // handled requests will yield the same response as the first execution.
776
+ //
777
+ // Required for DML statements. Ignored for queries.
778
+ int64 seqno = 9;
779
+
780
+ // Query optimizer configuration to use for the given query.
781
+ QueryOptions query_options = 10;
782
+
783
+ // Common options for this request.
784
+ RequestOptions request_options = 11;
785
+
786
+ // Directed read options for this request.
787
+ DirectedReadOptions directed_read_options = 15;
788
+
789
+ // If this is for a partitioned query and this field is set to `true`, the
790
+ // request is executed with Spanner Data Boost independent compute resources.
791
+ //
792
+ // If the field is set to `true` but the request does not set
793
+ // `partition_token`, the API returns an `INVALID_ARGUMENT` error.
794
+ bool data_boost_enabled = 16;
795
+
796
+ // Optional. If set to true, this statement marks the end of the transaction.
797
+ // The transaction should be committed or aborted after this statement
798
+ // executes, and attempts to execute any other requests against this
799
+ // transaction (including reads and queries) will be rejected.
800
+ //
801
+ // For DML statements, setting this option may cause some error reporting to
802
+ // be deferred until commit time (e.g. validation of unique constraints).
803
+ // Given this, successful execution of a DML statement should not be assumed
804
+ // until a subsequent Commit call completes successfully.
805
+ bool last_statement = 17 [(google.api.field_behavior) = OPTIONAL];
806
+ }
807
+
808
+ // The request for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
809
+ message ExecuteBatchDmlRequest {
810
+ // A single DML statement.
811
+ message Statement {
812
+ // Required. The DML string.
813
+ string sql = 1 [(google.api.field_behavior) = REQUIRED];
814
+
815
+ // Parameter names and values that bind to placeholders in the DML string.
816
+ //
817
+ // A parameter placeholder consists of the `@` character followed by the
818
+ // parameter name (for example, `@firstName`). Parameter names can contain
819
+ // letters, numbers, and underscores.
820
+ //
821
+ // Parameters can appear anywhere that a literal value is expected. The
822
+ // same parameter name can be used more than once, for example:
823
+ //
824
+ // `"WHERE id > @msg_id AND id < @msg_id + 100"`
825
+ //
826
+ // It is an error to execute a SQL statement with unbound parameters.
827
+ google.protobuf.Struct params = 2;
828
+
829
+ // It is not always possible for Cloud Spanner to infer the right SQL type
830
+ // from a JSON value. For example, values of type `BYTES` and values
831
+ // of type `STRING` both appear in
832
+ // [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as
833
+ // JSON strings.
834
+ //
835
+ // In these cases, `param_types` can be used to specify the exact
836
+ // SQL type for some or all of the SQL statement parameters. See the
837
+ // definition of [Type][google.spanner.v1.Type] for more information
838
+ // about SQL types.
839
+ map<string, Type> param_types = 3;
840
+ }
841
+
842
+ // Required. The session in which the DML statements should be performed.
843
+ string session = 1 [
844
+ (google.api.field_behavior) = REQUIRED,
845
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
846
+ ];
847
+
848
+ // Required. The transaction to use. Must be a read-write transaction.
849
+ //
850
+ // To protect against replays, single-use transactions are not supported. The
851
+ // caller must either supply an existing transaction ID or begin a new
852
+ // transaction.
853
+ TransactionSelector transaction = 2 [(google.api.field_behavior) = REQUIRED];
854
+
855
+ // Required. The list of statements to execute in this batch. Statements are
856
+ // executed serially, such that the effects of statement `i` are visible to
857
+ // statement `i+1`. Each statement must be a DML statement. Execution stops at
858
+ // the first failed statement; the remaining statements are not executed.
859
+ //
860
+ // Callers must provide at least one statement.
861
+ repeated Statement statements = 3 [(google.api.field_behavior) = REQUIRED];
862
+
863
+ // Required. A per-transaction sequence number used to identify this request.
864
+ // This field makes each request idempotent such that if the request is
865
+ // received multiple times, at most one will succeed.
866
+ //
867
+ // The sequence number must be monotonically increasing within the
868
+ // transaction. If a request arrives for the first time with an out-of-order
869
+ // sequence number, the transaction may be aborted. Replays of previously
870
+ // handled requests will yield the same response as the first execution.
871
+ int64 seqno = 4 [(google.api.field_behavior) = REQUIRED];
872
+
873
+ // Common options for this request.
874
+ RequestOptions request_options = 5;
875
+
876
+ // Optional. If set to true, this request marks the end of the transaction.
877
+ // The transaction should be committed or aborted after these statements
878
+ // execute, and attempts to execute any other requests against this
879
+ // transaction (including reads and queries) will be rejected.
880
+ //
881
+ // Setting this option may cause some error reporting to be deferred until
882
+ // commit time (e.g. validation of unique constraints). Given this, successful
883
+ // execution of statements should not be assumed until a subsequent Commit
884
+ // call completes successfully.
885
+ bool last_statements = 6 [(google.api.field_behavior) = OPTIONAL];
886
+ }
887
+
888
+ // The response for
889
+ // [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
890
+ // of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML
891
+ // statement that has successfully executed, in the same order as the statements
892
+ // in the request. If a statement fails, the status in the response body
893
+ // identifies the cause of the failure.
894
+ //
895
+ // To check for DML statements that failed, use the following approach:
896
+ //
897
+ // 1. Check the status in the response message. The
898
+ // [google.rpc.Code][google.rpc.Code] enum
899
+ // value `OK` indicates that all statements were executed successfully.
900
+ // 2. If the status was not `OK`, check the number of result sets in the
901
+ // response. If the response contains `N`
902
+ // [ResultSet][google.spanner.v1.ResultSet] messages, then statement `N+1` in
903
+ // the request failed.
904
+ //
905
+ // Example 1:
906
+ //
907
+ // * Request: 5 DML statements, all executed successfully.
908
+ // * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the
909
+ // status `OK`.
910
+ //
911
+ // Example 2:
912
+ //
913
+ // * Request: 5 DML statements. The third statement has a syntax error.
914
+ // * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax
915
+ // error (`INVALID_ARGUMENT`)
916
+ // status. The number of [ResultSet][google.spanner.v1.ResultSet] messages
917
+ // indicates that the third statement failed, and the fourth and fifth
918
+ // statements were not executed.
919
+ message ExecuteBatchDmlResponse {
920
+ // One [ResultSet][google.spanner.v1.ResultSet] for each statement in the
921
+ // request that ran successfully, in the same order as the statements in the
922
+ // request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any
923
+ // rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each
924
+ // [ResultSet][google.spanner.v1.ResultSet] contain the number of rows
925
+ // modified by the statement.
926
+ //
927
+ // Only the first [ResultSet][google.spanner.v1.ResultSet] in the response
928
+ // contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata].
929
+ repeated ResultSet result_sets = 1;
930
+
931
+ // If all DML statements are executed successfully, the status is `OK`.
932
+ // Otherwise, the error status of the first failed statement.
933
+ google.rpc.Status status = 2;
934
+
935
+ // Optional. A precommit token will be included if the read-write transaction
936
+ // is on a multiplexed session.
937
+ // The precommit token with the highest sequence number from this transaction
938
+ // attempt should be passed to the
939
+ // [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
940
+ // This feature is not yet supported and will result in an UNIMPLEMENTED
941
+ // error.
942
+ MultiplexedSessionPrecommitToken precommit_token = 3
943
+ [(google.api.field_behavior) = OPTIONAL];
944
+ }
945
+
946
+ // Options for a PartitionQueryRequest and
947
+ // PartitionReadRequest.
948
+ message PartitionOptions {
949
+ // **Note:** This hint is currently ignored by PartitionQuery and
950
+ // PartitionRead requests.
951
+ //
952
+ // The desired data size for each partition generated. The default for this
953
+ // option is currently 1 GiB. This is only a hint. The actual size of each
954
+ // partition may be smaller or larger than this size request.
955
+ int64 partition_size_bytes = 1;
956
+
957
+ // **Note:** This hint is currently ignored by PartitionQuery and
958
+ // PartitionRead requests.
959
+ //
960
+ // The desired maximum number of partitions to return. For example, this may
961
+ // be set to the number of workers available. The default for this option
962
+ // is currently 10,000. The maximum value is currently 200,000. This is only
963
+ // a hint. The actual number of partitions returned may be smaller or larger
964
+ // than this maximum count request.
965
+ int64 max_partitions = 2;
966
+ }
967
+
968
+ // The request for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
969
+ message PartitionQueryRequest {
970
+ // Required. The session used to create the partitions.
971
+ string session = 1 [
972
+ (google.api.field_behavior) = REQUIRED,
973
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
974
+ ];
975
+
976
+ // Read only snapshot transactions are supported, read/write and single use
977
+ // transactions are not.
978
+ TransactionSelector transaction = 2;
979
+
980
+ // Required. The query request to generate partitions for. The request will
981
+ // fail if the query is not root partitionable. For a query to be root
982
+ // partitionable, it needs to satisfy a few conditions. For example, if the
983
+ // query execution plan contains a distributed union operator, then it must be
984
+ // the first operator in the plan. For more information about other
985
+ // conditions, see [Read data in
986
+ // parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel).
987
+ //
988
+ // The query request must not contain DML commands, such as INSERT, UPDATE, or
989
+ // DELETE. Use
990
+ // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a
991
+ // PartitionedDml transaction for large, partition-friendly DML operations.
992
+ string sql = 3 [(google.api.field_behavior) = REQUIRED];
993
+
994
+ // Parameter names and values that bind to placeholders in the SQL string.
995
+ //
996
+ // A parameter placeholder consists of the `@` character followed by the
997
+ // parameter name (for example, `@firstName`). Parameter names can contain
998
+ // letters, numbers, and underscores.
999
+ //
1000
+ // Parameters can appear anywhere that a literal value is expected. The same
1001
+ // parameter name can be used more than once, for example:
1002
+ //
1003
+ // `"WHERE id > @msg_id AND id < @msg_id + 100"`
1004
+ //
1005
+ // It is an error to execute a SQL statement with unbound parameters.
1006
+ google.protobuf.Struct params = 4;
1007
+
1008
+ // It is not always possible for Cloud Spanner to infer the right SQL type
1009
+ // from a JSON value. For example, values of type `BYTES` and values
1010
+ // of type `STRING` both appear in
1011
+ // [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings.
1012
+ //
1013
+ // In these cases, `param_types` can be used to specify the exact
1014
+ // SQL type for some or all of the SQL query parameters. See the
1015
+ // definition of [Type][google.spanner.v1.Type] for more information
1016
+ // about SQL types.
1017
+ map<string, Type> param_types = 5;
1018
+
1019
+ // Additional options that affect how many partitions are created.
1020
+ PartitionOptions partition_options = 6;
1021
+ }
1022
+
1023
+ // The request for [PartitionRead][google.spanner.v1.Spanner.PartitionRead]
1024
+ message PartitionReadRequest {
1025
+ // Required. The session used to create the partitions.
1026
+ string session = 1 [
1027
+ (google.api.field_behavior) = REQUIRED,
1028
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1029
+ ];
1030
+
1031
+ // Read only snapshot transactions are supported, read/write and single use
1032
+ // transactions are not.
1033
+ TransactionSelector transaction = 2;
1034
+
1035
+ // Required. The name of the table in the database to be read.
1036
+ string table = 3 [(google.api.field_behavior) = REQUIRED];
1037
+
1038
+ // If non-empty, the name of an index on
1039
+ // [table][google.spanner.v1.PartitionReadRequest.table]. This index is used
1040
+ // instead of the table primary key when interpreting
1041
+ // [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting
1042
+ // result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set]
1043
+ // for further information.
1044
+ string index = 4;
1045
+
1046
+ // The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be
1047
+ // returned for each row matching this request.
1048
+ repeated string columns = 5;
1049
+
1050
+ // Required. `key_set` identifies the rows to be yielded. `key_set` names the
1051
+ // primary keys of the rows in
1052
+ // [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless
1053
+ // [index][google.spanner.v1.PartitionReadRequest.index] is present. If
1054
+ // [index][google.spanner.v1.PartitionReadRequest.index] is present, then
1055
+ // [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names
1056
+ // index keys in [index][google.spanner.v1.PartitionReadRequest.index].
1057
+ //
1058
+ // It is not an error for the `key_set` to name rows that do not
1059
+ // exist in the database. Read yields nothing for nonexistent rows.
1060
+ KeySet key_set = 6 [(google.api.field_behavior) = REQUIRED];
1061
+
1062
+ // Additional options that affect how many partitions are created.
1063
+ PartitionOptions partition_options = 9;
1064
+ }
1065
+
1066
+ // Information returned for each partition returned in a
1067
+ // PartitionResponse.
1068
+ message Partition {
1069
+ // This token can be passed to Read, StreamingRead, ExecuteSql, or
1070
+ // ExecuteStreamingSql requests to restrict the results to those identified by
1071
+ // this partition token.
1072
+ bytes partition_token = 1;
1073
+ }
1074
+
1075
+ // The response for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
1076
+ // or [PartitionRead][google.spanner.v1.Spanner.PartitionRead]
1077
+ message PartitionResponse {
1078
+ // Partitions created by this request.
1079
+ repeated Partition partitions = 1;
1080
+
1081
+ // Transaction created by this request.
1082
+ Transaction transaction = 2;
1083
+ }
1084
+
1085
+ // The request for [Read][google.spanner.v1.Spanner.Read] and
1086
+ // [StreamingRead][google.spanner.v1.Spanner.StreamingRead].
1087
+ message ReadRequest {
1088
+ // An option to control the order in which rows are returned from a read.
1089
+ enum OrderBy {
1090
+ // Default value.
1091
+ //
1092
+ // ORDER_BY_UNSPECIFIED is equivalent to ORDER_BY_PRIMARY_KEY.
1093
+ ORDER_BY_UNSPECIFIED = 0;
1094
+
1095
+ // Read rows are returned in primary key order.
1096
+ //
1097
+ // In the event that this option is used in conjunction with the
1098
+ // `partition_token` field, the API will return an `INVALID_ARGUMENT` error.
1099
+ ORDER_BY_PRIMARY_KEY = 1;
1100
+
1101
+ // Read rows are returned in any order.
1102
+ ORDER_BY_NO_ORDER = 2;
1103
+ }
1104
+
1105
+ // A lock hint mechanism for reads done within a transaction.
1106
+ enum LockHint {
1107
+ // Default value.
1108
+ //
1109
+ // LOCK_HINT_UNSPECIFIED is equivalent to LOCK_HINT_SHARED.
1110
+ LOCK_HINT_UNSPECIFIED = 0;
1111
+
1112
+ // Acquire shared locks.
1113
+ //
1114
+ // By default when you perform a read as part of a read-write transaction,
1115
+ // Spanner acquires shared read locks, which allows other reads to still
1116
+ // access the data until your transaction is ready to commit. When your
1117
+ // transaction is committing and writes are being applied, the transaction
1118
+ // attempts to upgrade to an exclusive lock for any data you are writing.
1119
+ // For more information about locks, see [Lock
1120
+ // modes](https://cloud.google.com/spanner/docs/introspection/lock-statistics#explain-lock-modes).
1121
+ LOCK_HINT_SHARED = 1;
1122
+
1123
+ // Acquire exclusive locks.
1124
+ //
1125
+ // Requesting exclusive locks is beneficial if you observe high write
1126
+ // contention, which means you notice that multiple transactions are
1127
+ // concurrently trying to read and write to the same data, resulting in a
1128
+ // large number of aborts. This problem occurs when two transactions
1129
+ // initially acquire shared locks and then both try to upgrade to exclusive
1130
+ // locks at the same time. In this situation both transactions are waiting
1131
+ // for the other to give up their lock, resulting in a deadlocked situation.
1132
+ // Spanner is able to detect this occurring and force one of the
1133
+ // transactions to abort. However, this is a slow and expensive operation
1134
+ // and results in lower performance. In this case it makes sense to acquire
1135
+ // exclusive locks at the start of the transaction because then when
1136
+ // multiple transactions try to act on the same data, they automatically get
1137
+ // serialized. Each transaction waits its turn to acquire the lock and
1138
+ // avoids getting into deadlock situations.
1139
+ //
1140
+ // Because the exclusive lock hint is just a hint, it should not be
1141
+ // considered equivalent to a mutex. In other words, you should not use
1142
+ // Spanner exclusive locks as a mutual exclusion mechanism for the execution
1143
+ // of code outside of Spanner.
1144
+ //
1145
+ // **Note:** Request exclusive locks judiciously because they block others
1146
+ // from reading that data for the entire transaction, rather than just when
1147
+ // the writes are being performed. Unless you observe high write contention,
1148
+ // you should use the default of shared read locks so you don't prematurely
1149
+ // block other clients from reading the data that you're writing to.
1150
+ LOCK_HINT_EXCLUSIVE = 2;
1151
+ }
1152
+
1153
+ // Required. The session in which the read should be performed.
1154
+ string session = 1 [
1155
+ (google.api.field_behavior) = REQUIRED,
1156
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1157
+ ];
1158
+
1159
+ // The transaction to use. If none is provided, the default is a
1160
+ // temporary read-only transaction with strong concurrency.
1161
+ TransactionSelector transaction = 2;
1162
+
1163
+ // Required. The name of the table in the database to be read.
1164
+ string table = 3 [(google.api.field_behavior) = REQUIRED];
1165
+
1166
+ // If non-empty, the name of an index on
1167
+ // [table][google.spanner.v1.ReadRequest.table]. This index is used instead of
1168
+ // the table primary key when interpreting
1169
+ // [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows.
1170
+ // See [key_set][google.spanner.v1.ReadRequest.key_set] for further
1171
+ // information.
1172
+ string index = 4;
1173
+
1174
+ // Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be
1175
+ // returned for each row matching this request.
1176
+ repeated string columns = 5 [(google.api.field_behavior) = REQUIRED];
1177
+
1178
+ // Required. `key_set` identifies the rows to be yielded. `key_set` names the
1179
+ // primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to
1180
+ // be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present.
1181
+ // If [index][google.spanner.v1.ReadRequest.index] is present, then
1182
+ // [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys
1183
+ // in [index][google.spanner.v1.ReadRequest.index].
1184
+ //
1185
+ // If the [partition_token][google.spanner.v1.ReadRequest.partition_token]
1186
+ // field is empty, rows are yielded in table primary key order (if
1187
+ // [index][google.spanner.v1.ReadRequest.index] is empty) or index key order
1188
+ // (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the
1189
+ // [partition_token][google.spanner.v1.ReadRequest.partition_token] field is
1190
+ // not empty, rows will be yielded in an unspecified order.
1191
+ //
1192
+ // It is not an error for the `key_set` to name rows that do not
1193
+ // exist in the database. Read yields nothing for nonexistent rows.
1194
+ KeySet key_set = 6 [(google.api.field_behavior) = REQUIRED];
1195
+
1196
+ // If greater than zero, only the first `limit` rows are yielded. If `limit`
1197
+ // is zero, the default is no limit. A limit cannot be specified if
1198
+ // `partition_token` is set.
1199
+ int64 limit = 8;
1200
+
1201
+ // If this request is resuming a previously interrupted read,
1202
+ // `resume_token` should be copied from the last
1203
+ // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
1204
+ // interruption. Doing this enables the new read to resume where the last read
1205
+ // left off. The rest of the request parameters must exactly match the request
1206
+ // that yielded this token.
1207
+ bytes resume_token = 9;
1208
+
1209
+ // If present, results will be restricted to the specified partition
1210
+ // previously created using PartitionRead(). There must be an exact
1211
+ // match for the values of fields common to this message and the
1212
+ // PartitionReadRequest message used to create this partition_token.
1213
+ bytes partition_token = 10;
1214
+
1215
+ // Common options for this request.
1216
+ RequestOptions request_options = 11;
1217
+
1218
+ // Directed read options for this request.
1219
+ DirectedReadOptions directed_read_options = 14;
1220
+
1221
+ // If this is for a partitioned read and this field is set to `true`, the
1222
+ // request is executed with Spanner Data Boost independent compute resources.
1223
+ //
1224
+ // If the field is set to `true` but the request does not set
1225
+ // `partition_token`, the API returns an `INVALID_ARGUMENT` error.
1226
+ bool data_boost_enabled = 15;
1227
+
1228
+ // Optional. Order for the returned rows.
1229
+ //
1230
+ // By default, Spanner will return result rows in primary key order except for
1231
+ // PartitionRead requests. For applications that do not require rows to be
1232
+ // returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting
1233
+ // `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval,
1234
+ // resulting in lower latencies in certain cases (e.g. bulk point lookups).
1235
+ OrderBy order_by = 16 [(google.api.field_behavior) = OPTIONAL];
1236
+
1237
+ // Optional. Lock Hint for the request, it can only be used with read-write
1238
+ // transactions.
1239
+ LockHint lock_hint = 17 [(google.api.field_behavior) = OPTIONAL];
1240
+ }
1241
+
1242
+ // The request for
1243
+ // [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
1244
+ message BeginTransactionRequest {
1245
+ // Required. The session in which the transaction runs.
1246
+ string session = 1 [
1247
+ (google.api.field_behavior) = REQUIRED,
1248
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1249
+ ];
1250
+
1251
+ // Required. Options for the new transaction.
1252
+ TransactionOptions options = 2 [(google.api.field_behavior) = REQUIRED];
1253
+
1254
+ // Common options for this request.
1255
+ // Priority is ignored for this request. Setting the priority in this
1256
+ // request_options struct will not do anything. To set the priority for a
1257
+ // transaction, set it on the reads and writes that are part of this
1258
+ // transaction instead.
1259
+ RequestOptions request_options = 3;
1260
+
1261
+ // Optional. Required for read-write transactions on a multiplexed session
1262
+ // that commit mutations but do not perform any reads or queries. Clients
1263
+ // should randomly select one of the mutations from the mutation set and send
1264
+ // it as a part of this request.
1265
+ // This feature is not yet supported and will result in an UNIMPLEMENTED
1266
+ // error.
1267
+ Mutation mutation_key = 4 [(google.api.field_behavior) = OPTIONAL];
1268
+ }
1269
+
1270
+ // The request for [Commit][google.spanner.v1.Spanner.Commit].
1271
+ message CommitRequest {
1272
+ // Required. The session in which the transaction to be committed is running.
1273
+ string session = 1 [
1274
+ (google.api.field_behavior) = REQUIRED,
1275
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1276
+ ];
1277
+
1278
+ // Required. The transaction in which to commit.
1279
+ oneof transaction {
1280
+ // Commit a previously-started transaction.
1281
+ bytes transaction_id = 2;
1282
+
1283
+ // Execute mutations in a temporary transaction. Note that unlike
1284
+ // commit of a previously-started transaction, commit with a
1285
+ // temporary transaction is non-idempotent. That is, if the
1286
+ // `CommitRequest` is sent to Cloud Spanner more than once (for
1287
+ // instance, due to retries in the application, or in the
1288
+ // transport library), it is possible that the mutations are
1289
+ // executed more than once. If this is undesirable, use
1290
+ // [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and
1291
+ // [Commit][google.spanner.v1.Spanner.Commit] instead.
1292
+ TransactionOptions single_use_transaction = 3;
1293
+ }
1294
+
1295
+ // The mutations to be executed when this transaction commits. All
1296
+ // mutations are applied atomically, in the order they appear in
1297
+ // this list.
1298
+ repeated Mutation mutations = 4;
1299
+
1300
+ // If `true`, then statistics related to the transaction will be included in
1301
+ // the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats].
1302
+ // Default value is `false`.
1303
+ bool return_commit_stats = 5;
1304
+
1305
+ // Optional. The amount of latency this request is willing to incur in order
1306
+ // to improve throughput. If this field is not set, Spanner assumes requests
1307
+ // are relatively latency sensitive and automatically determines an
1308
+ // appropriate delay time. You can specify a batching delay value between 0
1309
+ // and 500 ms.
1310
+ google.protobuf.Duration max_commit_delay = 8
1311
+ [(google.api.field_behavior) = OPTIONAL];
1312
+
1313
+ // Common options for this request.
1314
+ RequestOptions request_options = 6;
1315
+
1316
+ // Optional. If the read-write transaction was executed on a multiplexed
1317
+ // session, the precommit token with the highest sequence number received in
1318
+ // this transaction attempt, should be included here. Failing to do so will
1319
+ // result in a FailedPrecondition error.
1320
+ // This feature is not yet supported and will result in an UNIMPLEMENTED
1321
+ // error.
1322
+ MultiplexedSessionPrecommitToken precommit_token = 9
1323
+ [(google.api.field_behavior) = OPTIONAL];
1324
+ }
1325
+
1326
+ // The request for [Rollback][google.spanner.v1.Spanner.Rollback].
1327
+ message RollbackRequest {
1328
+ // Required. The session in which the transaction to roll back is running.
1329
+ string session = 1 [
1330
+ (google.api.field_behavior) = REQUIRED,
1331
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1332
+ ];
1333
+
1334
+ // Required. The transaction to roll back.
1335
+ bytes transaction_id = 2 [(google.api.field_behavior) = REQUIRED];
1336
+ }
1337
+
1338
+ // The request for [BatchWrite][google.spanner.v1.Spanner.BatchWrite].
1339
+ message BatchWriteRequest {
1340
+ // A group of mutations to be committed together. Related mutations should be
1341
+ // placed in a group. For example, two mutations inserting rows with the same
1342
+ // primary key prefix in both parent and child tables are related.
1343
+ message MutationGroup {
1344
+ // Required. The mutations in this group.
1345
+ repeated Mutation mutations = 1 [(google.api.field_behavior) = REQUIRED];
1346
+ }
1347
+
1348
+ // Required. The session in which the batch request is to be run.
1349
+ string session = 1 [
1350
+ (google.api.field_behavior) = REQUIRED,
1351
+ (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" }
1352
+ ];
1353
+
1354
+ // Common options for this request.
1355
+ RequestOptions request_options = 3;
1356
+
1357
+ // Required. The groups of mutations to be applied.
1358
+ repeated MutationGroup mutation_groups = 4
1359
+ [(google.api.field_behavior) = REQUIRED];
1360
+
1361
+ // Optional. When `exclude_txn_from_change_streams` is set to `true`:
1362
+ // * Mutations from all transactions in this batch write operation will not
1363
+ // be recorded in change streams with DDL option `allow_txn_exclusion=true`
1364
+ // that are tracking columns modified by these transactions.
1365
+ // * Mutations from all transactions in this batch write operation will be
1366
+ // recorded in change streams with DDL option `allow_txn_exclusion=false or
1367
+ // not set` that are tracking columns modified by these transactions.
1368
+ //
1369
+ // When `exclude_txn_from_change_streams` is set to `false` or not set,
1370
+ // mutations from all transactions in this batch write operation will be
1371
+ // recorded in all change streams that are tracking columns modified by these
1372
+ // transactions.
1373
+ bool exclude_txn_from_change_streams = 5
1374
+ [(google.api.field_behavior) = OPTIONAL];
1375
+ }
1376
+
1377
+ // The result of applying a batch of mutations.
1378
+ message BatchWriteResponse {
1379
+ // The mutation groups applied in this batch. The values index into the
1380
+ // `mutation_groups` field in the corresponding `BatchWriteRequest`.
1381
+ repeated int32 indexes = 1;
1382
+
1383
+ // An `OK` status indicates success. Any other status indicates a failure.
1384
+ google.rpc.Status status = 2;
1385
+
1386
+ // The commit timestamp of the transaction that applied this batch.
1387
+ // Present if `status` is `OK`, absent otherwise.
1388
+ google.protobuf.Timestamp commit_timestamp = 3;
1389
+ }