google-cloud-spanner 1.14.0 → 2.0.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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +51 -0
  4. data/CONTRIBUTING.md +5 -5
  5. data/TROUBLESHOOTING.md +0 -6
  6. data/lib/google-cloud-spanner.rb +23 -13
  7. data/lib/google/cloud/spanner.rb +8 -9
  8. data/lib/google/cloud/spanner/admin/database/credentials.rb +2 -2
  9. data/lib/google/cloud/spanner/admin/instance/credentials.rb +2 -2
  10. data/lib/google/cloud/spanner/backup.rb +315 -0
  11. data/lib/google/cloud/spanner/backup/job.rb +274 -0
  12. data/lib/google/cloud/spanner/backup/job/list.rb +177 -0
  13. data/lib/google/cloud/spanner/backup/list.rb +169 -0
  14. data/lib/google/cloud/spanner/backup/restore/job.rb +246 -0
  15. data/lib/google/cloud/spanner/batch_client.rb +7 -5
  16. data/lib/google/cloud/spanner/batch_snapshot.rb +49 -16
  17. data/lib/google/cloud/spanner/batch_update.rb +1 -1
  18. data/lib/google/cloud/spanner/client.rb +65 -16
  19. data/lib/google/cloud/spanner/commit.rb +14 -14
  20. data/lib/google/cloud/spanner/convert.rb +7 -7
  21. data/lib/google/cloud/spanner/credentials.rb +2 -2
  22. data/lib/google/cloud/spanner/data.rb +2 -2
  23. data/lib/google/cloud/spanner/database.rb +275 -15
  24. data/lib/google/cloud/spanner/database/backup_info.rb +105 -0
  25. data/lib/google/cloud/spanner/database/job.rb +5 -2
  26. data/lib/google/cloud/spanner/database/job/list.rb +177 -0
  27. data/lib/google/cloud/spanner/database/list.rb +1 -1
  28. data/lib/google/cloud/spanner/database/restore_info.rb +63 -0
  29. data/lib/google/cloud/spanner/fields.rb +8 -8
  30. data/lib/google/cloud/spanner/instance.rb +401 -8
  31. data/lib/google/cloud/spanner/instance/config.rb +1 -1
  32. data/lib/google/cloud/spanner/instance/config/list.rb +1 -1
  33. data/lib/google/cloud/spanner/instance/job.rb +2 -2
  34. data/lib/google/cloud/spanner/instance/list.rb +1 -1
  35. data/lib/google/cloud/spanner/partition.rb +4 -4
  36. data/lib/google/cloud/spanner/policy.rb +2 -2
  37. data/lib/google/cloud/spanner/project.rb +31 -6
  38. data/lib/google/cloud/spanner/results.rb +4 -2
  39. data/lib/google/cloud/spanner/service.rb +231 -240
  40. data/lib/google/cloud/spanner/session.rb +46 -15
  41. data/lib/google/cloud/spanner/snapshot.rb +28 -5
  42. data/lib/google/cloud/spanner/transaction.rb +51 -7
  43. data/lib/google/cloud/spanner/version.rb +1 -1
  44. metadata +28 -104
  45. data/lib/google/cloud/spanner/admin/database.rb +0 -148
  46. data/lib/google/cloud/spanner/admin/database/v1.rb +0 -146
  47. data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +0 -46
  48. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +0 -791
  49. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +0 -71
  50. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  51. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/options.rb +0 -33
  52. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +0 -151
  53. data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +0 -51
  54. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +0 -131
  55. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +0 -29
  56. data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +0 -39
  57. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +0 -201
  58. data/lib/google/cloud/spanner/admin/database/v1/doc/google/type/expr.rb +0 -45
  59. data/lib/google/cloud/spanner/admin/instance.rb +0 -164
  60. data/lib/google/cloud/spanner/admin/instance/v1.rb +0 -162
  61. data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +0 -46
  62. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  63. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/options.rb +0 -33
  64. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +0 -151
  65. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +0 -51
  66. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +0 -131
  67. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +0 -29
  68. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +0 -222
  69. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +0 -39
  70. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +0 -341
  71. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/type/expr.rb +0 -45
  72. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +0 -972
  73. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +0 -76
  74. data/lib/google/cloud/spanner/v1.rb +0 -16
  75. data/lib/google/cloud/spanner/v1/credentials.rb +0 -42
  76. data/lib/google/cloud/spanner/v1/doc/google/protobuf/any.rb +0 -131
  77. data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +0 -91
  78. data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +0 -29
  79. data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +0 -74
  80. data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +0 -113
  81. data/lib/google/cloud/spanner/v1/doc/google/rpc/status.rb +0 -39
  82. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +0 -150
  83. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +0 -88
  84. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +0 -121
  85. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +0 -190
  86. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +0 -581
  87. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +0 -432
  88. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +0 -112
  89. data/lib/google/cloud/spanner/v1/spanner_client.rb +0 -1509
  90. data/lib/google/cloud/spanner/v1/spanner_client_config.json +0 -121
  91. data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +0 -88
  92. data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +0 -99
  93. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +0 -125
  94. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +0 -182
  95. data/lib/google/spanner/v1/keys_pb.rb +0 -34
  96. data/lib/google/spanner/v1/mutation_pb.rb +0 -39
  97. data/lib/google/spanner/v1/query_plan_pb.rb +0 -48
  98. data/lib/google/spanner/v1/result_set_pb.rb +0 -48
  99. data/lib/google/spanner/v1/spanner_pb.rb +0 -174
  100. data/lib/google/spanner/v1/spanner_services_pb.rb +0 -188
  101. data/lib/google/spanner/v1/transaction_pb.rb +0 -56
  102. data/lib/google/spanner/v1/type_pb.rb +0 -44
@@ -1,190 +0,0 @@
1
- # Copyright 2020 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
- # https://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
-
16
- module Google
17
- module Spanner
18
- module V1
19
- # Results from {Google::Spanner::V1::Spanner::Read Read} or
20
- # {Google::Spanner::V1::Spanner::ExecuteSql ExecuteSql}.
21
- # @!attribute [rw] metadata
22
- # @return [Google::Spanner::V1::ResultSetMetadata]
23
- # Metadata about the result set, such as row type information.
24
- # @!attribute [rw] rows
25
- # @return [Array<Google::Protobuf::ListValue>]
26
- # Each element in `rows` is a row whose format is defined by
27
- # {Google::Spanner::V1::ResultSetMetadata#row_type metadata::row_type}. The ith element
28
- # in each row matches the ith field in
29
- # {Google::Spanner::V1::ResultSetMetadata#row_type metadata::row_type}. Elements are
30
- # encoded based on type as described
31
- # {Google::Spanner::V1::TypeCode here}.
32
- # @!attribute [rw] stats
33
- # @return [Google::Spanner::V1::ResultSetStats]
34
- # Query plan and execution statistics for the SQL statement that
35
- # produced this result set. These can be requested by setting
36
- # {Google::Spanner::V1::ExecuteSqlRequest#query_mode ExecuteSqlRequest#query_mode}.
37
- # DML statements always produce stats containing the number of rows
38
- # modified, unless executed using the
39
- # {Google::Spanner::V1::ExecuteSqlRequest::QueryMode::PLAN ExecuteSqlRequest::QueryMode::PLAN} {Google::Spanner::V1::ExecuteSqlRequest#query_mode ExecuteSqlRequest#query_mode}.
40
- # Other fields may or may not be populated, based on the
41
- # {Google::Spanner::V1::ExecuteSqlRequest#query_mode ExecuteSqlRequest#query_mode}.
42
- class ResultSet; end
43
-
44
- # Partial results from a streaming read or SQL query. Streaming reads and
45
- # SQL queries better tolerate large result sets, large rows, and large
46
- # values, but are a little trickier to consume.
47
- # @!attribute [rw] metadata
48
- # @return [Google::Spanner::V1::ResultSetMetadata]
49
- # Metadata about the result set, such as row type information.
50
- # Only present in the first response.
51
- # @!attribute [rw] values
52
- # @return [Array<Google::Protobuf::Value>]
53
- # A streamed result set consists of a stream of values, which might
54
- # be split into many `PartialResultSet` messages to accommodate
55
- # large rows and/or large values. Every N complete values defines a
56
- # row, where N is equal to the number of entries in
57
- # {Google::Spanner::V1::StructType#fields metadata::row_type::fields}.
58
- #
59
- # Most values are encoded based on type as described
60
- # {Google::Spanner::V1::TypeCode here}.
61
- #
62
- # It is possible that the last value in values is "chunked",
63
- # meaning that the rest of the value is sent in subsequent
64
- # `PartialResultSet`(s). This is denoted by the {Google::Spanner::V1::PartialResultSet#chunked_value chunked_value}
65
- # field. Two or more chunked values can be merged to form a
66
- # complete value as follows:
67
- #
68
- # * `bool/number/null`: cannot be chunked
69
- # * `string`: concatenate the strings
70
- # * `list`: concatenate the lists. If the last element in a list is a
71
- # `string`, `list`, or `object`, merge it with the first element in
72
- # the next list by applying these rules recursively.
73
- # * `object`: concatenate the (field name, field value) pairs. If a
74
- # field name is duplicated, then apply these rules recursively
75
- # to merge the field values.
76
- #
77
- # Some examples of merging:
78
- #
79
- # = Strings are concatenated.
80
- # "foo", "bar" => "foobar"
81
- #
82
- # = Lists of non-strings are concatenated.
83
- # [2, 3], [4] => [2, 3, 4]
84
- #
85
- # = Lists are concatenated, but the last and first elements are merged
86
- # = because they are strings.
87
- # ["a", "b"], ["c", "d"] => ["a", "bc", "d"]
88
- #
89
- # = Lists are concatenated, but the last and first elements are merged
90
- # = because they are lists. Recursively, the last and first elements
91
- # = of the inner lists are merged because they are strings.
92
- # ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"]
93
- #
94
- # = Non-overlapping object fields are combined.
95
- # {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"}
96
- #
97
- # = Overlapping object fields are merged.
98
- # {"a": "1"}, {"a": "2"} => {"a": "12"}
99
- #
100
- # = Examples of merging objects containing lists of strings.
101
- # {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]}
102
- #
103
- # For a more complete example, suppose a streaming SQL query is
104
- # yielding a result set whose rows contain a single string
105
- # field. The following `PartialResultSet`s might be yielded:
106
- #
107
- # {
108
- # "metadata": { ... }
109
- # "values": ["Hello", "W"]
110
- # "chunked_value": true
111
- # "resume_token": "Af65..."
112
- # }
113
- # {
114
- # "values": ["orl"]
115
- # "chunked_value": true
116
- # "resume_token": "Bqp2..."
117
- # }
118
- # {
119
- # "values": ["d"]
120
- # "resume_token": "Zx1B..."
121
- # }
122
- #
123
- # This sequence of `PartialResultSet`s encodes two rows, one
124
- # containing the field value `"Hello"`, and a second containing the
125
- # field value `"World" = "W" + "orl" + "d"`.
126
- # @!attribute [rw] chunked_value
127
- # @return [true, false]
128
- # If true, then the final value in {Google::Spanner::V1::PartialResultSet#values values} is chunked, and must
129
- # be combined with more values from subsequent `PartialResultSet`s
130
- # to obtain a complete field value.
131
- # @!attribute [rw] resume_token
132
- # @return [String]
133
- # Streaming calls might be interrupted for a variety of reasons, such
134
- # as TCP connection loss. If this occurs, the stream of results can
135
- # be resumed by re-sending the original request and including
136
- # `resume_token`. Note that executing any other transaction in the
137
- # same session invalidates the token.
138
- # @!attribute [rw] stats
139
- # @return [Google::Spanner::V1::ResultSetStats]
140
- # Query plan and execution statistics for the statement that produced this
141
- # streaming result set. These can be requested by setting
142
- # {Google::Spanner::V1::ExecuteSqlRequest#query_mode ExecuteSqlRequest#query_mode} and are sent
143
- # only once with the last response in the stream.
144
- # This field will also be present in the last response for DML
145
- # statements.
146
- class PartialResultSet; end
147
-
148
- # Metadata about a {Google::Spanner::V1::ResultSet ResultSet} or {Google::Spanner::V1::PartialResultSet PartialResultSet}.
149
- # @!attribute [rw] row_type
150
- # @return [Google::Spanner::V1::StructType]
151
- # Indicates the field names and types for the rows in the result
152
- # set. For example, a SQL query like `"SELECT UserId, UserName FROM
153
- # Users"` could return a `row_type` value like:
154
- #
155
- # "fields": [
156
- # { "name": "UserId", "type": { "code": "INT64" } },
157
- # { "name": "UserName", "type": { "code": "STRING" } },
158
- # ]
159
- # @!attribute [rw] transaction
160
- # @return [Google::Spanner::V1::Transaction]
161
- # If the read or SQL query began a transaction as a side-effect, the
162
- # information about the new transaction is yielded here.
163
- class ResultSetMetadata; end
164
-
165
- # Additional statistics about a {Google::Spanner::V1::ResultSet ResultSet} or {Google::Spanner::V1::PartialResultSet PartialResultSet}.
166
- # @!attribute [rw] query_plan
167
- # @return [Google::Spanner::V1::QueryPlan]
168
- # {Google::Spanner::V1::QueryPlan QueryPlan} for the query associated with this result.
169
- # @!attribute [rw] query_stats
170
- # @return [Google::Protobuf::Struct]
171
- # Aggregated statistics from the execution of the query. Only present when
172
- # the query is profiled. For example, a query could return the statistics as
173
- # follows:
174
- #
175
- # {
176
- # "rows_returned": "3",
177
- # "elapsed_time": "1.22 secs",
178
- # "cpu_time": "1.19 secs"
179
- # }
180
- # @!attribute [rw] row_count_exact
181
- # @return [Integer]
182
- # Standard DML returns an exact count of rows that were modified.
183
- # @!attribute [rw] row_count_lower_bound
184
- # @return [Integer]
185
- # Partitioned DML does not offer exactly-once semantics, so it
186
- # returns a lower bound of the rows modified.
187
- class ResultSetStats; end
188
- end
189
- end
190
- end
@@ -1,581 +0,0 @@
1
- # Copyright 2020 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
- # https://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
-
16
- module Google
17
- module Spanner
18
- module V1
19
- # The request for {Google::Spanner::V1::Spanner::CreateSession CreateSession}.
20
- # @!attribute [rw] database
21
- # @return [String]
22
- # Required. The database in which the new session is created.
23
- # @!attribute [rw] session
24
- # @return [Google::Spanner::V1::Session]
25
- # The session to create.
26
- class CreateSessionRequest; end
27
-
28
- # The request for
29
- # {Google::Spanner::V1::Spanner::BatchCreateSessions BatchCreateSessions}.
30
- # @!attribute [rw] database
31
- # @return [String]
32
- # Required. The database in which the new sessions are created.
33
- # @!attribute [rw] session_template
34
- # @return [Google::Spanner::V1::Session]
35
- # Parameters to be applied to each created session.
36
- # @!attribute [rw] session_count
37
- # @return [Integer]
38
- # Required. The number of sessions to be created in this batch call.
39
- # The API may return fewer than the requested number of sessions. If a
40
- # specific number of sessions are desired, the client can make additional
41
- # calls to BatchCreateSessions (adjusting
42
- # {Google::Spanner::V1::BatchCreateSessionsRequest#session_count session_count}
43
- # as necessary).
44
- class BatchCreateSessionsRequest; end
45
-
46
- # The response for
47
- # {Google::Spanner::V1::Spanner::BatchCreateSessions BatchCreateSessions}.
48
- # @!attribute [rw] session
49
- # @return [Array<Google::Spanner::V1::Session>]
50
- # The freshly created sessions.
51
- class BatchCreateSessionsResponse; end
52
-
53
- # A session in the Cloud Spanner API.
54
- # @!attribute [rw] name
55
- # @return [String]
56
- # The name of the session. This is always system-assigned; values provided
57
- # when creating a session are ignored.
58
- # @!attribute [rw] labels
59
- # @return [Hash{String => String}]
60
- # The labels for the session.
61
- #
62
- # * Label keys must be between 1 and 63 characters long and must conform to
63
- # the following regular expression: `[a-z](https://cloud.google.com[-a-z0-9]*[a-z0-9])?`.
64
- # * Label values must be between 0 and 63 characters long and must conform
65
- # to the regular expression `([a-z](https://cloud.google.com[-a-z0-9]*[a-z0-9])?)?`.
66
- # * No more than 64 labels can be associated with a given session.
67
- #
68
- # See https://goo.gl/xmQnxf for more information on and examples of labels.
69
- # @!attribute [rw] create_time
70
- # @return [Google::Protobuf::Timestamp]
71
- # Output only. The timestamp when the session is created.
72
- # @!attribute [rw] approximate_last_use_time
73
- # @return [Google::Protobuf::Timestamp]
74
- # Output only. The approximate timestamp when the session is last used. It is
75
- # typically earlier than the actual last use time.
76
- class Session; end
77
-
78
- # The request for {Google::Spanner::V1::Spanner::GetSession GetSession}.
79
- # @!attribute [rw] name
80
- # @return [String]
81
- # Required. The name of the session to retrieve.
82
- class GetSessionRequest; end
83
-
84
- # The request for {Google::Spanner::V1::Spanner::ListSessions ListSessions}.
85
- # @!attribute [rw] database
86
- # @return [String]
87
- # Required. The database in which to list sessions.
88
- # @!attribute [rw] page_size
89
- # @return [Integer]
90
- # Number of sessions to be returned in the response. If 0 or less, defaults
91
- # to the server's maximum allowed page size.
92
- # @!attribute [rw] page_token
93
- # @return [String]
94
- # If non-empty, `page_token` should contain a
95
- # {Google::Spanner::V1::ListSessionsResponse#next_page_token next_page_token}
96
- # from a previous
97
- # {Google::Spanner::V1::ListSessionsResponse ListSessionsResponse}.
98
- # @!attribute [rw] filter
99
- # @return [String]
100
- # An expression for filtering the results of the request. Filter rules are
101
- # case insensitive. The fields eligible for filtering are:
102
- #
103
- # * `labels.key` where key is the name of a label
104
- #
105
- # Some examples of using filters are:
106
- #
107
- # * `labels.env:*` --> The session has the label "env".
108
- # * `labels.env:dev` --> The session has the label "env" and the value of
109
- # the label contains the string "dev".
110
- class ListSessionsRequest; end
111
-
112
- # The response for {Google::Spanner::V1::Spanner::ListSessions ListSessions}.
113
- # @!attribute [rw] sessions
114
- # @return [Array<Google::Spanner::V1::Session>]
115
- # The list of requested sessions.
116
- # @!attribute [rw] next_page_token
117
- # @return [String]
118
- # `next_page_token` can be sent in a subsequent
119
- # {Google::Spanner::V1::Spanner::ListSessions ListSessions} call to fetch more
120
- # of the matching sessions.
121
- class ListSessionsResponse; end
122
-
123
- # The request for {Google::Spanner::V1::Spanner::DeleteSession DeleteSession}.
124
- # @!attribute [rw] name
125
- # @return [String]
126
- # Required. The name of the session to delete.
127
- class DeleteSessionRequest; end
128
-
129
- # The request for {Google::Spanner::V1::Spanner::ExecuteSql ExecuteSql} and
130
- # {Google::Spanner::V1::Spanner::ExecuteStreamingSql ExecuteStreamingSql}.
131
- # @!attribute [rw] session
132
- # @return [String]
133
- # Required. The session in which the SQL query should be performed.
134
- # @!attribute [rw] transaction
135
- # @return [Google::Spanner::V1::TransactionSelector]
136
- # The transaction to use.
137
- #
138
- # For queries, if none is provided, the default is a temporary read-only
139
- # transaction with strong concurrency.
140
- #
141
- # Standard DML statements require a read-write transaction. To protect
142
- # against replays, single-use transactions are not supported. The caller
143
- # must either supply an existing transaction ID or begin a new transaction.
144
- #
145
- # Partitioned DML requires an existing Partitioned DML transaction ID.
146
- # @!attribute [rw] sql
147
- # @return [String]
148
- # Required. The SQL string.
149
- # @!attribute [rw] params
150
- # @return [Google::Protobuf::Struct]
151
- # Parameter names and values that bind to placeholders in the SQL string.
152
- #
153
- # A parameter placeholder consists of the `@` character followed by the
154
- # parameter name (for example, `@firstName`). Parameter names can contain
155
- # letters, numbers, and underscores.
156
- #
157
- # Parameters can appear anywhere that a literal value is expected. The same
158
- # parameter name can be used more than once, for example:
159
- #
160
- # `"WHERE id > @msg_id AND id < @msg_id + 100"`
161
- #
162
- # It is an error to execute a SQL statement with unbound parameters.
163
- # @!attribute [rw] param_types
164
- # @return [Hash{String => Google::Spanner::V1::Type}]
165
- # It is not always possible for Cloud Spanner to infer the right SQL type
166
- # from a JSON value. For example, values of type `BYTES` and values
167
- # of type `STRING` both appear in
168
- # {Google::Spanner::V1::ExecuteSqlRequest#params params} as JSON strings.
169
- #
170
- # In these cases, `param_types` can be used to specify the exact
171
- # SQL type for some or all of the SQL statement parameters. See the
172
- # definition of {Google::Spanner::V1::Type Type} for more information
173
- # about SQL types.
174
- # @!attribute [rw] resume_token
175
- # @return [String]
176
- # If this request is resuming a previously interrupted SQL statement
177
- # execution, `resume_token` should be copied from the last
178
- # {Google::Spanner::V1::PartialResultSet PartialResultSet} yielded before the
179
- # interruption. Doing this enables the new SQL statement execution to resume
180
- # where the last one left off. The rest of the request parameters must
181
- # exactly match the request that yielded this token.
182
- # @!attribute [rw] query_mode
183
- # @return [Google::Spanner::V1::ExecuteSqlRequest::QueryMode]
184
- # Used to control the amount of debugging information returned in
185
- # {Google::Spanner::V1::ResultSetStats ResultSetStats}. If
186
- # {Google::Spanner::V1::ExecuteSqlRequest#partition_token partition_token} is
187
- # set, {Google::Spanner::V1::ExecuteSqlRequest#query_mode query_mode} can only
188
- # be set to
189
- # {Google::Spanner::V1::ExecuteSqlRequest::QueryMode::NORMAL QueryMode::NORMAL}.
190
- # @!attribute [rw] partition_token
191
- # @return [String]
192
- # If present, results will be restricted to the specified partition
193
- # previously created using PartitionQuery(). There must be an exact
194
- # match for the values of fields common to this message and the
195
- # PartitionQueryRequest message used to create this partition_token.
196
- # @!attribute [rw] seqno
197
- # @return [Integer]
198
- # A per-transaction sequence number used to identify this request. This field
199
- # makes each request idempotent such that if the request is received multiple
200
- # times, at most one will succeed.
201
- #
202
- # The sequence number must be monotonically increasing within the
203
- # transaction. If a request arrives for the first time with an out-of-order
204
- # sequence number, the transaction may be aborted. Replays of previously
205
- # handled requests will yield the same response as the first execution.
206
- #
207
- # Required for DML statements. Ignored for queries.
208
- class ExecuteSqlRequest
209
- # Mode in which the statement must be processed.
210
- module QueryMode
211
- # The default mode. Only the statement results are returned.
212
- NORMAL = 0
213
-
214
- # This mode returns only the query plan, without any results or
215
- # execution statistics information.
216
- PLAN = 1
217
-
218
- # This mode returns both the query plan and the execution statistics along
219
- # with the results.
220
- PROFILE = 2
221
- end
222
- end
223
-
224
- # The request for {Google::Spanner::V1::Spanner::ExecuteBatchDml ExecuteBatchDml}.
225
- # @!attribute [rw] session
226
- # @return [String]
227
- # Required. The session in which the DML statements should be performed.
228
- # @!attribute [rw] transaction
229
- # @return [Google::Spanner::V1::TransactionSelector]
230
- # Required. The transaction to use. Must be a read-write transaction.
231
- #
232
- # To protect against replays, single-use transactions are not supported. The
233
- # caller must either supply an existing transaction ID or begin a new
234
- # transaction.
235
- # @!attribute [rw] statements
236
- # @return [Array<Google::Spanner::V1::ExecuteBatchDmlRequest::Statement>]
237
- # Required. The list of statements to execute in this batch. Statements are
238
- # executed serially, such that the effects of statement `i` are visible to
239
- # statement `i+1`. Each statement must be a DML statement. Execution stops at
240
- # the first failed statement; the remaining statements are not executed.
241
- #
242
- # Callers must provide at least one statement.
243
- # @!attribute [rw] seqno
244
- # @return [Integer]
245
- # Required. A per-transaction sequence number used to identify this request.
246
- # This field makes each request idempotent such that if the request is
247
- # received multiple times, at most one will succeed.
248
- #
249
- # The sequence number must be monotonically increasing within the
250
- # transaction. If a request arrives for the first time with an out-of-order
251
- # sequence number, the transaction may be aborted. Replays of previously
252
- # handled requests will yield the same response as the first execution.
253
- class ExecuteBatchDmlRequest
254
- # A single DML statement.
255
- # @!attribute [rw] sql
256
- # @return [String]
257
- # Required. The DML string.
258
- # @!attribute [rw] params
259
- # @return [Google::Protobuf::Struct]
260
- # Parameter names and values that bind to placeholders in the DML string.
261
- #
262
- # A parameter placeholder consists of the `@` character followed by the
263
- # parameter name (for example, `@firstName`). Parameter names can contain
264
- # letters, numbers, and underscores.
265
- #
266
- # Parameters can appear anywhere that a literal value is expected. The
267
- # same parameter name can be used more than once, for example:
268
- #
269
- # `"WHERE id > @msg_id AND id < @msg_id + 100"`
270
- #
271
- # It is an error to execute a SQL statement with unbound parameters.
272
- # @!attribute [rw] param_types
273
- # @return [Hash{String => Google::Spanner::V1::Type}]
274
- # It is not always possible for Cloud Spanner to infer the right SQL type
275
- # from a JSON value. For example, values of type `BYTES` and values
276
- # of type `STRING` both appear in
277
- # {Google::Spanner::V1::ExecuteBatchDmlRequest::Statement#params params} as
278
- # JSON strings.
279
- #
280
- # In these cases, `param_types` can be used to specify the exact
281
- # SQL type for some or all of the SQL statement parameters. See the
282
- # definition of {Google::Spanner::V1::Type Type} for more information
283
- # about SQL types.
284
- class Statement; end
285
- end
286
-
287
- # The response for
288
- # {Google::Spanner::V1::Spanner::ExecuteBatchDml ExecuteBatchDml}. Contains a list
289
- # of {Google::Spanner::V1::ResultSet ResultSet} messages, one for each DML
290
- # statement that has successfully executed, in the same order as the statements
291
- # in the request. If a statement fails, the status in the response body
292
- # identifies the cause of the failure.
293
- #
294
- # To check for DML statements that failed, use the following approach:
295
- #
296
- # 1. Check the status in the response message. The
297
- # {Google::Rpc::Code} enum
298
- # value `OK` indicates that all statements were executed successfully.
299
- # 2. If the status was not `OK`, check the number of result sets in the
300
- # response. If the response contains `N`
301
- # {Google::Spanner::V1::ResultSet ResultSet} messages, then statement `N+1` in
302
- # the request failed.
303
- #
304
- # Example 1:
305
- #
306
- # * Request: 5 DML statements, all executed successfully.
307
- # * Response: 5 {Google::Spanner::V1::ResultSet ResultSet} messages, with the
308
- # status `OK`.
309
- #
310
- # Example 2:
311
- #
312
- # * Request: 5 DML statements. The third statement has a syntax error.
313
- # * Response: 2 {Google::Spanner::V1::ResultSet ResultSet} messages, and a syntax
314
- # error (`INVALID_ARGUMENT`)
315
- # status. The number of {Google::Spanner::V1::ResultSet ResultSet} messages
316
- # indicates that the third statement failed, and the fourth and fifth
317
- # statements were not executed.
318
- # @!attribute [rw] result_sets
319
- # @return [Array<Google::Spanner::V1::ResultSet>]
320
- # One {Google::Spanner::V1::ResultSet ResultSet} for each statement in the
321
- # request that ran successfully, in the same order as the statements in the
322
- # request. Each {Google::Spanner::V1::ResultSet ResultSet} does not contain any
323
- # rows. The {Google::Spanner::V1::ResultSetStats ResultSetStats} in each
324
- # {Google::Spanner::V1::ResultSet ResultSet} contain the number of rows
325
- # modified by the statement.
326
- #
327
- # Only the first {Google::Spanner::V1::ResultSet ResultSet} in the response
328
- # contains valid {Google::Spanner::V1::ResultSetMetadata ResultSetMetadata}.
329
- # @!attribute [rw] status
330
- # @return [Google::Rpc::Status]
331
- # If all DML statements are executed successfully, the status is `OK`.
332
- # Otherwise, the error status of the first failed statement.
333
- class ExecuteBatchDmlResponse; end
334
-
335
- # Options for a PartitionQueryRequest and
336
- # PartitionReadRequest.
337
- # @!attribute [rw] partition_size_bytes
338
- # @return [Integer]
339
- # **Note:** This hint is currently ignored by PartitionQuery and
340
- # PartitionRead requests.
341
- #
342
- # The desired data size for each partition generated. The default for this
343
- # option is currently 1 GiB. This is only a hint. The actual size of each
344
- # partition may be smaller or larger than this size request.
345
- # @!attribute [rw] max_partitions
346
- # @return [Integer]
347
- # **Note:** This hint is currently ignored by PartitionQuery and
348
- # PartitionRead requests.
349
- #
350
- # The desired maximum number of partitions to return. For example, this may
351
- # be set to the number of workers available. The default for this option
352
- # is currently 10,000. The maximum value is currently 200,000. This is only
353
- # a hint. The actual number of partitions returned may be smaller or larger
354
- # than this maximum count request.
355
- class PartitionOptions; end
356
-
357
- # The request for {Google::Spanner::V1::Spanner::PartitionQuery PartitionQuery}
358
- # @!attribute [rw] session
359
- # @return [String]
360
- # Required. The session used to create the partitions.
361
- # @!attribute [rw] transaction
362
- # @return [Google::Spanner::V1::TransactionSelector]
363
- # Read only snapshot transactions are supported, read/write and single use
364
- # transactions are not.
365
- # @!attribute [rw] sql
366
- # @return [String]
367
- # Required. The query request to generate partitions for. The request will
368
- # fail if the query is not root partitionable. The query plan of a root
369
- # partitionable query has a single distributed union operator. A distributed
370
- # union operator conceptually divides one or more tables into multiple
371
- # splits, remotely evaluates a subquery independently on each split, and
372
- # then unions all results.
373
- #
374
- # This must not contain DML commands, such as INSERT, UPDATE, or
375
- # DELETE. Use
376
- # {Google::Spanner::V1::Spanner::ExecuteStreamingSql ExecuteStreamingSql} with a
377
- # PartitionedDml transaction for large, partition-friendly DML operations.
378
- # @!attribute [rw] params
379
- # @return [Google::Protobuf::Struct]
380
- # Parameter names and values that bind to placeholders in the SQL string.
381
- #
382
- # A parameter placeholder consists of the `@` character followed by the
383
- # parameter name (for example, `@firstName`). Parameter names can contain
384
- # letters, numbers, and underscores.
385
- #
386
- # Parameters can appear anywhere that a literal value is expected. The same
387
- # parameter name can be used more than once, for example:
388
- #
389
- # `"WHERE id > @msg_id AND id < @msg_id + 100"`
390
- #
391
- # It is an error to execute a SQL statement with unbound parameters.
392
- # @!attribute [rw] param_types
393
- # @return [Hash{String => Google::Spanner::V1::Type}]
394
- # It is not always possible for Cloud Spanner to infer the right SQL type
395
- # from a JSON value. For example, values of type `BYTES` and values
396
- # of type `STRING` both appear in
397
- # {Google::Spanner::V1::PartitionQueryRequest#params params} as JSON strings.
398
- #
399
- # In these cases, `param_types` can be used to specify the exact
400
- # SQL type for some or all of the SQL query parameters. See the
401
- # definition of {Google::Spanner::V1::Type Type} for more information
402
- # about SQL types.
403
- # @!attribute [rw] partition_options
404
- # @return [Google::Spanner::V1::PartitionOptions]
405
- # Additional options that affect how many partitions are created.
406
- class PartitionQueryRequest; end
407
-
408
- # The request for {Google::Spanner::V1::Spanner::PartitionRead PartitionRead}
409
- # @!attribute [rw] session
410
- # @return [String]
411
- # Required. The session used to create the partitions.
412
- # @!attribute [rw] transaction
413
- # @return [Google::Spanner::V1::TransactionSelector]
414
- # Read only snapshot transactions are supported, read/write and single use
415
- # transactions are not.
416
- # @!attribute [rw] table
417
- # @return [String]
418
- # Required. The name of the table in the database to be read.
419
- # @!attribute [rw] index
420
- # @return [String]
421
- # If non-empty, the name of an index on
422
- # {Google::Spanner::V1::PartitionReadRequest#table table}. This index is used
423
- # instead of the table primary key when interpreting
424
- # {Google::Spanner::V1::PartitionReadRequest#key_set key_set} and sorting
425
- # result rows. See {Google::Spanner::V1::PartitionReadRequest#key_set key_set}
426
- # for further information.
427
- # @!attribute [rw] columns
428
- # @return [Array<String>]
429
- # The columns of {Google::Spanner::V1::PartitionReadRequest#table table} to be
430
- # returned for each row matching this request.
431
- # @!attribute [rw] key_set
432
- # @return [Google::Spanner::V1::KeySet]
433
- # Required. `key_set` identifies the rows to be yielded. `key_set` names the
434
- # primary keys of the rows in
435
- # {Google::Spanner::V1::PartitionReadRequest#table table} to be yielded, unless
436
- # {Google::Spanner::V1::PartitionReadRequest#index index} is present. If
437
- # {Google::Spanner::V1::PartitionReadRequest#index index} is present, then
438
- # {Google::Spanner::V1::PartitionReadRequest#key_set key_set} instead names
439
- # index keys in {Google::Spanner::V1::PartitionReadRequest#index index}.
440
- #
441
- # It is not an error for the `key_set` to name rows that do not
442
- # exist in the database. Read yields nothing for nonexistent rows.
443
- # @!attribute [rw] partition_options
444
- # @return [Google::Spanner::V1::PartitionOptions]
445
- # Additional options that affect how many partitions are created.
446
- class PartitionReadRequest; end
447
-
448
- # Information returned for each partition returned in a
449
- # PartitionResponse.
450
- # @!attribute [rw] partition_token
451
- # @return [String]
452
- # This token can be passed to Read, StreamingRead, ExecuteSql, or
453
- # ExecuteStreamingSql requests to restrict the results to those identified by
454
- # this partition token.
455
- class Partition; end
456
-
457
- # The response for {Google::Spanner::V1::Spanner::PartitionQuery PartitionQuery}
458
- # or {Google::Spanner::V1::Spanner::PartitionRead PartitionRead}
459
- # @!attribute [rw] partitions
460
- # @return [Array<Google::Spanner::V1::Partition>]
461
- # Partitions created by this request.
462
- # @!attribute [rw] transaction
463
- # @return [Google::Spanner::V1::Transaction]
464
- # Transaction created by this request.
465
- class PartitionResponse; end
466
-
467
- # The request for {Google::Spanner::V1::Spanner::Read Read} and
468
- # {Google::Spanner::V1::Spanner::StreamingRead StreamingRead}.
469
- # @!attribute [rw] session
470
- # @return [String]
471
- # Required. The session in which the read should be performed.
472
- # @!attribute [rw] transaction
473
- # @return [Google::Spanner::V1::TransactionSelector]
474
- # The transaction to use. If none is provided, the default is a
475
- # temporary read-only transaction with strong concurrency.
476
- # @!attribute [rw] table
477
- # @return [String]
478
- # Required. The name of the table in the database to be read.
479
- # @!attribute [rw] index
480
- # @return [String]
481
- # If non-empty, the name of an index on
482
- # {Google::Spanner::V1::ReadRequest#table table}. This index is used instead of
483
- # the table primary key when interpreting
484
- # {Google::Spanner::V1::ReadRequest#key_set key_set} and sorting result rows.
485
- # See {Google::Spanner::V1::ReadRequest#key_set key_set} for further
486
- # information.
487
- # @!attribute [rw] columns
488
- # @return [Array<String>]
489
- # Required. The columns of {Google::Spanner::V1::ReadRequest#table table} to be
490
- # returned for each row matching this request.
491
- # @!attribute [rw] key_set
492
- # @return [Google::Spanner::V1::KeySet]
493
- # Required. `key_set` identifies the rows to be yielded. `key_set` names the
494
- # primary keys of the rows in {Google::Spanner::V1::ReadRequest#table table} to
495
- # be yielded, unless {Google::Spanner::V1::ReadRequest#index index} is present.
496
- # If {Google::Spanner::V1::ReadRequest#index index} is present, then
497
- # {Google::Spanner::V1::ReadRequest#key_set key_set} instead names index keys
498
- # in {Google::Spanner::V1::ReadRequest#index index}.
499
- #
500
- # If the {Google::Spanner::V1::ReadRequest#partition_token partition_token}
501
- # field is empty, rows are yielded in table primary key order (if
502
- # {Google::Spanner::V1::ReadRequest#index index} is empty) or index key order
503
- # (if {Google::Spanner::V1::ReadRequest#index index} is non-empty). If the
504
- # {Google::Spanner::V1::ReadRequest#partition_token partition_token} field is
505
- # not empty, rows will be yielded in an unspecified order.
506
- #
507
- # It is not an error for the `key_set` to name rows that do not
508
- # exist in the database. Read yields nothing for nonexistent rows.
509
- # @!attribute [rw] limit
510
- # @return [Integer]
511
- # If greater than zero, only the first `limit` rows are yielded. If `limit`
512
- # is zero, the default is no limit. A limit cannot be specified if
513
- # `partition_token` is set.
514
- # @!attribute [rw] resume_token
515
- # @return [String]
516
- # If this request is resuming a previously interrupted read,
517
- # `resume_token` should be copied from the last
518
- # {Google::Spanner::V1::PartialResultSet PartialResultSet} yielded before the
519
- # interruption. Doing this enables the new read to resume where the last read
520
- # left off. The rest of the request parameters must exactly match the request
521
- # that yielded this token.
522
- # @!attribute [rw] partition_token
523
- # @return [String]
524
- # If present, results will be restricted to the specified partition
525
- # previously created using PartitionRead(). There must be an exact
526
- # match for the values of fields common to this message and the
527
- # PartitionReadRequest message used to create this partition_token.
528
- class ReadRequest; end
529
-
530
- # The request for
531
- # {Google::Spanner::V1::Spanner::BeginTransaction BeginTransaction}.
532
- # @!attribute [rw] session
533
- # @return [String]
534
- # Required. The session in which the transaction runs.
535
- # @!attribute [rw] options
536
- # @return [Google::Spanner::V1::TransactionOptions]
537
- # Required. Options for the new transaction.
538
- class BeginTransactionRequest; end
539
-
540
- # The request for {Google::Spanner::V1::Spanner::Commit Commit}.
541
- # @!attribute [rw] session
542
- # @return [String]
543
- # Required. The session in which the transaction to be committed is running.
544
- # @!attribute [rw] transaction_id
545
- # @return [String]
546
- # Commit a previously-started transaction.
547
- # @!attribute [rw] single_use_transaction
548
- # @return [Google::Spanner::V1::TransactionOptions]
549
- # Execute mutations in a temporary transaction. Note that unlike
550
- # commit of a previously-started transaction, commit with a
551
- # temporary transaction is non-idempotent. That is, if the
552
- # `CommitRequest` is sent to Cloud Spanner more than once (for
553
- # instance, due to retries in the application, or in the
554
- # transport library), it is possible that the mutations are
555
- # executed more than once. If this is undesirable, use
556
- # {Google::Spanner::V1::Spanner::BeginTransaction BeginTransaction} and
557
- # {Google::Spanner::V1::Spanner::Commit Commit} instead.
558
- # @!attribute [rw] mutations
559
- # @return [Array<Google::Spanner::V1::Mutation>]
560
- # The mutations to be executed when this transaction commits. All
561
- # mutations are applied atomically, in the order they appear in
562
- # this list.
563
- class CommitRequest; end
564
-
565
- # The response for {Google::Spanner::V1::Spanner::Commit Commit}.
566
- # @!attribute [rw] commit_timestamp
567
- # @return [Google::Protobuf::Timestamp]
568
- # The Cloud Spanner timestamp at which the transaction committed.
569
- class CommitResponse; end
570
-
571
- # The request for {Google::Spanner::V1::Spanner::Rollback Rollback}.
572
- # @!attribute [rw] session
573
- # @return [String]
574
- # Required. The session in which the transaction to roll back is running.
575
- # @!attribute [rw] transaction_id
576
- # @return [String]
577
- # Required. The transaction to roll back.
578
- class RollbackRequest; end
579
- end
580
- end
581
- end