google-cloud-spanner-v1 1.19.1 → 1.19.2
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/google/cloud/spanner/v1/rest.rb +37 -0
- data/lib/google/cloud/spanner/v1/spanner/client.rb +1 -1
- data/lib/google/cloud/spanner/v1/spanner/credentials.rb +1 -1
- data/lib/google/cloud/spanner/v1/spanner/paths.rb +1 -1
- data/lib/google/cloud/spanner/v1/spanner/rest/client.rb +2593 -0
- data/lib/google/cloud/spanner/v1/spanner/rest/service_stub.rb +1108 -0
- data/lib/google/cloud/spanner/v1/spanner/rest.rb +55 -0
- data/lib/google/cloud/spanner/v1/spanner.rb +7 -1
- data/lib/google/cloud/spanner/v1/version.rb +1 -1
- data/lib/google/cloud/spanner/v1.rb +6 -1
- data/lib/google/spanner/v1/spanner_services_pb.rb +1 -1
- data/lib/google-cloud-spanner-v1.rb +1 -1
- data/proto_docs/google/api/client.rb +1 -1
- data/proto_docs/google/api/field_behavior.rb +1 -1
- data/proto_docs/google/api/launch_stage.rb +1 -1
- data/proto_docs/google/api/resource.rb +1 -1
- data/proto_docs/google/protobuf/any.rb +1 -1
- data/proto_docs/google/protobuf/duration.rb +1 -1
- data/proto_docs/google/protobuf/empty.rb +1 -1
- data/proto_docs/google/protobuf/struct.rb +1 -1
- data/proto_docs/google/protobuf/timestamp.rb +8 -7
- data/proto_docs/google/rpc/status.rb +1 -1
- data/proto_docs/google/spanner/v1/change_stream.rb +1 -1
- data/proto_docs/google/spanner/v1/commit_response.rb +1 -1
- data/proto_docs/google/spanner/v1/keys.rb +1 -1
- data/proto_docs/google/spanner/v1/location.rb +1 -1
- data/proto_docs/google/spanner/v1/mutation.rb +1 -1
- data/proto_docs/google/spanner/v1/query_plan.rb +1 -1
- data/proto_docs/google/spanner/v1/result_set.rb +1 -1
- data/proto_docs/google/spanner/v1/spanner.rb +1 -1
- data/proto_docs/google/spanner/v1/transaction.rb +1 -1
- data/proto_docs/google/spanner/v1/type.rb +1 -1
- metadata +5 -1
|
@@ -0,0 +1,2593 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2026 Google LLC
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
|
18
|
+
|
|
19
|
+
require "google/cloud/errors"
|
|
20
|
+
require "google/spanner/v1/spanner_pb"
|
|
21
|
+
require "google/cloud/spanner/v1/spanner/rest/service_stub"
|
|
22
|
+
|
|
23
|
+
module Google
|
|
24
|
+
module Cloud
|
|
25
|
+
module Spanner
|
|
26
|
+
module V1
|
|
27
|
+
module Spanner
|
|
28
|
+
module Rest
|
|
29
|
+
##
|
|
30
|
+
# REST client for the Spanner service.
|
|
31
|
+
#
|
|
32
|
+
# Cloud Spanner API
|
|
33
|
+
#
|
|
34
|
+
# The Cloud Spanner API can be used to manage sessions and execute
|
|
35
|
+
# transactions on data stored in Cloud Spanner databases.
|
|
36
|
+
#
|
|
37
|
+
class Client
|
|
38
|
+
# @private
|
|
39
|
+
API_VERSION = ""
|
|
40
|
+
|
|
41
|
+
# @private
|
|
42
|
+
DEFAULT_ENDPOINT_TEMPLATE = "spanner.$UNIVERSE_DOMAIN$"
|
|
43
|
+
|
|
44
|
+
include Paths
|
|
45
|
+
|
|
46
|
+
# @private
|
|
47
|
+
attr_reader :spanner_stub
|
|
48
|
+
|
|
49
|
+
##
|
|
50
|
+
# Configure the Spanner Client class.
|
|
51
|
+
#
|
|
52
|
+
# See {::Google::Cloud::Spanner::V1::Spanner::Rest::Client::Configuration}
|
|
53
|
+
# for a description of the configuration fields.
|
|
54
|
+
#
|
|
55
|
+
# @example
|
|
56
|
+
#
|
|
57
|
+
# # Modify the configuration for all Spanner clients
|
|
58
|
+
# ::Google::Cloud::Spanner::V1::Spanner::Rest::Client.configure do |config|
|
|
59
|
+
# config.timeout = 10.0
|
|
60
|
+
# end
|
|
61
|
+
#
|
|
62
|
+
# @yield [config] Configure the Client client.
|
|
63
|
+
# @yieldparam config [Client::Configuration]
|
|
64
|
+
#
|
|
65
|
+
# @return [Client::Configuration]
|
|
66
|
+
#
|
|
67
|
+
def self.configure
|
|
68
|
+
@configure ||= begin
|
|
69
|
+
namespace = ["Google", "Cloud", "Spanner", "V1"]
|
|
70
|
+
parent_config = while namespace.any?
|
|
71
|
+
parent_name = namespace.join "::"
|
|
72
|
+
parent_const = const_get parent_name
|
|
73
|
+
break parent_const.configure if parent_const.respond_to? :configure
|
|
74
|
+
namespace.pop
|
|
75
|
+
end
|
|
76
|
+
default_config = Client::Configuration.new parent_config
|
|
77
|
+
|
|
78
|
+
default_config.rpcs.create_session.timeout = 30.0
|
|
79
|
+
default_config.rpcs.create_session.retry_policy = {
|
|
80
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
default_config.rpcs.batch_create_sessions.timeout = 60.0
|
|
84
|
+
default_config.rpcs.batch_create_sessions.retry_policy = {
|
|
85
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
default_config.rpcs.get_session.timeout = 30.0
|
|
89
|
+
default_config.rpcs.get_session.retry_policy = {
|
|
90
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
default_config.rpcs.list_sessions.timeout = 3600.0
|
|
94
|
+
default_config.rpcs.list_sessions.retry_policy = {
|
|
95
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
default_config.rpcs.delete_session.timeout = 30.0
|
|
99
|
+
default_config.rpcs.delete_session.retry_policy = {
|
|
100
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
default_config.rpcs.execute_sql.timeout = 30.0
|
|
104
|
+
default_config.rpcs.execute_sql.retry_policy = {
|
|
105
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
default_config.rpcs.execute_streaming_sql.timeout = 3600.0
|
|
109
|
+
|
|
110
|
+
default_config.rpcs.execute_batch_dml.timeout = 30.0
|
|
111
|
+
default_config.rpcs.execute_batch_dml.retry_policy = {
|
|
112
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
default_config.rpcs.read.timeout = 30.0
|
|
116
|
+
default_config.rpcs.read.retry_policy = {
|
|
117
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
default_config.rpcs.streaming_read.timeout = 3600.0
|
|
121
|
+
|
|
122
|
+
default_config.rpcs.begin_transaction.timeout = 30.0
|
|
123
|
+
default_config.rpcs.begin_transaction.retry_policy = {
|
|
124
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
default_config.rpcs.commit.timeout = 3600.0
|
|
128
|
+
default_config.rpcs.commit.retry_policy = {
|
|
129
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
default_config.rpcs.rollback.timeout = 30.0
|
|
133
|
+
default_config.rpcs.rollback.retry_policy = {
|
|
134
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
default_config.rpcs.partition_query.timeout = 30.0
|
|
138
|
+
default_config.rpcs.partition_query.retry_policy = {
|
|
139
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
default_config.rpcs.partition_read.timeout = 30.0
|
|
143
|
+
default_config.rpcs.partition_read.retry_policy = {
|
|
144
|
+
initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8]
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
default_config.rpcs.batch_write.timeout = 3600.0
|
|
148
|
+
|
|
149
|
+
default_config
|
|
150
|
+
end
|
|
151
|
+
yield @configure if block_given?
|
|
152
|
+
@configure
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
##
|
|
156
|
+
# Configure the Spanner Client instance.
|
|
157
|
+
#
|
|
158
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
|
159
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
|
160
|
+
# should be made on {Client.configure}.
|
|
161
|
+
#
|
|
162
|
+
# See {::Google::Cloud::Spanner::V1::Spanner::Rest::Client::Configuration}
|
|
163
|
+
# for a description of the configuration fields.
|
|
164
|
+
#
|
|
165
|
+
# @yield [config] Configure the Client client.
|
|
166
|
+
# @yieldparam config [Client::Configuration]
|
|
167
|
+
#
|
|
168
|
+
# @return [Client::Configuration]
|
|
169
|
+
#
|
|
170
|
+
def configure
|
|
171
|
+
yield @config if block_given?
|
|
172
|
+
@config
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
##
|
|
176
|
+
# The effective universe domain
|
|
177
|
+
#
|
|
178
|
+
# @return [String]
|
|
179
|
+
#
|
|
180
|
+
def universe_domain
|
|
181
|
+
@spanner_stub.universe_domain
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
##
|
|
185
|
+
# Create a new Spanner REST client object.
|
|
186
|
+
#
|
|
187
|
+
# @example
|
|
188
|
+
#
|
|
189
|
+
# # Create a client using the default configuration
|
|
190
|
+
# client = ::Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
191
|
+
#
|
|
192
|
+
# # Create a client using a custom configuration
|
|
193
|
+
# client = ::Google::Cloud::Spanner::V1::Spanner::Rest::Client.new do |config|
|
|
194
|
+
# config.timeout = 10.0
|
|
195
|
+
# end
|
|
196
|
+
#
|
|
197
|
+
# @yield [config] Configure the Spanner client.
|
|
198
|
+
# @yieldparam config [Client::Configuration]
|
|
199
|
+
#
|
|
200
|
+
def initialize
|
|
201
|
+
# Create the configuration object
|
|
202
|
+
@config = Configuration.new Client.configure
|
|
203
|
+
|
|
204
|
+
# Yield the configuration if needed
|
|
205
|
+
yield @config if block_given?
|
|
206
|
+
|
|
207
|
+
# Create credentials
|
|
208
|
+
credentials = @config.credentials
|
|
209
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
|
210
|
+
# but only if the default endpoint does not have a region prefix.
|
|
211
|
+
enable_self_signed_jwt = @config.endpoint.nil? ||
|
|
212
|
+
(@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
|
|
213
|
+
!@config.endpoint.split(".").first.include?("-"))
|
|
214
|
+
credentials ||= Credentials.default scope: @config.scope,
|
|
215
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
|
216
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
|
217
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
@quota_project_id = @config.quota_project
|
|
221
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
|
222
|
+
|
|
223
|
+
@spanner_stub = ::Google::Cloud::Spanner::V1::Spanner::Rest::ServiceStub.new(
|
|
224
|
+
endpoint: @config.endpoint,
|
|
225
|
+
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
|
|
226
|
+
universe_domain: @config.universe_domain,
|
|
227
|
+
credentials: credentials,
|
|
228
|
+
logger: @config.logger
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
@spanner_stub.logger(stub: true)&.info do |entry|
|
|
232
|
+
entry.set_system_name
|
|
233
|
+
entry.set_service
|
|
234
|
+
entry.message = "Created client for #{entry.service}"
|
|
235
|
+
entry.set_credentials_fields credentials
|
|
236
|
+
entry.set "customEndpoint", @config.endpoint if @config.endpoint
|
|
237
|
+
entry.set "defaultTimeout", @config.timeout if @config.timeout
|
|
238
|
+
entry.set "quotaProject", @quota_project_id if @quota_project_id
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
##
|
|
243
|
+
# The logger used for request/response debug logging.
|
|
244
|
+
#
|
|
245
|
+
# @return [Logger]
|
|
246
|
+
#
|
|
247
|
+
def logger
|
|
248
|
+
@spanner_stub.logger
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Service calls
|
|
252
|
+
|
|
253
|
+
##
|
|
254
|
+
# Creates a new session. A session can be used to perform
|
|
255
|
+
# transactions that read and/or modify data in a Cloud Spanner database.
|
|
256
|
+
# Sessions are meant to be reused for many consecutive
|
|
257
|
+
# transactions.
|
|
258
|
+
#
|
|
259
|
+
# Sessions can only execute one transaction at a time. To execute
|
|
260
|
+
# multiple concurrent read-write/write-only transactions, create
|
|
261
|
+
# multiple sessions. Note that standalone reads and queries use a
|
|
262
|
+
# transaction internally, and count toward the one transaction
|
|
263
|
+
# limit.
|
|
264
|
+
#
|
|
265
|
+
# Active sessions use additional server resources, so it's a good idea to
|
|
266
|
+
# delete idle and unneeded sessions.
|
|
267
|
+
# Aside from explicit deletes, Cloud Spanner can delete sessions when no
|
|
268
|
+
# operations are sent for more than an hour. If a session is deleted,
|
|
269
|
+
# requests to it return `NOT_FOUND`.
|
|
270
|
+
#
|
|
271
|
+
# Idle sessions can be kept alive by sending a trivial SQL query
|
|
272
|
+
# periodically, for example, `"SELECT 1"`.
|
|
273
|
+
#
|
|
274
|
+
# @overload create_session(request, options = nil)
|
|
275
|
+
# Pass arguments to `create_session` via a request object, either of type
|
|
276
|
+
# {::Google::Cloud::Spanner::V1::CreateSessionRequest} or an equivalent Hash.
|
|
277
|
+
#
|
|
278
|
+
# @param request [::Google::Cloud::Spanner::V1::CreateSessionRequest, ::Hash]
|
|
279
|
+
# A request object representing the call parameters. Required. To specify no
|
|
280
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
281
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
282
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
283
|
+
#
|
|
284
|
+
# @overload create_session(database: nil, session: nil)
|
|
285
|
+
# Pass arguments to `create_session` via keyword arguments. Note that at
|
|
286
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
287
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
288
|
+
#
|
|
289
|
+
# @param database [::String]
|
|
290
|
+
# Required. The database in which the new session is created.
|
|
291
|
+
# @param session [::Google::Cloud::Spanner::V1::Session, ::Hash]
|
|
292
|
+
# Required. The session to create.
|
|
293
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
294
|
+
# @yieldparam result [::Google::Cloud::Spanner::V1::Session]
|
|
295
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
296
|
+
#
|
|
297
|
+
# @return [::Google::Cloud::Spanner::V1::Session]
|
|
298
|
+
#
|
|
299
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
300
|
+
#
|
|
301
|
+
# @example Basic example
|
|
302
|
+
# require "google/cloud/spanner/v1"
|
|
303
|
+
#
|
|
304
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
305
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
306
|
+
#
|
|
307
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
308
|
+
# request = Google::Cloud::Spanner::V1::CreateSessionRequest.new
|
|
309
|
+
#
|
|
310
|
+
# # Call the create_session method.
|
|
311
|
+
# result = client.create_session request
|
|
312
|
+
#
|
|
313
|
+
# # The returned object is of type Google::Cloud::Spanner::V1::Session.
|
|
314
|
+
# p result
|
|
315
|
+
#
|
|
316
|
+
def create_session request, options = nil
|
|
317
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
318
|
+
|
|
319
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::CreateSessionRequest
|
|
320
|
+
|
|
321
|
+
# Converts hash and nil to an options object
|
|
322
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
323
|
+
|
|
324
|
+
# Customize the options with defaults
|
|
325
|
+
call_metadata = @config.rpcs.create_session.metadata.to_h
|
|
326
|
+
|
|
327
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
328
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
329
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
330
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
331
|
+
transports_version_send: [:rest]
|
|
332
|
+
|
|
333
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
334
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
335
|
+
|
|
336
|
+
options.apply_defaults timeout: @config.rpcs.create_session.timeout,
|
|
337
|
+
metadata: call_metadata,
|
|
338
|
+
retry_policy: @config.rpcs.create_session.retry_policy
|
|
339
|
+
|
|
340
|
+
options.apply_defaults timeout: @config.timeout,
|
|
341
|
+
metadata: @config.metadata,
|
|
342
|
+
retry_policy: @config.retry_policy
|
|
343
|
+
|
|
344
|
+
@spanner_stub.create_session request, options do |result, operation|
|
|
345
|
+
yield result, operation if block_given?
|
|
346
|
+
end
|
|
347
|
+
rescue ::Gapic::Rest::Error => e
|
|
348
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
##
|
|
352
|
+
# Creates multiple new sessions.
|
|
353
|
+
#
|
|
354
|
+
# This API can be used to initialize a session cache on the clients.
|
|
355
|
+
# See https://goo.gl/TgSFN2 for best practices on session cache management.
|
|
356
|
+
#
|
|
357
|
+
# @overload batch_create_sessions(request, options = nil)
|
|
358
|
+
# Pass arguments to `batch_create_sessions` via a request object, either of type
|
|
359
|
+
# {::Google::Cloud::Spanner::V1::BatchCreateSessionsRequest} or an equivalent Hash.
|
|
360
|
+
#
|
|
361
|
+
# @param request [::Google::Cloud::Spanner::V1::BatchCreateSessionsRequest, ::Hash]
|
|
362
|
+
# A request object representing the call parameters. Required. To specify no
|
|
363
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
364
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
365
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
366
|
+
#
|
|
367
|
+
# @overload batch_create_sessions(database: nil, session_template: nil, session_count: nil)
|
|
368
|
+
# Pass arguments to `batch_create_sessions` via keyword arguments. Note that at
|
|
369
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
370
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
371
|
+
#
|
|
372
|
+
# @param database [::String]
|
|
373
|
+
# Required. The database in which the new sessions are created.
|
|
374
|
+
# @param session_template [::Google::Cloud::Spanner::V1::Session, ::Hash]
|
|
375
|
+
# Parameters to apply to each created session.
|
|
376
|
+
# @param session_count [::Integer]
|
|
377
|
+
# Required. The number of sessions to be created in this batch call. At least
|
|
378
|
+
# one session is created. The API can return fewer than the requested number
|
|
379
|
+
# of sessions. If a specific number of sessions are desired, the client can
|
|
380
|
+
# make additional calls to `BatchCreateSessions` (adjusting
|
|
381
|
+
# {::Google::Cloud::Spanner::V1::BatchCreateSessionsRequest#session_count session_count}
|
|
382
|
+
# as necessary).
|
|
383
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
384
|
+
# @yieldparam result [::Google::Cloud::Spanner::V1::BatchCreateSessionsResponse]
|
|
385
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
386
|
+
#
|
|
387
|
+
# @return [::Google::Cloud::Spanner::V1::BatchCreateSessionsResponse]
|
|
388
|
+
#
|
|
389
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
390
|
+
#
|
|
391
|
+
# @example Basic example
|
|
392
|
+
# require "google/cloud/spanner/v1"
|
|
393
|
+
#
|
|
394
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
395
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
396
|
+
#
|
|
397
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
398
|
+
# request = Google::Cloud::Spanner::V1::BatchCreateSessionsRequest.new
|
|
399
|
+
#
|
|
400
|
+
# # Call the batch_create_sessions method.
|
|
401
|
+
# result = client.batch_create_sessions request
|
|
402
|
+
#
|
|
403
|
+
# # The returned object is of type Google::Cloud::Spanner::V1::BatchCreateSessionsResponse.
|
|
404
|
+
# p result
|
|
405
|
+
#
|
|
406
|
+
def batch_create_sessions request, options = nil
|
|
407
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
408
|
+
|
|
409
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::BatchCreateSessionsRequest
|
|
410
|
+
|
|
411
|
+
# Converts hash and nil to an options object
|
|
412
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
413
|
+
|
|
414
|
+
# Customize the options with defaults
|
|
415
|
+
call_metadata = @config.rpcs.batch_create_sessions.metadata.to_h
|
|
416
|
+
|
|
417
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
418
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
419
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
420
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
421
|
+
transports_version_send: [:rest]
|
|
422
|
+
|
|
423
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
424
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
425
|
+
|
|
426
|
+
options.apply_defaults timeout: @config.rpcs.batch_create_sessions.timeout,
|
|
427
|
+
metadata: call_metadata,
|
|
428
|
+
retry_policy: @config.rpcs.batch_create_sessions.retry_policy
|
|
429
|
+
|
|
430
|
+
options.apply_defaults timeout: @config.timeout,
|
|
431
|
+
metadata: @config.metadata,
|
|
432
|
+
retry_policy: @config.retry_policy
|
|
433
|
+
|
|
434
|
+
@spanner_stub.batch_create_sessions request, options do |result, operation|
|
|
435
|
+
yield result, operation if block_given?
|
|
436
|
+
end
|
|
437
|
+
rescue ::Gapic::Rest::Error => e
|
|
438
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
##
|
|
442
|
+
# Gets a session. Returns `NOT_FOUND` if the session doesn't exist.
|
|
443
|
+
# This is mainly useful for determining whether a session is still
|
|
444
|
+
# alive.
|
|
445
|
+
#
|
|
446
|
+
# @overload get_session(request, options = nil)
|
|
447
|
+
# Pass arguments to `get_session` via a request object, either of type
|
|
448
|
+
# {::Google::Cloud::Spanner::V1::GetSessionRequest} or an equivalent Hash.
|
|
449
|
+
#
|
|
450
|
+
# @param request [::Google::Cloud::Spanner::V1::GetSessionRequest, ::Hash]
|
|
451
|
+
# A request object representing the call parameters. Required. To specify no
|
|
452
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
453
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
454
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
455
|
+
#
|
|
456
|
+
# @overload get_session(name: nil)
|
|
457
|
+
# Pass arguments to `get_session` via keyword arguments. Note that at
|
|
458
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
459
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
460
|
+
#
|
|
461
|
+
# @param name [::String]
|
|
462
|
+
# Required. The name of the session to retrieve.
|
|
463
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
464
|
+
# @yieldparam result [::Google::Cloud::Spanner::V1::Session]
|
|
465
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
466
|
+
#
|
|
467
|
+
# @return [::Google::Cloud::Spanner::V1::Session]
|
|
468
|
+
#
|
|
469
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
470
|
+
#
|
|
471
|
+
# @example Basic example
|
|
472
|
+
# require "google/cloud/spanner/v1"
|
|
473
|
+
#
|
|
474
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
475
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
476
|
+
#
|
|
477
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
478
|
+
# request = Google::Cloud::Spanner::V1::GetSessionRequest.new
|
|
479
|
+
#
|
|
480
|
+
# # Call the get_session method.
|
|
481
|
+
# result = client.get_session request
|
|
482
|
+
#
|
|
483
|
+
# # The returned object is of type Google::Cloud::Spanner::V1::Session.
|
|
484
|
+
# p result
|
|
485
|
+
#
|
|
486
|
+
def get_session request, options = nil
|
|
487
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
488
|
+
|
|
489
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::GetSessionRequest
|
|
490
|
+
|
|
491
|
+
# Converts hash and nil to an options object
|
|
492
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
493
|
+
|
|
494
|
+
# Customize the options with defaults
|
|
495
|
+
call_metadata = @config.rpcs.get_session.metadata.to_h
|
|
496
|
+
|
|
497
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
498
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
499
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
500
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
501
|
+
transports_version_send: [:rest]
|
|
502
|
+
|
|
503
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
504
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
505
|
+
|
|
506
|
+
options.apply_defaults timeout: @config.rpcs.get_session.timeout,
|
|
507
|
+
metadata: call_metadata,
|
|
508
|
+
retry_policy: @config.rpcs.get_session.retry_policy
|
|
509
|
+
|
|
510
|
+
options.apply_defaults timeout: @config.timeout,
|
|
511
|
+
metadata: @config.metadata,
|
|
512
|
+
retry_policy: @config.retry_policy
|
|
513
|
+
|
|
514
|
+
@spanner_stub.get_session request, options do |result, operation|
|
|
515
|
+
yield result, operation if block_given?
|
|
516
|
+
end
|
|
517
|
+
rescue ::Gapic::Rest::Error => e
|
|
518
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
519
|
+
end
|
|
520
|
+
|
|
521
|
+
##
|
|
522
|
+
# Lists all sessions in a given database.
|
|
523
|
+
#
|
|
524
|
+
# @overload list_sessions(request, options = nil)
|
|
525
|
+
# Pass arguments to `list_sessions` via a request object, either of type
|
|
526
|
+
# {::Google::Cloud::Spanner::V1::ListSessionsRequest} or an equivalent Hash.
|
|
527
|
+
#
|
|
528
|
+
# @param request [::Google::Cloud::Spanner::V1::ListSessionsRequest, ::Hash]
|
|
529
|
+
# A request object representing the call parameters. Required. To specify no
|
|
530
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
531
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
532
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
533
|
+
#
|
|
534
|
+
# @overload list_sessions(database: nil, page_size: nil, page_token: nil, filter: nil)
|
|
535
|
+
# Pass arguments to `list_sessions` via keyword arguments. Note that at
|
|
536
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
537
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
538
|
+
#
|
|
539
|
+
# @param database [::String]
|
|
540
|
+
# Required. The database in which to list sessions.
|
|
541
|
+
# @param page_size [::Integer]
|
|
542
|
+
# Number of sessions to be returned in the response. If 0 or less, defaults
|
|
543
|
+
# to the server's maximum allowed page size.
|
|
544
|
+
# @param page_token [::String]
|
|
545
|
+
# If non-empty, `page_token` should contain a
|
|
546
|
+
# {::Google::Cloud::Spanner::V1::ListSessionsResponse#next_page_token next_page_token}
|
|
547
|
+
# from a previous
|
|
548
|
+
# {::Google::Cloud::Spanner::V1::ListSessionsResponse ListSessionsResponse}.
|
|
549
|
+
# @param filter [::String]
|
|
550
|
+
# An expression for filtering the results of the request. Filter rules are
|
|
551
|
+
# case insensitive. The fields eligible for filtering are:
|
|
552
|
+
#
|
|
553
|
+
# * `labels.key` where key is the name of a label
|
|
554
|
+
#
|
|
555
|
+
# Some examples of using filters are:
|
|
556
|
+
#
|
|
557
|
+
# * `labels.env:*` --> The session has the label "env".
|
|
558
|
+
# * `labels.env:dev` --> The session has the label "env" and the value of
|
|
559
|
+
# the label contains the string "dev".
|
|
560
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
561
|
+
# @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Spanner::V1::Session>]
|
|
562
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
563
|
+
#
|
|
564
|
+
# @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Spanner::V1::Session>]
|
|
565
|
+
#
|
|
566
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
567
|
+
#
|
|
568
|
+
# @example Basic example
|
|
569
|
+
# require "google/cloud/spanner/v1"
|
|
570
|
+
#
|
|
571
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
572
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
573
|
+
#
|
|
574
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
575
|
+
# request = Google::Cloud::Spanner::V1::ListSessionsRequest.new
|
|
576
|
+
#
|
|
577
|
+
# # Call the list_sessions method.
|
|
578
|
+
# result = client.list_sessions request
|
|
579
|
+
#
|
|
580
|
+
# # The returned object is of type Gapic::PagedEnumerable. You can iterate
|
|
581
|
+
# # over elements, and API calls will be issued to fetch pages as needed.
|
|
582
|
+
# result.each do |item|
|
|
583
|
+
# # Each element is of type ::Google::Cloud::Spanner::V1::Session.
|
|
584
|
+
# p item
|
|
585
|
+
# end
|
|
586
|
+
#
|
|
587
|
+
def list_sessions request, options = nil
|
|
588
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
589
|
+
|
|
590
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ListSessionsRequest
|
|
591
|
+
|
|
592
|
+
# Converts hash and nil to an options object
|
|
593
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
594
|
+
|
|
595
|
+
# Customize the options with defaults
|
|
596
|
+
call_metadata = @config.rpcs.list_sessions.metadata.to_h
|
|
597
|
+
|
|
598
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
599
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
600
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
601
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
602
|
+
transports_version_send: [:rest]
|
|
603
|
+
|
|
604
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
605
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
606
|
+
|
|
607
|
+
options.apply_defaults timeout: @config.rpcs.list_sessions.timeout,
|
|
608
|
+
metadata: call_metadata,
|
|
609
|
+
retry_policy: @config.rpcs.list_sessions.retry_policy
|
|
610
|
+
|
|
611
|
+
options.apply_defaults timeout: @config.timeout,
|
|
612
|
+
metadata: @config.metadata,
|
|
613
|
+
retry_policy: @config.retry_policy
|
|
614
|
+
|
|
615
|
+
@spanner_stub.list_sessions request, options do |result, operation|
|
|
616
|
+
result = ::Gapic::Rest::PagedEnumerable.new @spanner_stub, :list_sessions, "sessions", request, result, options
|
|
617
|
+
yield result, operation if block_given?
|
|
618
|
+
throw :response, result
|
|
619
|
+
end
|
|
620
|
+
rescue ::Gapic::Rest::Error => e
|
|
621
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
622
|
+
end
|
|
623
|
+
|
|
624
|
+
##
|
|
625
|
+
# Ends a session, releasing server resources associated with it. This
|
|
626
|
+
# asynchronously triggers the cancellation of any operations that are running
|
|
627
|
+
# with this session.
|
|
628
|
+
#
|
|
629
|
+
# @overload delete_session(request, options = nil)
|
|
630
|
+
# Pass arguments to `delete_session` via a request object, either of type
|
|
631
|
+
# {::Google::Cloud::Spanner::V1::DeleteSessionRequest} or an equivalent Hash.
|
|
632
|
+
#
|
|
633
|
+
# @param request [::Google::Cloud::Spanner::V1::DeleteSessionRequest, ::Hash]
|
|
634
|
+
# A request object representing the call parameters. Required. To specify no
|
|
635
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
636
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
637
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
638
|
+
#
|
|
639
|
+
# @overload delete_session(name: nil)
|
|
640
|
+
# Pass arguments to `delete_session` via keyword arguments. Note that at
|
|
641
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
642
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
643
|
+
#
|
|
644
|
+
# @param name [::String]
|
|
645
|
+
# Required. The name of the session to delete.
|
|
646
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
647
|
+
# @yieldparam result [::Google::Protobuf::Empty]
|
|
648
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
649
|
+
#
|
|
650
|
+
# @return [::Google::Protobuf::Empty]
|
|
651
|
+
#
|
|
652
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
653
|
+
#
|
|
654
|
+
# @example Basic example
|
|
655
|
+
# require "google/cloud/spanner/v1"
|
|
656
|
+
#
|
|
657
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
658
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
659
|
+
#
|
|
660
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
661
|
+
# request = Google::Cloud::Spanner::V1::DeleteSessionRequest.new
|
|
662
|
+
#
|
|
663
|
+
# # Call the delete_session method.
|
|
664
|
+
# result = client.delete_session request
|
|
665
|
+
#
|
|
666
|
+
# # The returned object is of type Google::Protobuf::Empty.
|
|
667
|
+
# p result
|
|
668
|
+
#
|
|
669
|
+
def delete_session request, options = nil
|
|
670
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
671
|
+
|
|
672
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::DeleteSessionRequest
|
|
673
|
+
|
|
674
|
+
# Converts hash and nil to an options object
|
|
675
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
676
|
+
|
|
677
|
+
# Customize the options with defaults
|
|
678
|
+
call_metadata = @config.rpcs.delete_session.metadata.to_h
|
|
679
|
+
|
|
680
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
681
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
682
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
683
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
684
|
+
transports_version_send: [:rest]
|
|
685
|
+
|
|
686
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
687
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
688
|
+
|
|
689
|
+
options.apply_defaults timeout: @config.rpcs.delete_session.timeout,
|
|
690
|
+
metadata: call_metadata,
|
|
691
|
+
retry_policy: @config.rpcs.delete_session.retry_policy
|
|
692
|
+
|
|
693
|
+
options.apply_defaults timeout: @config.timeout,
|
|
694
|
+
metadata: @config.metadata,
|
|
695
|
+
retry_policy: @config.retry_policy
|
|
696
|
+
|
|
697
|
+
@spanner_stub.delete_session request, options do |result, operation|
|
|
698
|
+
yield result, operation if block_given?
|
|
699
|
+
end
|
|
700
|
+
rescue ::Gapic::Rest::Error => e
|
|
701
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
##
|
|
705
|
+
# Executes an SQL statement, returning all results in a single reply. This
|
|
706
|
+
# method can't be used to return a result set larger than 10 MiB;
|
|
707
|
+
# if the query yields more data than that, the query fails with
|
|
708
|
+
# a `FAILED_PRECONDITION` error.
|
|
709
|
+
#
|
|
710
|
+
# Operations inside read-write transactions might return `ABORTED`. If
|
|
711
|
+
# this occurs, the application should restart the transaction from
|
|
712
|
+
# the beginning. See {::Google::Cloud::Spanner::V1::Transaction Transaction} for more
|
|
713
|
+
# details.
|
|
714
|
+
#
|
|
715
|
+
# Larger result sets can be fetched in streaming fashion by calling
|
|
716
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#execute_streaming_sql ExecuteStreamingSql}
|
|
717
|
+
# instead.
|
|
718
|
+
#
|
|
719
|
+
# The query string can be SQL or [Graph Query Language
|
|
720
|
+
# (GQL)](https://cloud.google.com/spanner/docs/reference/standard-sql/graph-intro).
|
|
721
|
+
#
|
|
722
|
+
# @overload execute_sql(request, options = nil)
|
|
723
|
+
# Pass arguments to `execute_sql` via a request object, either of type
|
|
724
|
+
# {::Google::Cloud::Spanner::V1::ExecuteSqlRequest} or an equivalent Hash.
|
|
725
|
+
#
|
|
726
|
+
# @param request [::Google::Cloud::Spanner::V1::ExecuteSqlRequest, ::Hash]
|
|
727
|
+
# A request object representing the call parameters. Required. To specify no
|
|
728
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
729
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
730
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
731
|
+
#
|
|
732
|
+
# @overload execute_sql(session: nil, transaction: nil, sql: nil, params: nil, param_types: nil, resume_token: nil, query_mode: nil, partition_token: nil, seqno: nil, query_options: nil, request_options: nil, directed_read_options: nil, data_boost_enabled: nil, last_statement: nil, routing_hint: nil)
|
|
733
|
+
# Pass arguments to `execute_sql` via keyword arguments. Note that at
|
|
734
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
735
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
736
|
+
#
|
|
737
|
+
# @param session [::String]
|
|
738
|
+
# Required. The session in which the SQL query should be performed.
|
|
739
|
+
# @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
|
|
740
|
+
# The transaction to use.
|
|
741
|
+
#
|
|
742
|
+
# For queries, if none is provided, the default is a temporary read-only
|
|
743
|
+
# transaction with strong concurrency.
|
|
744
|
+
#
|
|
745
|
+
# Standard DML statements require a read-write transaction. To protect
|
|
746
|
+
# against replays, single-use transactions are not supported. The caller
|
|
747
|
+
# must either supply an existing transaction ID or begin a new transaction.
|
|
748
|
+
#
|
|
749
|
+
# Partitioned DML requires an existing Partitioned DML transaction ID.
|
|
750
|
+
# @param sql [::String]
|
|
751
|
+
# Required. The SQL string.
|
|
752
|
+
# @param params [::Google::Protobuf::Struct, ::Hash]
|
|
753
|
+
# Parameter names and values that bind to placeholders in the SQL string.
|
|
754
|
+
#
|
|
755
|
+
# A parameter placeholder consists of the `@` character followed by the
|
|
756
|
+
# parameter name (for example, `@firstName`). Parameter names must conform
|
|
757
|
+
# to the naming requirements of identifiers as specified at
|
|
758
|
+
# https://cloud.google.com/spanner/docs/lexical#identifiers.
|
|
759
|
+
#
|
|
760
|
+
# Parameters can appear anywhere that a literal value is expected. The same
|
|
761
|
+
# parameter name can be used more than once, for example:
|
|
762
|
+
#
|
|
763
|
+
# `"WHERE id > @msg_id AND id < @msg_id + 100"`
|
|
764
|
+
#
|
|
765
|
+
# It's an error to execute a SQL statement with unbound parameters.
|
|
766
|
+
# @param param_types [::Hash{::String => ::Google::Cloud::Spanner::V1::Type, ::Hash}]
|
|
767
|
+
# It isn't always possible for Cloud Spanner to infer the right SQL type
|
|
768
|
+
# from a JSON value. For example, values of type `BYTES` and values
|
|
769
|
+
# of type `STRING` both appear in
|
|
770
|
+
# {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#params params} as JSON strings.
|
|
771
|
+
#
|
|
772
|
+
# In these cases, you can use `param_types` to specify the exact
|
|
773
|
+
# SQL type for some or all of the SQL statement parameters. See the
|
|
774
|
+
# definition of {::Google::Cloud::Spanner::V1::Type Type} for more information
|
|
775
|
+
# about SQL types.
|
|
776
|
+
# @param resume_token [::String]
|
|
777
|
+
# If this request is resuming a previously interrupted SQL statement
|
|
778
|
+
# execution, `resume_token` should be copied from the last
|
|
779
|
+
# {::Google::Cloud::Spanner::V1::PartialResultSet PartialResultSet} yielded before the
|
|
780
|
+
# interruption. Doing this enables the new SQL statement execution to resume
|
|
781
|
+
# where the last one left off. The rest of the request parameters must
|
|
782
|
+
# exactly match the request that yielded this token.
|
|
783
|
+
# @param query_mode [::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryMode]
|
|
784
|
+
# Used to control the amount of debugging information returned in
|
|
785
|
+
# {::Google::Cloud::Spanner::V1::ResultSetStats ResultSetStats}. If
|
|
786
|
+
# {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#partition_token partition_token} is
|
|
787
|
+
# set, {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#query_mode query_mode} can only
|
|
788
|
+
# be set to
|
|
789
|
+
# {::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryMode::NORMAL QueryMode.NORMAL}.
|
|
790
|
+
# @param partition_token [::String]
|
|
791
|
+
# If present, results are restricted to the specified partition
|
|
792
|
+
# previously created using `PartitionQuery`. There must be an exact
|
|
793
|
+
# match for the values of fields common to this message and the
|
|
794
|
+
# `PartitionQueryRequest` message used to create this `partition_token`.
|
|
795
|
+
# @param seqno [::Integer]
|
|
796
|
+
# A per-transaction sequence number used to identify this request. This field
|
|
797
|
+
# makes each request idempotent such that if the request is received multiple
|
|
798
|
+
# times, at most one succeeds.
|
|
799
|
+
#
|
|
800
|
+
# The sequence number must be monotonically increasing within the
|
|
801
|
+
# transaction. If a request arrives for the first time with an out-of-order
|
|
802
|
+
# sequence number, the transaction can be aborted. Replays of previously
|
|
803
|
+
# handled requests yield the same response as the first execution.
|
|
804
|
+
#
|
|
805
|
+
# Required for DML statements. Ignored for queries.
|
|
806
|
+
# @param query_options [::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryOptions, ::Hash]
|
|
807
|
+
# Query optimizer configuration to use for the given query.
|
|
808
|
+
# @param request_options [::Google::Cloud::Spanner::V1::RequestOptions, ::Hash]
|
|
809
|
+
# Common options for this request.
|
|
810
|
+
# @param directed_read_options [::Google::Cloud::Spanner::V1::DirectedReadOptions, ::Hash]
|
|
811
|
+
# Directed read options for this request.
|
|
812
|
+
# @param data_boost_enabled [::Boolean]
|
|
813
|
+
# If this is for a partitioned query and this field is set to `true`, the
|
|
814
|
+
# request is executed with Spanner Data Boost independent compute resources.
|
|
815
|
+
#
|
|
816
|
+
# If the field is set to `true` but the request doesn't set
|
|
817
|
+
# `partition_token`, the API returns an `INVALID_ARGUMENT` error.
|
|
818
|
+
# @param last_statement [::Boolean]
|
|
819
|
+
# Optional. If set to `true`, this statement marks the end of the
|
|
820
|
+
# transaction. After this statement executes, you must commit or abort the
|
|
821
|
+
# transaction. Attempts to execute any other requests against this
|
|
822
|
+
# transaction (including reads and queries) are rejected.
|
|
823
|
+
#
|
|
824
|
+
# For DML statements, setting this option might cause some error reporting to
|
|
825
|
+
# be deferred until commit time (for example, validation of unique
|
|
826
|
+
# constraints). Given this, successful execution of a DML statement shouldn't
|
|
827
|
+
# be assumed until a subsequent `Commit` call completes successfully.
|
|
828
|
+
# @param routing_hint [::Google::Cloud::Spanner::V1::RoutingHint, ::Hash]
|
|
829
|
+
# Optional. Makes the Spanner requests location-aware if present.
|
|
830
|
+
#
|
|
831
|
+
# It gives the server hints that can be used to route the request
|
|
832
|
+
# to an appropriate server, potentially significantly decreasing latency and
|
|
833
|
+
# improving throughput. To achieve improved performance, most fields must be
|
|
834
|
+
# filled in with accurate values.
|
|
835
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
836
|
+
# @yieldparam result [::Google::Cloud::Spanner::V1::ResultSet]
|
|
837
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
838
|
+
#
|
|
839
|
+
# @return [::Google::Cloud::Spanner::V1::ResultSet]
|
|
840
|
+
#
|
|
841
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
842
|
+
#
|
|
843
|
+
# @example Basic example
|
|
844
|
+
# require "google/cloud/spanner/v1"
|
|
845
|
+
#
|
|
846
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
847
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
848
|
+
#
|
|
849
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
850
|
+
# request = Google::Cloud::Spanner::V1::ExecuteSqlRequest.new
|
|
851
|
+
#
|
|
852
|
+
# # Call the execute_sql method.
|
|
853
|
+
# result = client.execute_sql request
|
|
854
|
+
#
|
|
855
|
+
# # The returned object is of type Google::Cloud::Spanner::V1::ResultSet.
|
|
856
|
+
# p result
|
|
857
|
+
#
|
|
858
|
+
def execute_sql request, options = nil
|
|
859
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
860
|
+
|
|
861
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ExecuteSqlRequest
|
|
862
|
+
|
|
863
|
+
# Converts hash and nil to an options object
|
|
864
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
865
|
+
|
|
866
|
+
# Customize the options with defaults
|
|
867
|
+
call_metadata = @config.rpcs.execute_sql.metadata.to_h
|
|
868
|
+
|
|
869
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
870
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
871
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
872
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
873
|
+
transports_version_send: [:rest]
|
|
874
|
+
|
|
875
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
876
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
877
|
+
|
|
878
|
+
options.apply_defaults timeout: @config.rpcs.execute_sql.timeout,
|
|
879
|
+
metadata: call_metadata,
|
|
880
|
+
retry_policy: @config.rpcs.execute_sql.retry_policy
|
|
881
|
+
|
|
882
|
+
options.apply_defaults timeout: @config.timeout,
|
|
883
|
+
metadata: @config.metadata,
|
|
884
|
+
retry_policy: @config.retry_policy
|
|
885
|
+
|
|
886
|
+
@spanner_stub.execute_sql request, options do |result, operation|
|
|
887
|
+
yield result, operation if block_given?
|
|
888
|
+
end
|
|
889
|
+
rescue ::Gapic::Rest::Error => e
|
|
890
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
891
|
+
end
|
|
892
|
+
|
|
893
|
+
##
|
|
894
|
+
# Like {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#execute_sql ExecuteSql}, except returns the
|
|
895
|
+
# result set as a stream. Unlike
|
|
896
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#execute_sql ExecuteSql}, there is no limit on
|
|
897
|
+
# the size of the returned result set. However, no individual row in the
|
|
898
|
+
# result set can exceed 100 MiB, and no column value can exceed 10 MiB.
|
|
899
|
+
#
|
|
900
|
+
# The query string can be SQL or [Graph Query Language
|
|
901
|
+
# (GQL)](https://cloud.google.com/spanner/docs/reference/standard-sql/graph-intro).
|
|
902
|
+
#
|
|
903
|
+
# @overload execute_streaming_sql(request, options = nil)
|
|
904
|
+
# Pass arguments to `execute_streaming_sql` via a request object, either of type
|
|
905
|
+
# {::Google::Cloud::Spanner::V1::ExecuteSqlRequest} or an equivalent Hash.
|
|
906
|
+
#
|
|
907
|
+
# @param request [::Google::Cloud::Spanner::V1::ExecuteSqlRequest, ::Hash]
|
|
908
|
+
# A request object representing the call parameters. Required. To specify no
|
|
909
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
910
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
911
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
912
|
+
#
|
|
913
|
+
# @overload execute_streaming_sql(session: nil, transaction: nil, sql: nil, params: nil, param_types: nil, resume_token: nil, query_mode: nil, partition_token: nil, seqno: nil, query_options: nil, request_options: nil, directed_read_options: nil, data_boost_enabled: nil, last_statement: nil, routing_hint: nil)
|
|
914
|
+
# Pass arguments to `execute_streaming_sql` via keyword arguments. Note that at
|
|
915
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
916
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
917
|
+
#
|
|
918
|
+
# @param session [::String]
|
|
919
|
+
# Required. The session in which the SQL query should be performed.
|
|
920
|
+
# @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
|
|
921
|
+
# The transaction to use.
|
|
922
|
+
#
|
|
923
|
+
# For queries, if none is provided, the default is a temporary read-only
|
|
924
|
+
# transaction with strong concurrency.
|
|
925
|
+
#
|
|
926
|
+
# Standard DML statements require a read-write transaction. To protect
|
|
927
|
+
# against replays, single-use transactions are not supported. The caller
|
|
928
|
+
# must either supply an existing transaction ID or begin a new transaction.
|
|
929
|
+
#
|
|
930
|
+
# Partitioned DML requires an existing Partitioned DML transaction ID.
|
|
931
|
+
# @param sql [::String]
|
|
932
|
+
# Required. The SQL string.
|
|
933
|
+
# @param params [::Google::Protobuf::Struct, ::Hash]
|
|
934
|
+
# Parameter names and values that bind to placeholders in the SQL string.
|
|
935
|
+
#
|
|
936
|
+
# A parameter placeholder consists of the `@` character followed by the
|
|
937
|
+
# parameter name (for example, `@firstName`). Parameter names must conform
|
|
938
|
+
# to the naming requirements of identifiers as specified at
|
|
939
|
+
# https://cloud.google.com/spanner/docs/lexical#identifiers.
|
|
940
|
+
#
|
|
941
|
+
# Parameters can appear anywhere that a literal value is expected. The same
|
|
942
|
+
# parameter name can be used more than once, for example:
|
|
943
|
+
#
|
|
944
|
+
# `"WHERE id > @msg_id AND id < @msg_id + 100"`
|
|
945
|
+
#
|
|
946
|
+
# It's an error to execute a SQL statement with unbound parameters.
|
|
947
|
+
# @param param_types [::Hash{::String => ::Google::Cloud::Spanner::V1::Type, ::Hash}]
|
|
948
|
+
# It isn't always possible for Cloud Spanner to infer the right SQL type
|
|
949
|
+
# from a JSON value. For example, values of type `BYTES` and values
|
|
950
|
+
# of type `STRING` both appear in
|
|
951
|
+
# {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#params params} as JSON strings.
|
|
952
|
+
#
|
|
953
|
+
# In these cases, you can use `param_types` to specify the exact
|
|
954
|
+
# SQL type for some or all of the SQL statement parameters. See the
|
|
955
|
+
# definition of {::Google::Cloud::Spanner::V1::Type Type} for more information
|
|
956
|
+
# about SQL types.
|
|
957
|
+
# @param resume_token [::String]
|
|
958
|
+
# If this request is resuming a previously interrupted SQL statement
|
|
959
|
+
# execution, `resume_token` should be copied from the last
|
|
960
|
+
# {::Google::Cloud::Spanner::V1::PartialResultSet PartialResultSet} yielded before the
|
|
961
|
+
# interruption. Doing this enables the new SQL statement execution to resume
|
|
962
|
+
# where the last one left off. The rest of the request parameters must
|
|
963
|
+
# exactly match the request that yielded this token.
|
|
964
|
+
# @param query_mode [::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryMode]
|
|
965
|
+
# Used to control the amount of debugging information returned in
|
|
966
|
+
# {::Google::Cloud::Spanner::V1::ResultSetStats ResultSetStats}. If
|
|
967
|
+
# {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#partition_token partition_token} is
|
|
968
|
+
# set, {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#query_mode query_mode} can only
|
|
969
|
+
# be set to
|
|
970
|
+
# {::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryMode::NORMAL QueryMode.NORMAL}.
|
|
971
|
+
# @param partition_token [::String]
|
|
972
|
+
# If present, results are restricted to the specified partition
|
|
973
|
+
# previously created using `PartitionQuery`. There must be an exact
|
|
974
|
+
# match for the values of fields common to this message and the
|
|
975
|
+
# `PartitionQueryRequest` message used to create this `partition_token`.
|
|
976
|
+
# @param seqno [::Integer]
|
|
977
|
+
# A per-transaction sequence number used to identify this request. This field
|
|
978
|
+
# makes each request idempotent such that if the request is received multiple
|
|
979
|
+
# times, at most one succeeds.
|
|
980
|
+
#
|
|
981
|
+
# The sequence number must be monotonically increasing within the
|
|
982
|
+
# transaction. If a request arrives for the first time with an out-of-order
|
|
983
|
+
# sequence number, the transaction can be aborted. Replays of previously
|
|
984
|
+
# handled requests yield the same response as the first execution.
|
|
985
|
+
#
|
|
986
|
+
# Required for DML statements. Ignored for queries.
|
|
987
|
+
# @param query_options [::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryOptions, ::Hash]
|
|
988
|
+
# Query optimizer configuration to use for the given query.
|
|
989
|
+
# @param request_options [::Google::Cloud::Spanner::V1::RequestOptions, ::Hash]
|
|
990
|
+
# Common options for this request.
|
|
991
|
+
# @param directed_read_options [::Google::Cloud::Spanner::V1::DirectedReadOptions, ::Hash]
|
|
992
|
+
# Directed read options for this request.
|
|
993
|
+
# @param data_boost_enabled [::Boolean]
|
|
994
|
+
# If this is for a partitioned query and this field is set to `true`, the
|
|
995
|
+
# request is executed with Spanner Data Boost independent compute resources.
|
|
996
|
+
#
|
|
997
|
+
# If the field is set to `true` but the request doesn't set
|
|
998
|
+
# `partition_token`, the API returns an `INVALID_ARGUMENT` error.
|
|
999
|
+
# @param last_statement [::Boolean]
|
|
1000
|
+
# Optional. If set to `true`, this statement marks the end of the
|
|
1001
|
+
# transaction. After this statement executes, you must commit or abort the
|
|
1002
|
+
# transaction. Attempts to execute any other requests against this
|
|
1003
|
+
# transaction (including reads and queries) are rejected.
|
|
1004
|
+
#
|
|
1005
|
+
# For DML statements, setting this option might cause some error reporting to
|
|
1006
|
+
# be deferred until commit time (for example, validation of unique
|
|
1007
|
+
# constraints). Given this, successful execution of a DML statement shouldn't
|
|
1008
|
+
# be assumed until a subsequent `Commit` call completes successfully.
|
|
1009
|
+
# @param routing_hint [::Google::Cloud::Spanner::V1::RoutingHint, ::Hash]
|
|
1010
|
+
# Optional. Makes the Spanner requests location-aware if present.
|
|
1011
|
+
#
|
|
1012
|
+
# It gives the server hints that can be used to route the request
|
|
1013
|
+
# to an appropriate server, potentially significantly decreasing latency and
|
|
1014
|
+
# improving throughput. To achieve improved performance, most fields must be
|
|
1015
|
+
# filled in with accurate values.
|
|
1016
|
+
# @return [::Enumerable<::Google::Cloud::Spanner::V1::PartialResultSet>]
|
|
1017
|
+
#
|
|
1018
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
1019
|
+
#
|
|
1020
|
+
# @example Basic example
|
|
1021
|
+
# require "google/cloud/spanner/v1"
|
|
1022
|
+
#
|
|
1023
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
1024
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
1025
|
+
#
|
|
1026
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
1027
|
+
# request = Google::Cloud::Spanner::V1::ExecuteSqlRequest.new
|
|
1028
|
+
#
|
|
1029
|
+
# # Call the execute_streaming_sql method to start streaming.
|
|
1030
|
+
# output = client.execute_streaming_sql request
|
|
1031
|
+
#
|
|
1032
|
+
# # The returned object is a streamed enumerable yielding elements of type
|
|
1033
|
+
# # ::Google::Cloud::Spanner::V1::PartialResultSet
|
|
1034
|
+
# output.each do |current_response|
|
|
1035
|
+
# p current_response
|
|
1036
|
+
# end
|
|
1037
|
+
#
|
|
1038
|
+
def execute_streaming_sql request, options = nil
|
|
1039
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
1040
|
+
|
|
1041
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ExecuteSqlRequest
|
|
1042
|
+
|
|
1043
|
+
# Converts hash and nil to an options object
|
|
1044
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
1045
|
+
|
|
1046
|
+
# Customize the options with defaults
|
|
1047
|
+
call_metadata = @config.rpcs.execute_streaming_sql.metadata.to_h
|
|
1048
|
+
|
|
1049
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
1050
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
1051
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
1052
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
1053
|
+
transports_version_send: [:rest]
|
|
1054
|
+
|
|
1055
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
1056
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
1057
|
+
|
|
1058
|
+
options.apply_defaults timeout: @config.rpcs.execute_streaming_sql.timeout,
|
|
1059
|
+
metadata: call_metadata,
|
|
1060
|
+
retry_policy: @config.rpcs.execute_streaming_sql.retry_policy
|
|
1061
|
+
|
|
1062
|
+
options.apply_defaults timeout: @config.timeout,
|
|
1063
|
+
metadata: @config.metadata,
|
|
1064
|
+
retry_policy: @config.retry_policy
|
|
1065
|
+
|
|
1066
|
+
::Gapic::Rest::ServerStream.new(
|
|
1067
|
+
::Google::Cloud::Spanner::V1::PartialResultSet,
|
|
1068
|
+
::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
|
|
1069
|
+
@spanner_stub.execute_streaming_sql request, options do |chunk|
|
|
1070
|
+
in_q.deq
|
|
1071
|
+
out_q.enq chunk
|
|
1072
|
+
end
|
|
1073
|
+
end
|
|
1074
|
+
)
|
|
1075
|
+
rescue ::Gapic::Rest::Error => e
|
|
1076
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
1077
|
+
end
|
|
1078
|
+
|
|
1079
|
+
##
|
|
1080
|
+
# Executes a batch of SQL DML statements. This method allows many statements
|
|
1081
|
+
# to be run with lower latency than submitting them sequentially with
|
|
1082
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#execute_sql ExecuteSql}.
|
|
1083
|
+
#
|
|
1084
|
+
# Statements are executed in sequential order. A request can succeed even if
|
|
1085
|
+
# a statement fails. The
|
|
1086
|
+
# {::Google::Cloud::Spanner::V1::ExecuteBatchDmlResponse#status ExecuteBatchDmlResponse.status}
|
|
1087
|
+
# field in the response provides information about the statement that failed.
|
|
1088
|
+
# Clients must inspect this field to determine whether an error occurred.
|
|
1089
|
+
#
|
|
1090
|
+
# Execution stops after the first failed statement; the remaining statements
|
|
1091
|
+
# are not executed.
|
|
1092
|
+
#
|
|
1093
|
+
# @overload execute_batch_dml(request, options = nil)
|
|
1094
|
+
# Pass arguments to `execute_batch_dml` via a request object, either of type
|
|
1095
|
+
# {::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest} or an equivalent Hash.
|
|
1096
|
+
#
|
|
1097
|
+
# @param request [::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest, ::Hash]
|
|
1098
|
+
# A request object representing the call parameters. Required. To specify no
|
|
1099
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
1100
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
1101
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
1102
|
+
#
|
|
1103
|
+
# @overload execute_batch_dml(session: nil, transaction: nil, statements: nil, seqno: nil, request_options: nil, last_statements: nil)
|
|
1104
|
+
# Pass arguments to `execute_batch_dml` via keyword arguments. Note that at
|
|
1105
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
1106
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
1107
|
+
#
|
|
1108
|
+
# @param session [::String]
|
|
1109
|
+
# Required. The session in which the DML statements should be performed.
|
|
1110
|
+
# @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
|
|
1111
|
+
# Required. The transaction to use. Must be a read-write transaction.
|
|
1112
|
+
#
|
|
1113
|
+
# To protect against replays, single-use transactions are not supported. The
|
|
1114
|
+
# caller must either supply an existing transaction ID or begin a new
|
|
1115
|
+
# transaction.
|
|
1116
|
+
# @param statements [::Array<::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest::Statement, ::Hash>]
|
|
1117
|
+
# Required. The list of statements to execute in this batch. Statements are
|
|
1118
|
+
# executed serially, such that the effects of statement `i` are visible to
|
|
1119
|
+
# statement `i+1`. Each statement must be a DML statement. Execution stops at
|
|
1120
|
+
# the first failed statement; the remaining statements are not executed.
|
|
1121
|
+
#
|
|
1122
|
+
# Callers must provide at least one statement.
|
|
1123
|
+
# @param seqno [::Integer]
|
|
1124
|
+
# Required. A per-transaction sequence number used to identify this request.
|
|
1125
|
+
# This field makes each request idempotent such that if the request is
|
|
1126
|
+
# received multiple times, at most one succeeds.
|
|
1127
|
+
#
|
|
1128
|
+
# The sequence number must be monotonically increasing within the
|
|
1129
|
+
# transaction. If a request arrives for the first time with an out-of-order
|
|
1130
|
+
# sequence number, the transaction might be aborted. Replays of previously
|
|
1131
|
+
# handled requests yield the same response as the first execution.
|
|
1132
|
+
# @param request_options [::Google::Cloud::Spanner::V1::RequestOptions, ::Hash]
|
|
1133
|
+
# Common options for this request.
|
|
1134
|
+
# @param last_statements [::Boolean]
|
|
1135
|
+
# Optional. If set to `true`, this request marks the end of the transaction.
|
|
1136
|
+
# After these statements execute, you must commit or abort the transaction.
|
|
1137
|
+
# Attempts to execute any other requests against this transaction
|
|
1138
|
+
# (including reads and queries) are rejected.
|
|
1139
|
+
#
|
|
1140
|
+
# Setting this option might cause some error reporting to be deferred until
|
|
1141
|
+
# commit time (for example, validation of unique constraints). Given this,
|
|
1142
|
+
# successful execution of statements shouldn't be assumed until a subsequent
|
|
1143
|
+
# `Commit` call completes successfully.
|
|
1144
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
1145
|
+
# @yieldparam result [::Google::Cloud::Spanner::V1::ExecuteBatchDmlResponse]
|
|
1146
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
1147
|
+
#
|
|
1148
|
+
# @return [::Google::Cloud::Spanner::V1::ExecuteBatchDmlResponse]
|
|
1149
|
+
#
|
|
1150
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
1151
|
+
#
|
|
1152
|
+
# @example Basic example
|
|
1153
|
+
# require "google/cloud/spanner/v1"
|
|
1154
|
+
#
|
|
1155
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
1156
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
1157
|
+
#
|
|
1158
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
1159
|
+
# request = Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest.new
|
|
1160
|
+
#
|
|
1161
|
+
# # Call the execute_batch_dml method.
|
|
1162
|
+
# result = client.execute_batch_dml request
|
|
1163
|
+
#
|
|
1164
|
+
# # The returned object is of type Google::Cloud::Spanner::V1::ExecuteBatchDmlResponse.
|
|
1165
|
+
# p result
|
|
1166
|
+
#
|
|
1167
|
+
def execute_batch_dml request, options = nil
|
|
1168
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
1169
|
+
|
|
1170
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest
|
|
1171
|
+
|
|
1172
|
+
# Converts hash and nil to an options object
|
|
1173
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
1174
|
+
|
|
1175
|
+
# Customize the options with defaults
|
|
1176
|
+
call_metadata = @config.rpcs.execute_batch_dml.metadata.to_h
|
|
1177
|
+
|
|
1178
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
1179
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
1180
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
1181
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
1182
|
+
transports_version_send: [:rest]
|
|
1183
|
+
|
|
1184
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
1185
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
1186
|
+
|
|
1187
|
+
options.apply_defaults timeout: @config.rpcs.execute_batch_dml.timeout,
|
|
1188
|
+
metadata: call_metadata,
|
|
1189
|
+
retry_policy: @config.rpcs.execute_batch_dml.retry_policy
|
|
1190
|
+
|
|
1191
|
+
options.apply_defaults timeout: @config.timeout,
|
|
1192
|
+
metadata: @config.metadata,
|
|
1193
|
+
retry_policy: @config.retry_policy
|
|
1194
|
+
|
|
1195
|
+
@spanner_stub.execute_batch_dml request, options do |result, operation|
|
|
1196
|
+
yield result, operation if block_given?
|
|
1197
|
+
end
|
|
1198
|
+
rescue ::Gapic::Rest::Error => e
|
|
1199
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
1200
|
+
end
|
|
1201
|
+
|
|
1202
|
+
##
|
|
1203
|
+
# Reads rows from the database using key lookups and scans, as a
|
|
1204
|
+
# simple key/value style alternative to
|
|
1205
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#execute_sql ExecuteSql}. This method can't be
|
|
1206
|
+
# used to return a result set larger than 10 MiB; if the read matches more
|
|
1207
|
+
# data than that, the read fails with a `FAILED_PRECONDITION`
|
|
1208
|
+
# error.
|
|
1209
|
+
#
|
|
1210
|
+
# Reads inside read-write transactions might return `ABORTED`. If
|
|
1211
|
+
# this occurs, the application should restart the transaction from
|
|
1212
|
+
# the beginning. See {::Google::Cloud::Spanner::V1::Transaction Transaction} for more
|
|
1213
|
+
# details.
|
|
1214
|
+
#
|
|
1215
|
+
# Larger result sets can be yielded in streaming fashion by calling
|
|
1216
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#streaming_read StreamingRead} instead.
|
|
1217
|
+
#
|
|
1218
|
+
# @overload read(request, options = nil)
|
|
1219
|
+
# Pass arguments to `read` via a request object, either of type
|
|
1220
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest} or an equivalent Hash.
|
|
1221
|
+
#
|
|
1222
|
+
# @param request [::Google::Cloud::Spanner::V1::ReadRequest, ::Hash]
|
|
1223
|
+
# A request object representing the call parameters. Required. To specify no
|
|
1224
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
1225
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
1226
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
1227
|
+
#
|
|
1228
|
+
# @overload read(session: nil, transaction: nil, table: nil, index: nil, columns: nil, key_set: nil, limit: nil, resume_token: nil, partition_token: nil, request_options: nil, directed_read_options: nil, data_boost_enabled: nil, order_by: nil, lock_hint: nil, routing_hint: nil)
|
|
1229
|
+
# Pass arguments to `read` via keyword arguments. Note that at
|
|
1230
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
1231
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
1232
|
+
#
|
|
1233
|
+
# @param session [::String]
|
|
1234
|
+
# Required. The session in which the read should be performed.
|
|
1235
|
+
# @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
|
|
1236
|
+
# The transaction to use. If none is provided, the default is a
|
|
1237
|
+
# temporary read-only transaction with strong concurrency.
|
|
1238
|
+
# @param table [::String]
|
|
1239
|
+
# Required. The name of the table in the database to be read.
|
|
1240
|
+
# @param index [::String]
|
|
1241
|
+
# If non-empty, the name of an index on
|
|
1242
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest#table table}. This index is used instead of
|
|
1243
|
+
# the table primary key when interpreting
|
|
1244
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set} and sorting result rows.
|
|
1245
|
+
# See {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set} for further
|
|
1246
|
+
# information.
|
|
1247
|
+
# @param columns [::Array<::String>]
|
|
1248
|
+
# Required. The columns of {::Google::Cloud::Spanner::V1::ReadRequest#table table} to be
|
|
1249
|
+
# returned for each row matching this request.
|
|
1250
|
+
# @param key_set [::Google::Cloud::Spanner::V1::KeySet, ::Hash]
|
|
1251
|
+
# Required. `key_set` identifies the rows to be yielded. `key_set` names the
|
|
1252
|
+
# primary keys of the rows in {::Google::Cloud::Spanner::V1::ReadRequest#table table} to
|
|
1253
|
+
# be yielded, unless {::Google::Cloud::Spanner::V1::ReadRequest#index index} is present.
|
|
1254
|
+
# If {::Google::Cloud::Spanner::V1::ReadRequest#index index} is present, then
|
|
1255
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set} instead names index keys
|
|
1256
|
+
# in {::Google::Cloud::Spanner::V1::ReadRequest#index index}.
|
|
1257
|
+
#
|
|
1258
|
+
# If the {::Google::Cloud::Spanner::V1::ReadRequest#partition_token partition_token}
|
|
1259
|
+
# field is empty, rows are yielded in table primary key order (if
|
|
1260
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest#index index} is empty) or index key order
|
|
1261
|
+
# (if {::Google::Cloud::Spanner::V1::ReadRequest#index index} is non-empty). If the
|
|
1262
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest#partition_token partition_token} field
|
|
1263
|
+
# isn't empty, rows are yielded in an unspecified order.
|
|
1264
|
+
#
|
|
1265
|
+
# It isn't an error for the `key_set` to name rows that don't
|
|
1266
|
+
# exist in the database. Read yields nothing for nonexistent rows.
|
|
1267
|
+
# @param limit [::Integer]
|
|
1268
|
+
# If greater than zero, only the first `limit` rows are yielded. If `limit`
|
|
1269
|
+
# is zero, the default is no limit. A limit can't be specified if
|
|
1270
|
+
# `partition_token` is set.
|
|
1271
|
+
# @param resume_token [::String]
|
|
1272
|
+
# If this request is resuming a previously interrupted read,
|
|
1273
|
+
# `resume_token` should be copied from the last
|
|
1274
|
+
# {::Google::Cloud::Spanner::V1::PartialResultSet PartialResultSet} yielded before the
|
|
1275
|
+
# interruption. Doing this enables the new read to resume where the last read
|
|
1276
|
+
# left off. The rest of the request parameters must exactly match the request
|
|
1277
|
+
# that yielded this token.
|
|
1278
|
+
# @param partition_token [::String]
|
|
1279
|
+
# If present, results are restricted to the specified partition
|
|
1280
|
+
# previously created using `PartitionRead`. There must be an exact
|
|
1281
|
+
# match for the values of fields common to this message and the
|
|
1282
|
+
# PartitionReadRequest message used to create this partition_token.
|
|
1283
|
+
# @param request_options [::Google::Cloud::Spanner::V1::RequestOptions, ::Hash]
|
|
1284
|
+
# Common options for this request.
|
|
1285
|
+
# @param directed_read_options [::Google::Cloud::Spanner::V1::DirectedReadOptions, ::Hash]
|
|
1286
|
+
# Directed read options for this request.
|
|
1287
|
+
# @param data_boost_enabled [::Boolean]
|
|
1288
|
+
# If this is for a partitioned read and this field is set to `true`, the
|
|
1289
|
+
# request is executed with Spanner Data Boost independent compute resources.
|
|
1290
|
+
#
|
|
1291
|
+
# If the field is set to `true` but the request doesn't set
|
|
1292
|
+
# `partition_token`, the API returns an `INVALID_ARGUMENT` error.
|
|
1293
|
+
# @param order_by [::Google::Cloud::Spanner::V1::ReadRequest::OrderBy]
|
|
1294
|
+
# Optional. Order for the returned rows.
|
|
1295
|
+
#
|
|
1296
|
+
# By default, Spanner returns result rows in primary key order except for
|
|
1297
|
+
# PartitionRead requests. For applications that don't require rows to be
|
|
1298
|
+
# returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting
|
|
1299
|
+
# `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval,
|
|
1300
|
+
# resulting in lower latencies in certain cases (for example, bulk point
|
|
1301
|
+
# lookups).
|
|
1302
|
+
# @param lock_hint [::Google::Cloud::Spanner::V1::ReadRequest::LockHint]
|
|
1303
|
+
# Optional. Lock Hint for the request, it can only be used with read-write
|
|
1304
|
+
# transactions.
|
|
1305
|
+
# @param routing_hint [::Google::Cloud::Spanner::V1::RoutingHint, ::Hash]
|
|
1306
|
+
# Optional. Makes the Spanner requests location-aware if present.
|
|
1307
|
+
#
|
|
1308
|
+
# It gives the server hints that can be used to route the request
|
|
1309
|
+
# to an appropriate server, potentially significantly decreasing latency and
|
|
1310
|
+
# improving throughput. To achieve improved performance, most fields must be
|
|
1311
|
+
# filled in with accurate values.
|
|
1312
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
1313
|
+
# @yieldparam result [::Google::Cloud::Spanner::V1::ResultSet]
|
|
1314
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
1315
|
+
#
|
|
1316
|
+
# @return [::Google::Cloud::Spanner::V1::ResultSet]
|
|
1317
|
+
#
|
|
1318
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
1319
|
+
#
|
|
1320
|
+
# @example Basic example
|
|
1321
|
+
# require "google/cloud/spanner/v1"
|
|
1322
|
+
#
|
|
1323
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
1324
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
1325
|
+
#
|
|
1326
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
1327
|
+
# request = Google::Cloud::Spanner::V1::ReadRequest.new
|
|
1328
|
+
#
|
|
1329
|
+
# # Call the read method.
|
|
1330
|
+
# result = client.read request
|
|
1331
|
+
#
|
|
1332
|
+
# # The returned object is of type Google::Cloud::Spanner::V1::ResultSet.
|
|
1333
|
+
# p result
|
|
1334
|
+
#
|
|
1335
|
+
def read request, options = nil
|
|
1336
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
1337
|
+
|
|
1338
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ReadRequest
|
|
1339
|
+
|
|
1340
|
+
# Converts hash and nil to an options object
|
|
1341
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
1342
|
+
|
|
1343
|
+
# Customize the options with defaults
|
|
1344
|
+
call_metadata = @config.rpcs.read.metadata.to_h
|
|
1345
|
+
|
|
1346
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
1347
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
1348
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
1349
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
1350
|
+
transports_version_send: [:rest]
|
|
1351
|
+
|
|
1352
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
1353
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
1354
|
+
|
|
1355
|
+
options.apply_defaults timeout: @config.rpcs.read.timeout,
|
|
1356
|
+
metadata: call_metadata,
|
|
1357
|
+
retry_policy: @config.rpcs.read.retry_policy
|
|
1358
|
+
|
|
1359
|
+
options.apply_defaults timeout: @config.timeout,
|
|
1360
|
+
metadata: @config.metadata,
|
|
1361
|
+
retry_policy: @config.retry_policy
|
|
1362
|
+
|
|
1363
|
+
@spanner_stub.read request, options do |result, operation|
|
|
1364
|
+
yield result, operation if block_given?
|
|
1365
|
+
end
|
|
1366
|
+
rescue ::Gapic::Rest::Error => e
|
|
1367
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
1368
|
+
end
|
|
1369
|
+
|
|
1370
|
+
##
|
|
1371
|
+
# Like {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#read Read}, except returns the result set
|
|
1372
|
+
# as a stream. Unlike {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#read Read}, there is no
|
|
1373
|
+
# limit on the size of the returned result set. However, no individual row in
|
|
1374
|
+
# the result set can exceed 100 MiB, and no column value can exceed
|
|
1375
|
+
# 10 MiB.
|
|
1376
|
+
#
|
|
1377
|
+
# @overload streaming_read(request, options = nil)
|
|
1378
|
+
# Pass arguments to `streaming_read` via a request object, either of type
|
|
1379
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest} or an equivalent Hash.
|
|
1380
|
+
#
|
|
1381
|
+
# @param request [::Google::Cloud::Spanner::V1::ReadRequest, ::Hash]
|
|
1382
|
+
# A request object representing the call parameters. Required. To specify no
|
|
1383
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
1384
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
1385
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
1386
|
+
#
|
|
1387
|
+
# @overload streaming_read(session: nil, transaction: nil, table: nil, index: nil, columns: nil, key_set: nil, limit: nil, resume_token: nil, partition_token: nil, request_options: nil, directed_read_options: nil, data_boost_enabled: nil, order_by: nil, lock_hint: nil, routing_hint: nil)
|
|
1388
|
+
# Pass arguments to `streaming_read` via keyword arguments. Note that at
|
|
1389
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
1390
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
1391
|
+
#
|
|
1392
|
+
# @param session [::String]
|
|
1393
|
+
# Required. The session in which the read should be performed.
|
|
1394
|
+
# @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
|
|
1395
|
+
# The transaction to use. If none is provided, the default is a
|
|
1396
|
+
# temporary read-only transaction with strong concurrency.
|
|
1397
|
+
# @param table [::String]
|
|
1398
|
+
# Required. The name of the table in the database to be read.
|
|
1399
|
+
# @param index [::String]
|
|
1400
|
+
# If non-empty, the name of an index on
|
|
1401
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest#table table}. This index is used instead of
|
|
1402
|
+
# the table primary key when interpreting
|
|
1403
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set} and sorting result rows.
|
|
1404
|
+
# See {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set} for further
|
|
1405
|
+
# information.
|
|
1406
|
+
# @param columns [::Array<::String>]
|
|
1407
|
+
# Required. The columns of {::Google::Cloud::Spanner::V1::ReadRequest#table table} to be
|
|
1408
|
+
# returned for each row matching this request.
|
|
1409
|
+
# @param key_set [::Google::Cloud::Spanner::V1::KeySet, ::Hash]
|
|
1410
|
+
# Required. `key_set` identifies the rows to be yielded. `key_set` names the
|
|
1411
|
+
# primary keys of the rows in {::Google::Cloud::Spanner::V1::ReadRequest#table table} to
|
|
1412
|
+
# be yielded, unless {::Google::Cloud::Spanner::V1::ReadRequest#index index} is present.
|
|
1413
|
+
# If {::Google::Cloud::Spanner::V1::ReadRequest#index index} is present, then
|
|
1414
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set} instead names index keys
|
|
1415
|
+
# in {::Google::Cloud::Spanner::V1::ReadRequest#index index}.
|
|
1416
|
+
#
|
|
1417
|
+
# If the {::Google::Cloud::Spanner::V1::ReadRequest#partition_token partition_token}
|
|
1418
|
+
# field is empty, rows are yielded in table primary key order (if
|
|
1419
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest#index index} is empty) or index key order
|
|
1420
|
+
# (if {::Google::Cloud::Spanner::V1::ReadRequest#index index} is non-empty). If the
|
|
1421
|
+
# {::Google::Cloud::Spanner::V1::ReadRequest#partition_token partition_token} field
|
|
1422
|
+
# isn't empty, rows are yielded in an unspecified order.
|
|
1423
|
+
#
|
|
1424
|
+
# It isn't an error for the `key_set` to name rows that don't
|
|
1425
|
+
# exist in the database. Read yields nothing for nonexistent rows.
|
|
1426
|
+
# @param limit [::Integer]
|
|
1427
|
+
# If greater than zero, only the first `limit` rows are yielded. If `limit`
|
|
1428
|
+
# is zero, the default is no limit. A limit can't be specified if
|
|
1429
|
+
# `partition_token` is set.
|
|
1430
|
+
# @param resume_token [::String]
|
|
1431
|
+
# If this request is resuming a previously interrupted read,
|
|
1432
|
+
# `resume_token` should be copied from the last
|
|
1433
|
+
# {::Google::Cloud::Spanner::V1::PartialResultSet PartialResultSet} yielded before the
|
|
1434
|
+
# interruption. Doing this enables the new read to resume where the last read
|
|
1435
|
+
# left off. The rest of the request parameters must exactly match the request
|
|
1436
|
+
# that yielded this token.
|
|
1437
|
+
# @param partition_token [::String]
|
|
1438
|
+
# If present, results are restricted to the specified partition
|
|
1439
|
+
# previously created using `PartitionRead`. There must be an exact
|
|
1440
|
+
# match for the values of fields common to this message and the
|
|
1441
|
+
# PartitionReadRequest message used to create this partition_token.
|
|
1442
|
+
# @param request_options [::Google::Cloud::Spanner::V1::RequestOptions, ::Hash]
|
|
1443
|
+
# Common options for this request.
|
|
1444
|
+
# @param directed_read_options [::Google::Cloud::Spanner::V1::DirectedReadOptions, ::Hash]
|
|
1445
|
+
# Directed read options for this request.
|
|
1446
|
+
# @param data_boost_enabled [::Boolean]
|
|
1447
|
+
# If this is for a partitioned read and this field is set to `true`, the
|
|
1448
|
+
# request is executed with Spanner Data Boost independent compute resources.
|
|
1449
|
+
#
|
|
1450
|
+
# If the field is set to `true` but the request doesn't set
|
|
1451
|
+
# `partition_token`, the API returns an `INVALID_ARGUMENT` error.
|
|
1452
|
+
# @param order_by [::Google::Cloud::Spanner::V1::ReadRequest::OrderBy]
|
|
1453
|
+
# Optional. Order for the returned rows.
|
|
1454
|
+
#
|
|
1455
|
+
# By default, Spanner returns result rows in primary key order except for
|
|
1456
|
+
# PartitionRead requests. For applications that don't require rows to be
|
|
1457
|
+
# returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting
|
|
1458
|
+
# `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval,
|
|
1459
|
+
# resulting in lower latencies in certain cases (for example, bulk point
|
|
1460
|
+
# lookups).
|
|
1461
|
+
# @param lock_hint [::Google::Cloud::Spanner::V1::ReadRequest::LockHint]
|
|
1462
|
+
# Optional. Lock Hint for the request, it can only be used with read-write
|
|
1463
|
+
# transactions.
|
|
1464
|
+
# @param routing_hint [::Google::Cloud::Spanner::V1::RoutingHint, ::Hash]
|
|
1465
|
+
# Optional. Makes the Spanner requests location-aware if present.
|
|
1466
|
+
#
|
|
1467
|
+
# It gives the server hints that can be used to route the request
|
|
1468
|
+
# to an appropriate server, potentially significantly decreasing latency and
|
|
1469
|
+
# improving throughput. To achieve improved performance, most fields must be
|
|
1470
|
+
# filled in with accurate values.
|
|
1471
|
+
# @return [::Enumerable<::Google::Cloud::Spanner::V1::PartialResultSet>]
|
|
1472
|
+
#
|
|
1473
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
1474
|
+
#
|
|
1475
|
+
# @example Basic example
|
|
1476
|
+
# require "google/cloud/spanner/v1"
|
|
1477
|
+
#
|
|
1478
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
1479
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
1480
|
+
#
|
|
1481
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
1482
|
+
# request = Google::Cloud::Spanner::V1::ReadRequest.new
|
|
1483
|
+
#
|
|
1484
|
+
# # Call the streaming_read method to start streaming.
|
|
1485
|
+
# output = client.streaming_read request
|
|
1486
|
+
#
|
|
1487
|
+
# # The returned object is a streamed enumerable yielding elements of type
|
|
1488
|
+
# # ::Google::Cloud::Spanner::V1::PartialResultSet
|
|
1489
|
+
# output.each do |current_response|
|
|
1490
|
+
# p current_response
|
|
1491
|
+
# end
|
|
1492
|
+
#
|
|
1493
|
+
def streaming_read request, options = nil
|
|
1494
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
1495
|
+
|
|
1496
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ReadRequest
|
|
1497
|
+
|
|
1498
|
+
# Converts hash and nil to an options object
|
|
1499
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
1500
|
+
|
|
1501
|
+
# Customize the options with defaults
|
|
1502
|
+
call_metadata = @config.rpcs.streaming_read.metadata.to_h
|
|
1503
|
+
|
|
1504
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
1505
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
1506
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
1507
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
1508
|
+
transports_version_send: [:rest]
|
|
1509
|
+
|
|
1510
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
1511
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
1512
|
+
|
|
1513
|
+
options.apply_defaults timeout: @config.rpcs.streaming_read.timeout,
|
|
1514
|
+
metadata: call_metadata,
|
|
1515
|
+
retry_policy: @config.rpcs.streaming_read.retry_policy
|
|
1516
|
+
|
|
1517
|
+
options.apply_defaults timeout: @config.timeout,
|
|
1518
|
+
metadata: @config.metadata,
|
|
1519
|
+
retry_policy: @config.retry_policy
|
|
1520
|
+
|
|
1521
|
+
::Gapic::Rest::ServerStream.new(
|
|
1522
|
+
::Google::Cloud::Spanner::V1::PartialResultSet,
|
|
1523
|
+
::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
|
|
1524
|
+
@spanner_stub.streaming_read request, options do |chunk|
|
|
1525
|
+
in_q.deq
|
|
1526
|
+
out_q.enq chunk
|
|
1527
|
+
end
|
|
1528
|
+
end
|
|
1529
|
+
)
|
|
1530
|
+
rescue ::Gapic::Rest::Error => e
|
|
1531
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
1532
|
+
end
|
|
1533
|
+
|
|
1534
|
+
##
|
|
1535
|
+
# Begins a new transaction. This step can often be skipped:
|
|
1536
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#read Read},
|
|
1537
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#execute_sql ExecuteSql} and
|
|
1538
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#commit Commit} can begin a new transaction as a
|
|
1539
|
+
# side-effect.
|
|
1540
|
+
#
|
|
1541
|
+
# @overload begin_transaction(request, options = nil)
|
|
1542
|
+
# Pass arguments to `begin_transaction` via a request object, either of type
|
|
1543
|
+
# {::Google::Cloud::Spanner::V1::BeginTransactionRequest} or an equivalent Hash.
|
|
1544
|
+
#
|
|
1545
|
+
# @param request [::Google::Cloud::Spanner::V1::BeginTransactionRequest, ::Hash]
|
|
1546
|
+
# A request object representing the call parameters. Required. To specify no
|
|
1547
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
1548
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
1549
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
1550
|
+
#
|
|
1551
|
+
# @overload begin_transaction(session: nil, options: nil, request_options: nil, mutation_key: nil, routing_hint: nil)
|
|
1552
|
+
# Pass arguments to `begin_transaction` via keyword arguments. Note that at
|
|
1553
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
1554
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
1555
|
+
#
|
|
1556
|
+
# @param session [::String]
|
|
1557
|
+
# Required. The session in which the transaction runs.
|
|
1558
|
+
# @param options [::Google::Cloud::Spanner::V1::TransactionOptions, ::Hash]
|
|
1559
|
+
# Required. Options for the new transaction.
|
|
1560
|
+
# @param request_options [::Google::Cloud::Spanner::V1::RequestOptions, ::Hash]
|
|
1561
|
+
# Common options for this request.
|
|
1562
|
+
# Priority is ignored for this request. Setting the priority in this
|
|
1563
|
+
# `request_options` struct doesn't do anything. To set the priority for a
|
|
1564
|
+
# transaction, set it on the reads and writes that are part of this
|
|
1565
|
+
# transaction instead.
|
|
1566
|
+
# @param mutation_key [::Google::Cloud::Spanner::V1::Mutation, ::Hash]
|
|
1567
|
+
# Optional. Required for read-write transactions on a multiplexed session
|
|
1568
|
+
# that commit mutations but don't perform any reads or queries. You must
|
|
1569
|
+
# randomly select one of the mutations from the mutation set and send it as a
|
|
1570
|
+
# part of this request.
|
|
1571
|
+
# @param routing_hint [::Google::Cloud::Spanner::V1::RoutingHint, ::Hash]
|
|
1572
|
+
# Optional. Makes the Spanner requests location-aware if present.
|
|
1573
|
+
#
|
|
1574
|
+
# It gives the server hints that can be used to route the request
|
|
1575
|
+
# to an appropriate server, potentially significantly decreasing latency and
|
|
1576
|
+
# improving throughput. To achieve improved performance, most fields must be
|
|
1577
|
+
# filled in with accurate values.
|
|
1578
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
1579
|
+
# @yieldparam result [::Google::Cloud::Spanner::V1::Transaction]
|
|
1580
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
1581
|
+
#
|
|
1582
|
+
# @return [::Google::Cloud::Spanner::V1::Transaction]
|
|
1583
|
+
#
|
|
1584
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
1585
|
+
#
|
|
1586
|
+
# @example Basic example
|
|
1587
|
+
# require "google/cloud/spanner/v1"
|
|
1588
|
+
#
|
|
1589
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
1590
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
1591
|
+
#
|
|
1592
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
1593
|
+
# request = Google::Cloud::Spanner::V1::BeginTransactionRequest.new
|
|
1594
|
+
#
|
|
1595
|
+
# # Call the begin_transaction method.
|
|
1596
|
+
# result = client.begin_transaction request
|
|
1597
|
+
#
|
|
1598
|
+
# # The returned object is of type Google::Cloud::Spanner::V1::Transaction.
|
|
1599
|
+
# p result
|
|
1600
|
+
#
|
|
1601
|
+
def begin_transaction request, options = nil
|
|
1602
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
1603
|
+
|
|
1604
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::BeginTransactionRequest
|
|
1605
|
+
|
|
1606
|
+
# Converts hash and nil to an options object
|
|
1607
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
1608
|
+
|
|
1609
|
+
# Customize the options with defaults
|
|
1610
|
+
call_metadata = @config.rpcs.begin_transaction.metadata.to_h
|
|
1611
|
+
|
|
1612
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
1613
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
1614
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
1615
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
1616
|
+
transports_version_send: [:rest]
|
|
1617
|
+
|
|
1618
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
1619
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
1620
|
+
|
|
1621
|
+
options.apply_defaults timeout: @config.rpcs.begin_transaction.timeout,
|
|
1622
|
+
metadata: call_metadata,
|
|
1623
|
+
retry_policy: @config.rpcs.begin_transaction.retry_policy
|
|
1624
|
+
|
|
1625
|
+
options.apply_defaults timeout: @config.timeout,
|
|
1626
|
+
metadata: @config.metadata,
|
|
1627
|
+
retry_policy: @config.retry_policy
|
|
1628
|
+
|
|
1629
|
+
@spanner_stub.begin_transaction request, options do |result, operation|
|
|
1630
|
+
yield result, operation if block_given?
|
|
1631
|
+
end
|
|
1632
|
+
rescue ::Gapic::Rest::Error => e
|
|
1633
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
1634
|
+
end
|
|
1635
|
+
|
|
1636
|
+
##
|
|
1637
|
+
# Commits a transaction. The request includes the mutations to be
|
|
1638
|
+
# applied to rows in the database.
|
|
1639
|
+
#
|
|
1640
|
+
# `Commit` might return an `ABORTED` error. This can occur at any time;
|
|
1641
|
+
# commonly, the cause is conflicts with concurrent
|
|
1642
|
+
# transactions. However, it can also happen for a variety of other
|
|
1643
|
+
# reasons. If `Commit` returns `ABORTED`, the caller should retry
|
|
1644
|
+
# the transaction from the beginning, reusing the same session.
|
|
1645
|
+
#
|
|
1646
|
+
# On very rare occasions, `Commit` might return `UNKNOWN`. This can happen,
|
|
1647
|
+
# for example, if the client job experiences a 1+ hour networking failure.
|
|
1648
|
+
# At that point, Cloud Spanner has lost track of the transaction outcome and
|
|
1649
|
+
# we recommend that you perform another read from the database to see the
|
|
1650
|
+
# state of things as they are now.
|
|
1651
|
+
#
|
|
1652
|
+
# @overload commit(request, options = nil)
|
|
1653
|
+
# Pass arguments to `commit` via a request object, either of type
|
|
1654
|
+
# {::Google::Cloud::Spanner::V1::CommitRequest} or an equivalent Hash.
|
|
1655
|
+
#
|
|
1656
|
+
# @param request [::Google::Cloud::Spanner::V1::CommitRequest, ::Hash]
|
|
1657
|
+
# A request object representing the call parameters. Required. To specify no
|
|
1658
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
1659
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
1660
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
1661
|
+
#
|
|
1662
|
+
# @overload commit(session: nil, transaction_id: nil, single_use_transaction: nil, mutations: nil, return_commit_stats: nil, max_commit_delay: nil, request_options: nil, precommit_token: nil, routing_hint: nil)
|
|
1663
|
+
# Pass arguments to `commit` via keyword arguments. Note that at
|
|
1664
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
1665
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
1666
|
+
#
|
|
1667
|
+
# @param session [::String]
|
|
1668
|
+
# Required. The session in which the transaction to be committed is running.
|
|
1669
|
+
# @param transaction_id [::String]
|
|
1670
|
+
# Commit a previously-started transaction.
|
|
1671
|
+
#
|
|
1672
|
+
# Note: The following parameters are mutually exclusive: `transaction_id`, `single_use_transaction`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one.
|
|
1673
|
+
# @param single_use_transaction [::Google::Cloud::Spanner::V1::TransactionOptions, ::Hash]
|
|
1674
|
+
# Execute mutations in a temporary transaction. Note that unlike
|
|
1675
|
+
# commit of a previously-started transaction, commit with a
|
|
1676
|
+
# temporary transaction is non-idempotent. That is, if the
|
|
1677
|
+
# `CommitRequest` is sent to Cloud Spanner more than once (for
|
|
1678
|
+
# instance, due to retries in the application, or in the
|
|
1679
|
+
# transport library), it's possible that the mutations are
|
|
1680
|
+
# executed more than once. If this is undesirable, use
|
|
1681
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#begin_transaction BeginTransaction} and
|
|
1682
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#commit Commit} instead.
|
|
1683
|
+
#
|
|
1684
|
+
# Note: The following parameters are mutually exclusive: `single_use_transaction`, `transaction_id`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one.
|
|
1685
|
+
# @param mutations [::Array<::Google::Cloud::Spanner::V1::Mutation, ::Hash>]
|
|
1686
|
+
# The mutations to be executed when this transaction commits. All
|
|
1687
|
+
# mutations are applied atomically, in the order they appear in
|
|
1688
|
+
# this list.
|
|
1689
|
+
# @param return_commit_stats [::Boolean]
|
|
1690
|
+
# If `true`, then statistics related to the transaction is included in
|
|
1691
|
+
# the {::Google::Cloud::Spanner::V1::CommitResponse#commit_stats CommitResponse}.
|
|
1692
|
+
# Default value is `false`.
|
|
1693
|
+
# @param max_commit_delay [::Google::Protobuf::Duration, ::Hash]
|
|
1694
|
+
# Optional. The amount of latency this request is configured to incur in
|
|
1695
|
+
# order to improve throughput. If this field isn't set, Spanner assumes
|
|
1696
|
+
# requests are relatively latency sensitive and automatically determines an
|
|
1697
|
+
# appropriate delay time. You can specify a commit delay value between 0 and
|
|
1698
|
+
# 500 ms.
|
|
1699
|
+
# @param request_options [::Google::Cloud::Spanner::V1::RequestOptions, ::Hash]
|
|
1700
|
+
# Common options for this request.
|
|
1701
|
+
# @param precommit_token [::Google::Cloud::Spanner::V1::MultiplexedSessionPrecommitToken, ::Hash]
|
|
1702
|
+
# Optional. If the read-write transaction was executed on a multiplexed
|
|
1703
|
+
# session, then you must include the precommit token with the highest
|
|
1704
|
+
# sequence number received in this transaction attempt. Failing to do so
|
|
1705
|
+
# results in a `FailedPrecondition` error.
|
|
1706
|
+
# @param routing_hint [::Google::Cloud::Spanner::V1::RoutingHint, ::Hash]
|
|
1707
|
+
# Optional. Makes the Spanner requests location-aware if present.
|
|
1708
|
+
#
|
|
1709
|
+
# It gives the server hints that can be used to route the request
|
|
1710
|
+
# to an appropriate server, potentially significantly decreasing latency and
|
|
1711
|
+
# improving throughput. To achieve improved performance, most fields must be
|
|
1712
|
+
# filled in with accurate values.
|
|
1713
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
1714
|
+
# @yieldparam result [::Google::Cloud::Spanner::V1::CommitResponse]
|
|
1715
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
1716
|
+
#
|
|
1717
|
+
# @return [::Google::Cloud::Spanner::V1::CommitResponse]
|
|
1718
|
+
#
|
|
1719
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
1720
|
+
#
|
|
1721
|
+
# @example Basic example
|
|
1722
|
+
# require "google/cloud/spanner/v1"
|
|
1723
|
+
#
|
|
1724
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
1725
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
1726
|
+
#
|
|
1727
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
1728
|
+
# request = Google::Cloud::Spanner::V1::CommitRequest.new
|
|
1729
|
+
#
|
|
1730
|
+
# # Call the commit method.
|
|
1731
|
+
# result = client.commit request
|
|
1732
|
+
#
|
|
1733
|
+
# # The returned object is of type Google::Cloud::Spanner::V1::CommitResponse.
|
|
1734
|
+
# p result
|
|
1735
|
+
#
|
|
1736
|
+
def commit request, options = nil
|
|
1737
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
1738
|
+
|
|
1739
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::CommitRequest
|
|
1740
|
+
|
|
1741
|
+
# Converts hash and nil to an options object
|
|
1742
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
1743
|
+
|
|
1744
|
+
# Customize the options with defaults
|
|
1745
|
+
call_metadata = @config.rpcs.commit.metadata.to_h
|
|
1746
|
+
|
|
1747
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
1748
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
1749
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
1750
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
1751
|
+
transports_version_send: [:rest]
|
|
1752
|
+
|
|
1753
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
1754
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
1755
|
+
|
|
1756
|
+
options.apply_defaults timeout: @config.rpcs.commit.timeout,
|
|
1757
|
+
metadata: call_metadata,
|
|
1758
|
+
retry_policy: @config.rpcs.commit.retry_policy
|
|
1759
|
+
|
|
1760
|
+
options.apply_defaults timeout: @config.timeout,
|
|
1761
|
+
metadata: @config.metadata,
|
|
1762
|
+
retry_policy: @config.retry_policy
|
|
1763
|
+
|
|
1764
|
+
@spanner_stub.commit request, options do |result, operation|
|
|
1765
|
+
yield result, operation if block_given?
|
|
1766
|
+
end
|
|
1767
|
+
rescue ::Gapic::Rest::Error => e
|
|
1768
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
1769
|
+
end
|
|
1770
|
+
|
|
1771
|
+
##
|
|
1772
|
+
# Rolls back a transaction, releasing any locks it holds. It's a good
|
|
1773
|
+
# idea to call this for any transaction that includes one or more
|
|
1774
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#read Read} or
|
|
1775
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#execute_sql ExecuteSql} requests and ultimately
|
|
1776
|
+
# decides not to commit.
|
|
1777
|
+
#
|
|
1778
|
+
# `Rollback` returns `OK` if it successfully aborts the transaction, the
|
|
1779
|
+
# transaction was already aborted, or the transaction isn't
|
|
1780
|
+
# found. `Rollback` never returns `ABORTED`.
|
|
1781
|
+
#
|
|
1782
|
+
# @overload rollback(request, options = nil)
|
|
1783
|
+
# Pass arguments to `rollback` via a request object, either of type
|
|
1784
|
+
# {::Google::Cloud::Spanner::V1::RollbackRequest} or an equivalent Hash.
|
|
1785
|
+
#
|
|
1786
|
+
# @param request [::Google::Cloud::Spanner::V1::RollbackRequest, ::Hash]
|
|
1787
|
+
# A request object representing the call parameters. Required. To specify no
|
|
1788
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
1789
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
1790
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
1791
|
+
#
|
|
1792
|
+
# @overload rollback(session: nil, transaction_id: nil)
|
|
1793
|
+
# Pass arguments to `rollback` via keyword arguments. Note that at
|
|
1794
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
1795
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
1796
|
+
#
|
|
1797
|
+
# @param session [::String]
|
|
1798
|
+
# Required. The session in which the transaction to roll back is running.
|
|
1799
|
+
# @param transaction_id [::String]
|
|
1800
|
+
# Required. The transaction to roll back.
|
|
1801
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
1802
|
+
# @yieldparam result [::Google::Protobuf::Empty]
|
|
1803
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
1804
|
+
#
|
|
1805
|
+
# @return [::Google::Protobuf::Empty]
|
|
1806
|
+
#
|
|
1807
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
1808
|
+
#
|
|
1809
|
+
# @example Basic example
|
|
1810
|
+
# require "google/cloud/spanner/v1"
|
|
1811
|
+
#
|
|
1812
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
1813
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
1814
|
+
#
|
|
1815
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
1816
|
+
# request = Google::Cloud::Spanner::V1::RollbackRequest.new
|
|
1817
|
+
#
|
|
1818
|
+
# # Call the rollback method.
|
|
1819
|
+
# result = client.rollback request
|
|
1820
|
+
#
|
|
1821
|
+
# # The returned object is of type Google::Protobuf::Empty.
|
|
1822
|
+
# p result
|
|
1823
|
+
#
|
|
1824
|
+
def rollback request, options = nil
|
|
1825
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
1826
|
+
|
|
1827
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::RollbackRequest
|
|
1828
|
+
|
|
1829
|
+
# Converts hash and nil to an options object
|
|
1830
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
1831
|
+
|
|
1832
|
+
# Customize the options with defaults
|
|
1833
|
+
call_metadata = @config.rpcs.rollback.metadata.to_h
|
|
1834
|
+
|
|
1835
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
1836
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
1837
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
1838
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
1839
|
+
transports_version_send: [:rest]
|
|
1840
|
+
|
|
1841
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
1842
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
1843
|
+
|
|
1844
|
+
options.apply_defaults timeout: @config.rpcs.rollback.timeout,
|
|
1845
|
+
metadata: call_metadata,
|
|
1846
|
+
retry_policy: @config.rpcs.rollback.retry_policy
|
|
1847
|
+
|
|
1848
|
+
options.apply_defaults timeout: @config.timeout,
|
|
1849
|
+
metadata: @config.metadata,
|
|
1850
|
+
retry_policy: @config.retry_policy
|
|
1851
|
+
|
|
1852
|
+
@spanner_stub.rollback request, options do |result, operation|
|
|
1853
|
+
yield result, operation if block_given?
|
|
1854
|
+
end
|
|
1855
|
+
rescue ::Gapic::Rest::Error => e
|
|
1856
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
1857
|
+
end
|
|
1858
|
+
|
|
1859
|
+
##
|
|
1860
|
+
# Creates a set of partition tokens that can be used to execute a query
|
|
1861
|
+
# operation in parallel. Each of the returned partition tokens can be used
|
|
1862
|
+
# by {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#execute_streaming_sql ExecuteStreamingSql} to
|
|
1863
|
+
# specify a subset of the query result to read. The same session and
|
|
1864
|
+
# read-only transaction must be used by the `PartitionQueryRequest` used to
|
|
1865
|
+
# create the partition tokens and the `ExecuteSqlRequests` that use the
|
|
1866
|
+
# partition tokens.
|
|
1867
|
+
#
|
|
1868
|
+
# Partition tokens become invalid when the session used to create them
|
|
1869
|
+
# is deleted, is idle for too long, begins a new transaction, or becomes too
|
|
1870
|
+
# old. When any of these happen, it isn't possible to resume the query, and
|
|
1871
|
+
# the whole operation must be restarted from the beginning.
|
|
1872
|
+
#
|
|
1873
|
+
# @overload partition_query(request, options = nil)
|
|
1874
|
+
# Pass arguments to `partition_query` via a request object, either of type
|
|
1875
|
+
# {::Google::Cloud::Spanner::V1::PartitionQueryRequest} or an equivalent Hash.
|
|
1876
|
+
#
|
|
1877
|
+
# @param request [::Google::Cloud::Spanner::V1::PartitionQueryRequest, ::Hash]
|
|
1878
|
+
# A request object representing the call parameters. Required. To specify no
|
|
1879
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
1880
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
1881
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
1882
|
+
#
|
|
1883
|
+
# @overload partition_query(session: nil, transaction: nil, sql: nil, params: nil, param_types: nil, partition_options: nil)
|
|
1884
|
+
# Pass arguments to `partition_query` via keyword arguments. Note that at
|
|
1885
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
1886
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
1887
|
+
#
|
|
1888
|
+
# @param session [::String]
|
|
1889
|
+
# Required. The session used to create the partitions.
|
|
1890
|
+
# @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
|
|
1891
|
+
# Read-only snapshot transactions are supported, read and write and
|
|
1892
|
+
# single-use transactions are not.
|
|
1893
|
+
# @param sql [::String]
|
|
1894
|
+
# Required. The query request to generate partitions for. The request fails
|
|
1895
|
+
# if the query isn't root partitionable. For a query to be root
|
|
1896
|
+
# partitionable, it needs to satisfy a few conditions. For example, if the
|
|
1897
|
+
# query execution plan contains a distributed union operator, then it must be
|
|
1898
|
+
# the first operator in the plan. For more information about other
|
|
1899
|
+
# conditions, see [Read data in
|
|
1900
|
+
# parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel).
|
|
1901
|
+
#
|
|
1902
|
+
# The query request must not contain DML commands, such as `INSERT`,
|
|
1903
|
+
# `UPDATE`, or `DELETE`. Use
|
|
1904
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#execute_streaming_sql `ExecuteStreamingSql`} with
|
|
1905
|
+
# a `PartitionedDml` transaction for large, partition-friendly DML
|
|
1906
|
+
# operations.
|
|
1907
|
+
# @param params [::Google::Protobuf::Struct, ::Hash]
|
|
1908
|
+
# Optional. Parameter names and values that bind to placeholders in the SQL
|
|
1909
|
+
# string.
|
|
1910
|
+
#
|
|
1911
|
+
# A parameter placeholder consists of the `@` character followed by the
|
|
1912
|
+
# parameter name (for example, `@firstName`). Parameter names can contain
|
|
1913
|
+
# letters, numbers, and underscores.
|
|
1914
|
+
#
|
|
1915
|
+
# Parameters can appear anywhere that a literal value is expected. The same
|
|
1916
|
+
# parameter name can be used more than once, for example:
|
|
1917
|
+
#
|
|
1918
|
+
# `"WHERE id > @msg_id AND id < @msg_id + 100"`
|
|
1919
|
+
#
|
|
1920
|
+
# It's an error to execute a SQL statement with unbound parameters.
|
|
1921
|
+
# @param param_types [::Hash{::String => ::Google::Cloud::Spanner::V1::Type, ::Hash}]
|
|
1922
|
+
# Optional. It isn't always possible for Cloud Spanner to infer the right SQL
|
|
1923
|
+
# type from a JSON value. For example, values of type `BYTES` and values of
|
|
1924
|
+
# type `STRING` both appear in
|
|
1925
|
+
# {::Google::Cloud::Spanner::V1::PartitionQueryRequest#params params} as JSON strings.
|
|
1926
|
+
#
|
|
1927
|
+
# In these cases, `param_types` can be used to specify the exact
|
|
1928
|
+
# SQL type for some or all of the SQL query parameters. See the
|
|
1929
|
+
# definition of {::Google::Cloud::Spanner::V1::Type Type} for more information
|
|
1930
|
+
# about SQL types.
|
|
1931
|
+
# @param partition_options [::Google::Cloud::Spanner::V1::PartitionOptions, ::Hash]
|
|
1932
|
+
# Additional options that affect how many partitions are created.
|
|
1933
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
1934
|
+
# @yieldparam result [::Google::Cloud::Spanner::V1::PartitionResponse]
|
|
1935
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
1936
|
+
#
|
|
1937
|
+
# @return [::Google::Cloud::Spanner::V1::PartitionResponse]
|
|
1938
|
+
#
|
|
1939
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
1940
|
+
#
|
|
1941
|
+
# @example Basic example
|
|
1942
|
+
# require "google/cloud/spanner/v1"
|
|
1943
|
+
#
|
|
1944
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
1945
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
1946
|
+
#
|
|
1947
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
1948
|
+
# request = Google::Cloud::Spanner::V1::PartitionQueryRequest.new
|
|
1949
|
+
#
|
|
1950
|
+
# # Call the partition_query method.
|
|
1951
|
+
# result = client.partition_query request
|
|
1952
|
+
#
|
|
1953
|
+
# # The returned object is of type Google::Cloud::Spanner::V1::PartitionResponse.
|
|
1954
|
+
# p result
|
|
1955
|
+
#
|
|
1956
|
+
def partition_query request, options = nil
|
|
1957
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
1958
|
+
|
|
1959
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::PartitionQueryRequest
|
|
1960
|
+
|
|
1961
|
+
# Converts hash and nil to an options object
|
|
1962
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
1963
|
+
|
|
1964
|
+
# Customize the options with defaults
|
|
1965
|
+
call_metadata = @config.rpcs.partition_query.metadata.to_h
|
|
1966
|
+
|
|
1967
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
1968
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
1969
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
1970
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
1971
|
+
transports_version_send: [:rest]
|
|
1972
|
+
|
|
1973
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
1974
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
1975
|
+
|
|
1976
|
+
options.apply_defaults timeout: @config.rpcs.partition_query.timeout,
|
|
1977
|
+
metadata: call_metadata,
|
|
1978
|
+
retry_policy: @config.rpcs.partition_query.retry_policy
|
|
1979
|
+
|
|
1980
|
+
options.apply_defaults timeout: @config.timeout,
|
|
1981
|
+
metadata: @config.metadata,
|
|
1982
|
+
retry_policy: @config.retry_policy
|
|
1983
|
+
|
|
1984
|
+
@spanner_stub.partition_query request, options do |result, operation|
|
|
1985
|
+
yield result, operation if block_given?
|
|
1986
|
+
end
|
|
1987
|
+
rescue ::Gapic::Rest::Error => e
|
|
1988
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
1989
|
+
end
|
|
1990
|
+
|
|
1991
|
+
##
|
|
1992
|
+
# Creates a set of partition tokens that can be used to execute a read
|
|
1993
|
+
# operation in parallel. Each of the returned partition tokens can be used
|
|
1994
|
+
# by {::Google::Cloud::Spanner::V1::Spanner::Rest::Client#streaming_read StreamingRead} to specify a
|
|
1995
|
+
# subset of the read result to read. The same session and read-only
|
|
1996
|
+
# transaction must be used by the `PartitionReadRequest` used to create the
|
|
1997
|
+
# partition tokens and the `ReadRequests` that use the partition tokens.
|
|
1998
|
+
# There are no ordering guarantees on rows returned among the returned
|
|
1999
|
+
# partition tokens, or even within each individual `StreamingRead` call
|
|
2000
|
+
# issued with a `partition_token`.
|
|
2001
|
+
#
|
|
2002
|
+
# Partition tokens become invalid when the session used to create them
|
|
2003
|
+
# is deleted, is idle for too long, begins a new transaction, or becomes too
|
|
2004
|
+
# old. When any of these happen, it isn't possible to resume the read, and
|
|
2005
|
+
# the whole operation must be restarted from the beginning.
|
|
2006
|
+
#
|
|
2007
|
+
# @overload partition_read(request, options = nil)
|
|
2008
|
+
# Pass arguments to `partition_read` via a request object, either of type
|
|
2009
|
+
# {::Google::Cloud::Spanner::V1::PartitionReadRequest} or an equivalent Hash.
|
|
2010
|
+
#
|
|
2011
|
+
# @param request [::Google::Cloud::Spanner::V1::PartitionReadRequest, ::Hash]
|
|
2012
|
+
# A request object representing the call parameters. Required. To specify no
|
|
2013
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
2014
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
2015
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
2016
|
+
#
|
|
2017
|
+
# @overload partition_read(session: nil, transaction: nil, table: nil, index: nil, columns: nil, key_set: nil, partition_options: nil)
|
|
2018
|
+
# Pass arguments to `partition_read` via keyword arguments. Note that at
|
|
2019
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
2020
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
2021
|
+
#
|
|
2022
|
+
# @param session [::String]
|
|
2023
|
+
# Required. The session used to create the partitions.
|
|
2024
|
+
# @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
|
|
2025
|
+
# Read only snapshot transactions are supported, read/write and single use
|
|
2026
|
+
# transactions are not.
|
|
2027
|
+
# @param table [::String]
|
|
2028
|
+
# Required. The name of the table in the database to be read.
|
|
2029
|
+
# @param index [::String]
|
|
2030
|
+
# If non-empty, the name of an index on
|
|
2031
|
+
# {::Google::Cloud::Spanner::V1::PartitionReadRequest#table table}. This index is used
|
|
2032
|
+
# instead of the table primary key when interpreting
|
|
2033
|
+
# {::Google::Cloud::Spanner::V1::PartitionReadRequest#key_set key_set} and sorting
|
|
2034
|
+
# result rows. See {::Google::Cloud::Spanner::V1::PartitionReadRequest#key_set key_set}
|
|
2035
|
+
# for further information.
|
|
2036
|
+
# @param columns [::Array<::String>]
|
|
2037
|
+
# The columns of {::Google::Cloud::Spanner::V1::PartitionReadRequest#table table} to be
|
|
2038
|
+
# returned for each row matching this request.
|
|
2039
|
+
# @param key_set [::Google::Cloud::Spanner::V1::KeySet, ::Hash]
|
|
2040
|
+
# Required. `key_set` identifies the rows to be yielded. `key_set` names the
|
|
2041
|
+
# primary keys of the rows in
|
|
2042
|
+
# {::Google::Cloud::Spanner::V1::PartitionReadRequest#table table} to be yielded, unless
|
|
2043
|
+
# {::Google::Cloud::Spanner::V1::PartitionReadRequest#index index} is present. If
|
|
2044
|
+
# {::Google::Cloud::Spanner::V1::PartitionReadRequest#index index} is present, then
|
|
2045
|
+
# {::Google::Cloud::Spanner::V1::PartitionReadRequest#key_set key_set} instead names
|
|
2046
|
+
# index keys in {::Google::Cloud::Spanner::V1::PartitionReadRequest#index index}.
|
|
2047
|
+
#
|
|
2048
|
+
# It isn't an error for the `key_set` to name rows that don't
|
|
2049
|
+
# exist in the database. Read yields nothing for nonexistent rows.
|
|
2050
|
+
# @param partition_options [::Google::Cloud::Spanner::V1::PartitionOptions, ::Hash]
|
|
2051
|
+
# Additional options that affect how many partitions are created.
|
|
2052
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
2053
|
+
# @yieldparam result [::Google::Cloud::Spanner::V1::PartitionResponse]
|
|
2054
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
2055
|
+
#
|
|
2056
|
+
# @return [::Google::Cloud::Spanner::V1::PartitionResponse]
|
|
2057
|
+
#
|
|
2058
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
2059
|
+
#
|
|
2060
|
+
# @example Basic example
|
|
2061
|
+
# require "google/cloud/spanner/v1"
|
|
2062
|
+
#
|
|
2063
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
2064
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
2065
|
+
#
|
|
2066
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
2067
|
+
# request = Google::Cloud::Spanner::V1::PartitionReadRequest.new
|
|
2068
|
+
#
|
|
2069
|
+
# # Call the partition_read method.
|
|
2070
|
+
# result = client.partition_read request
|
|
2071
|
+
#
|
|
2072
|
+
# # The returned object is of type Google::Cloud::Spanner::V1::PartitionResponse.
|
|
2073
|
+
# p result
|
|
2074
|
+
#
|
|
2075
|
+
def partition_read request, options = nil
|
|
2076
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
2077
|
+
|
|
2078
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::PartitionReadRequest
|
|
2079
|
+
|
|
2080
|
+
# Converts hash and nil to an options object
|
|
2081
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
2082
|
+
|
|
2083
|
+
# Customize the options with defaults
|
|
2084
|
+
call_metadata = @config.rpcs.partition_read.metadata.to_h
|
|
2085
|
+
|
|
2086
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
2087
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
2088
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
2089
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
2090
|
+
transports_version_send: [:rest]
|
|
2091
|
+
|
|
2092
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
2093
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
2094
|
+
|
|
2095
|
+
options.apply_defaults timeout: @config.rpcs.partition_read.timeout,
|
|
2096
|
+
metadata: call_metadata,
|
|
2097
|
+
retry_policy: @config.rpcs.partition_read.retry_policy
|
|
2098
|
+
|
|
2099
|
+
options.apply_defaults timeout: @config.timeout,
|
|
2100
|
+
metadata: @config.metadata,
|
|
2101
|
+
retry_policy: @config.retry_policy
|
|
2102
|
+
|
|
2103
|
+
@spanner_stub.partition_read request, options do |result, operation|
|
|
2104
|
+
yield result, operation if block_given?
|
|
2105
|
+
end
|
|
2106
|
+
rescue ::Gapic::Rest::Error => e
|
|
2107
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
2108
|
+
end
|
|
2109
|
+
|
|
2110
|
+
##
|
|
2111
|
+
# Batches the supplied mutation groups in a collection of efficient
|
|
2112
|
+
# transactions. All mutations in a group are committed atomically. However,
|
|
2113
|
+
# mutations across groups can be committed non-atomically in an unspecified
|
|
2114
|
+
# order and thus, they must be independent of each other. Partial failure is
|
|
2115
|
+
# possible, that is, some groups might have been committed successfully,
|
|
2116
|
+
# while some might have failed. The results of individual batches are
|
|
2117
|
+
# streamed into the response as the batches are applied.
|
|
2118
|
+
#
|
|
2119
|
+
# `BatchWrite` requests are not replay protected, meaning that each mutation
|
|
2120
|
+
# group can be applied more than once. Replays of non-idempotent mutations
|
|
2121
|
+
# can have undesirable effects. For example, replays of an insert mutation
|
|
2122
|
+
# can produce an already exists error or if you use generated or commit
|
|
2123
|
+
# timestamp-based keys, it can result in additional rows being added to the
|
|
2124
|
+
# mutation's table. We recommend structuring your mutation groups to be
|
|
2125
|
+
# idempotent to avoid this issue.
|
|
2126
|
+
#
|
|
2127
|
+
# @overload batch_write(request, options = nil)
|
|
2128
|
+
# Pass arguments to `batch_write` via a request object, either of type
|
|
2129
|
+
# {::Google::Cloud::Spanner::V1::BatchWriteRequest} or an equivalent Hash.
|
|
2130
|
+
#
|
|
2131
|
+
# @param request [::Google::Cloud::Spanner::V1::BatchWriteRequest, ::Hash]
|
|
2132
|
+
# A request object representing the call parameters. Required. To specify no
|
|
2133
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
2134
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
2135
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
2136
|
+
#
|
|
2137
|
+
# @overload batch_write(session: nil, request_options: nil, mutation_groups: nil, exclude_txn_from_change_streams: nil)
|
|
2138
|
+
# Pass arguments to `batch_write` via keyword arguments. Note that at
|
|
2139
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
2140
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
2141
|
+
#
|
|
2142
|
+
# @param session [::String]
|
|
2143
|
+
# Required. The session in which the batch request is to be run.
|
|
2144
|
+
# @param request_options [::Google::Cloud::Spanner::V1::RequestOptions, ::Hash]
|
|
2145
|
+
# Common options for this request.
|
|
2146
|
+
# @param mutation_groups [::Array<::Google::Cloud::Spanner::V1::BatchWriteRequest::MutationGroup, ::Hash>]
|
|
2147
|
+
# Required. The groups of mutations to be applied.
|
|
2148
|
+
# @param exclude_txn_from_change_streams [::Boolean]
|
|
2149
|
+
# Optional. If you don't set the `exclude_txn_from_change_streams` option or
|
|
2150
|
+
# if it's set to `false`, then any change streams monitoring columns modified
|
|
2151
|
+
# by transactions will capture the updates made within that transaction.
|
|
2152
|
+
# @return [::Enumerable<::Google::Cloud::Spanner::V1::BatchWriteResponse>]
|
|
2153
|
+
#
|
|
2154
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
2155
|
+
#
|
|
2156
|
+
# @example Basic example
|
|
2157
|
+
# require "google/cloud/spanner/v1"
|
|
2158
|
+
#
|
|
2159
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
2160
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
2161
|
+
#
|
|
2162
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
2163
|
+
# request = Google::Cloud::Spanner::V1::BatchWriteRequest.new
|
|
2164
|
+
#
|
|
2165
|
+
# # Call the batch_write method to start streaming.
|
|
2166
|
+
# output = client.batch_write request
|
|
2167
|
+
#
|
|
2168
|
+
# # The returned object is a streamed enumerable yielding elements of type
|
|
2169
|
+
# # ::Google::Cloud::Spanner::V1::BatchWriteResponse
|
|
2170
|
+
# output.each do |current_response|
|
|
2171
|
+
# p current_response
|
|
2172
|
+
# end
|
|
2173
|
+
#
|
|
2174
|
+
def batch_write request, options = nil
|
|
2175
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
2176
|
+
|
|
2177
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::BatchWriteRequest
|
|
2178
|
+
|
|
2179
|
+
# Converts hash and nil to an options object
|
|
2180
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
2181
|
+
|
|
2182
|
+
# Customize the options with defaults
|
|
2183
|
+
call_metadata = @config.rpcs.batch_write.metadata.to_h
|
|
2184
|
+
|
|
2185
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
2186
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
2187
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
2188
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
2189
|
+
transports_version_send: [:rest]
|
|
2190
|
+
|
|
2191
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
2192
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
2193
|
+
|
|
2194
|
+
options.apply_defaults timeout: @config.rpcs.batch_write.timeout,
|
|
2195
|
+
metadata: call_metadata,
|
|
2196
|
+
retry_policy: @config.rpcs.batch_write.retry_policy
|
|
2197
|
+
|
|
2198
|
+
options.apply_defaults timeout: @config.timeout,
|
|
2199
|
+
metadata: @config.metadata,
|
|
2200
|
+
retry_policy: @config.retry_policy
|
|
2201
|
+
|
|
2202
|
+
::Gapic::Rest::ServerStream.new(
|
|
2203
|
+
::Google::Cloud::Spanner::V1::BatchWriteResponse,
|
|
2204
|
+
::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
|
|
2205
|
+
@spanner_stub.batch_write request, options do |chunk|
|
|
2206
|
+
in_q.deq
|
|
2207
|
+
out_q.enq chunk
|
|
2208
|
+
end
|
|
2209
|
+
end
|
|
2210
|
+
)
|
|
2211
|
+
rescue ::Gapic::Rest::Error => e
|
|
2212
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
2213
|
+
end
|
|
2214
|
+
|
|
2215
|
+
##
|
|
2216
|
+
# Retrieves a cache update for a given database.
|
|
2217
|
+
#
|
|
2218
|
+
# This RPC can be used to warm up the client cache by fetching key recipes
|
|
2219
|
+
# and server information for a given database. It is recommended to call
|
|
2220
|
+
# this RPC at the beginning of the client's lifecycle, prior to any other
|
|
2221
|
+
# data plane operations.
|
|
2222
|
+
#
|
|
2223
|
+
# The cache update is returned as a stream because the response can be too
|
|
2224
|
+
# large to fit into a single `CacheUpdate` message.
|
|
2225
|
+
#
|
|
2226
|
+
# @overload fetch_cache_update(request, options = nil)
|
|
2227
|
+
# Pass arguments to `fetch_cache_update` via a request object, either of type
|
|
2228
|
+
# {::Google::Cloud::Spanner::V1::FetchCacheUpdateRequest} or an equivalent Hash.
|
|
2229
|
+
#
|
|
2230
|
+
# @param request [::Google::Cloud::Spanner::V1::FetchCacheUpdateRequest, ::Hash]
|
|
2231
|
+
# A request object representing the call parameters. Required. To specify no
|
|
2232
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
2233
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
2234
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
2235
|
+
#
|
|
2236
|
+
# @overload fetch_cache_update(database: nil, max_recipe_count: nil, max_range_count: nil)
|
|
2237
|
+
# Pass arguments to `fetch_cache_update` via keyword arguments. Note that at
|
|
2238
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
2239
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
2240
|
+
#
|
|
2241
|
+
# @param database [::String]
|
|
2242
|
+
# Required. The database for which to retrieve the cache update.
|
|
2243
|
+
# @param max_recipe_count [::Integer]
|
|
2244
|
+
# Optional. The maximum number of key recipes to return in the response.
|
|
2245
|
+
# If not set, a default limit of 100 will be used.
|
|
2246
|
+
# @param max_range_count [::Integer]
|
|
2247
|
+
# Optional. The maximum number of ranges to return in the response.
|
|
2248
|
+
# If not set, a default limit of 10000 will be used.
|
|
2249
|
+
# @return [::Enumerable<::Google::Cloud::Spanner::V1::CacheUpdate>]
|
|
2250
|
+
#
|
|
2251
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
2252
|
+
#
|
|
2253
|
+
# @example Basic example
|
|
2254
|
+
# require "google/cloud/spanner/v1"
|
|
2255
|
+
#
|
|
2256
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
2257
|
+
# client = Google::Cloud::Spanner::V1::Spanner::Rest::Client.new
|
|
2258
|
+
#
|
|
2259
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
2260
|
+
# request = Google::Cloud::Spanner::V1::FetchCacheUpdateRequest.new
|
|
2261
|
+
#
|
|
2262
|
+
# # Call the fetch_cache_update method to start streaming.
|
|
2263
|
+
# output = client.fetch_cache_update request
|
|
2264
|
+
#
|
|
2265
|
+
# # The returned object is a streamed enumerable yielding elements of type
|
|
2266
|
+
# # ::Google::Cloud::Spanner::V1::CacheUpdate
|
|
2267
|
+
# output.each do |current_response|
|
|
2268
|
+
# p current_response
|
|
2269
|
+
# end
|
|
2270
|
+
#
|
|
2271
|
+
def fetch_cache_update request, options = nil
|
|
2272
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
2273
|
+
|
|
2274
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::FetchCacheUpdateRequest
|
|
2275
|
+
|
|
2276
|
+
# Converts hash and nil to an options object
|
|
2277
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
2278
|
+
|
|
2279
|
+
# Customize the options with defaults
|
|
2280
|
+
call_metadata = @config.rpcs.fetch_cache_update.metadata.to_h
|
|
2281
|
+
|
|
2282
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
2283
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
2284
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
2285
|
+
gapic_version: ::Google::Cloud::Spanner::V1::VERSION,
|
|
2286
|
+
transports_version_send: [:rest]
|
|
2287
|
+
|
|
2288
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
2289
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
2290
|
+
|
|
2291
|
+
options.apply_defaults timeout: @config.rpcs.fetch_cache_update.timeout,
|
|
2292
|
+
metadata: call_metadata,
|
|
2293
|
+
retry_policy: @config.rpcs.fetch_cache_update.retry_policy
|
|
2294
|
+
|
|
2295
|
+
options.apply_defaults timeout: @config.timeout,
|
|
2296
|
+
metadata: @config.metadata,
|
|
2297
|
+
retry_policy: @config.retry_policy
|
|
2298
|
+
|
|
2299
|
+
::Gapic::Rest::ServerStream.new(
|
|
2300
|
+
::Google::Cloud::Spanner::V1::CacheUpdate,
|
|
2301
|
+
::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
|
|
2302
|
+
@spanner_stub.fetch_cache_update request, options do |chunk|
|
|
2303
|
+
in_q.deq
|
|
2304
|
+
out_q.enq chunk
|
|
2305
|
+
end
|
|
2306
|
+
end
|
|
2307
|
+
)
|
|
2308
|
+
rescue ::Gapic::Rest::Error => e
|
|
2309
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
2310
|
+
end
|
|
2311
|
+
|
|
2312
|
+
##
|
|
2313
|
+
# Configuration class for the Spanner REST API.
|
|
2314
|
+
#
|
|
2315
|
+
# This class represents the configuration for Spanner REST,
|
|
2316
|
+
# providing control over timeouts, retry behavior, logging, transport
|
|
2317
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
|
2318
|
+
# applied individually to specific RPCs. See
|
|
2319
|
+
# {::Google::Cloud::Spanner::V1::Spanner::Rest::Client::Configuration::Rpcs}
|
|
2320
|
+
# for a list of RPCs that can be configured independently.
|
|
2321
|
+
#
|
|
2322
|
+
# Configuration can be applied globally to all clients, or to a single client
|
|
2323
|
+
# on construction.
|
|
2324
|
+
#
|
|
2325
|
+
# @example
|
|
2326
|
+
#
|
|
2327
|
+
# # Modify the global config, setting the timeout for
|
|
2328
|
+
# # create_session to 20 seconds,
|
|
2329
|
+
# # and all remaining timeouts to 10 seconds.
|
|
2330
|
+
# ::Google::Cloud::Spanner::V1::Spanner::Rest::Client.configure do |config|
|
|
2331
|
+
# config.timeout = 10.0
|
|
2332
|
+
# config.rpcs.create_session.timeout = 20.0
|
|
2333
|
+
# end
|
|
2334
|
+
#
|
|
2335
|
+
# # Apply the above configuration only to a new client.
|
|
2336
|
+
# client = ::Google::Cloud::Spanner::V1::Spanner::Rest::Client.new do |config|
|
|
2337
|
+
# config.timeout = 10.0
|
|
2338
|
+
# config.rpcs.create_session.timeout = 20.0
|
|
2339
|
+
# end
|
|
2340
|
+
#
|
|
2341
|
+
# @!attribute [rw] endpoint
|
|
2342
|
+
# A custom service endpoint, as a hostname or hostname:port. The default is
|
|
2343
|
+
# nil, indicating to use the default endpoint in the current universe domain.
|
|
2344
|
+
# @return [::String,nil]
|
|
2345
|
+
# @!attribute [rw] credentials
|
|
2346
|
+
# Credentials to send with calls. You may provide any of the following types:
|
|
2347
|
+
# * (`String`) The path to a service account key file in JSON format
|
|
2348
|
+
# * (`Hash`) A service account key as a Hash
|
|
2349
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
|
2350
|
+
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
|
|
2351
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
|
2352
|
+
# (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
|
|
2353
|
+
# * (`nil`) indicating no credentials
|
|
2354
|
+
#
|
|
2355
|
+
# Warning: If you accept a credential configuration (JSON file or Hash) from an
|
|
2356
|
+
# external source for authentication to Google Cloud, you must validate it before
|
|
2357
|
+
# providing it to a Google API client library. Providing an unvalidated credential
|
|
2358
|
+
# configuration to Google APIs can compromise the security of your systems and data.
|
|
2359
|
+
# For more information, refer to [Validate credential configurations from external
|
|
2360
|
+
# sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
|
|
2361
|
+
# @return [::Object]
|
|
2362
|
+
# @!attribute [rw] scope
|
|
2363
|
+
# The OAuth scopes
|
|
2364
|
+
# @return [::Array<::String>]
|
|
2365
|
+
# @!attribute [rw] lib_name
|
|
2366
|
+
# The library name as recorded in instrumentation and logging
|
|
2367
|
+
# @return [::String]
|
|
2368
|
+
# @!attribute [rw] lib_version
|
|
2369
|
+
# The library version as recorded in instrumentation and logging
|
|
2370
|
+
# @return [::String]
|
|
2371
|
+
# @!attribute [rw] timeout
|
|
2372
|
+
# The call timeout in seconds.
|
|
2373
|
+
# @return [::Numeric]
|
|
2374
|
+
# @!attribute [rw] metadata
|
|
2375
|
+
# Additional headers to be sent with the call.
|
|
2376
|
+
# @return [::Hash{::Symbol=>::String}]
|
|
2377
|
+
# @!attribute [rw] retry_policy
|
|
2378
|
+
# The retry policy. The value is a hash with the following keys:
|
|
2379
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
|
2380
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
|
2381
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
|
2382
|
+
# * `:jitter` (*type:* `Numeric`) - The jitter in seconds. Default: 1.0.
|
|
2383
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
|
2384
|
+
# trigger a retry.
|
|
2385
|
+
# @return [::Hash]
|
|
2386
|
+
# @!attribute [rw] quota_project
|
|
2387
|
+
# A separate project against which to charge quota.
|
|
2388
|
+
# @return [::String]
|
|
2389
|
+
# @!attribute [rw] universe_domain
|
|
2390
|
+
# The universe domain within which to make requests. This determines the
|
|
2391
|
+
# default endpoint URL. The default value of nil uses the environment
|
|
2392
|
+
# universe (usually the default "googleapis.com" universe).
|
|
2393
|
+
# @return [::String,nil]
|
|
2394
|
+
# @!attribute [rw] logger
|
|
2395
|
+
# A custom logger to use for request/response debug logging, or the value
|
|
2396
|
+
# `:default` (the default) to construct a default logger, or `nil` to
|
|
2397
|
+
# explicitly disable logging.
|
|
2398
|
+
# @return [::Logger,:default,nil]
|
|
2399
|
+
#
|
|
2400
|
+
class Configuration
|
|
2401
|
+
extend ::Gapic::Config
|
|
2402
|
+
|
|
2403
|
+
# @private
|
|
2404
|
+
# The endpoint specific to the default "googleapis.com" universe. Deprecated.
|
|
2405
|
+
DEFAULT_ENDPOINT = "spanner.googleapis.com"
|
|
2406
|
+
|
|
2407
|
+
config_attr :endpoint, nil, ::String, nil
|
|
2408
|
+
config_attr :credentials, nil do |value|
|
|
2409
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
|
|
2410
|
+
allowed.any? { |klass| klass === value }
|
|
2411
|
+
end
|
|
2412
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
|
2413
|
+
config_attr :lib_name, nil, ::String, nil
|
|
2414
|
+
config_attr :lib_version, nil, ::String, nil
|
|
2415
|
+
config_attr :timeout, nil, ::Numeric, nil
|
|
2416
|
+
config_attr :metadata, nil, ::Hash, nil
|
|
2417
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
|
2418
|
+
config_attr :quota_project, nil, ::String, nil
|
|
2419
|
+
config_attr :universe_domain, nil, ::String, nil
|
|
2420
|
+
config_attr :logger, :default, ::Logger, nil, :default
|
|
2421
|
+
|
|
2422
|
+
# @private
|
|
2423
|
+
def initialize parent_config = nil
|
|
2424
|
+
@parent_config = parent_config unless parent_config.nil?
|
|
2425
|
+
|
|
2426
|
+
yield self if block_given?
|
|
2427
|
+
end
|
|
2428
|
+
|
|
2429
|
+
##
|
|
2430
|
+
# Configurations for individual RPCs
|
|
2431
|
+
# @return [Rpcs]
|
|
2432
|
+
#
|
|
2433
|
+
def rpcs
|
|
2434
|
+
@rpcs ||= begin
|
|
2435
|
+
parent_rpcs = nil
|
|
2436
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
|
2437
|
+
Rpcs.new parent_rpcs
|
|
2438
|
+
end
|
|
2439
|
+
end
|
|
2440
|
+
|
|
2441
|
+
##
|
|
2442
|
+
# Configuration RPC class for the Spanner API.
|
|
2443
|
+
#
|
|
2444
|
+
# Includes fields providing the configuration for each RPC in this service.
|
|
2445
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
|
2446
|
+
# the following configuration fields:
|
|
2447
|
+
#
|
|
2448
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
|
2449
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
|
|
2450
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
|
2451
|
+
# include the following keys:
|
|
2452
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
|
2453
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
|
2454
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
|
2455
|
+
# * `:jitter` (*type:* `Numeric`) - The jitter in seconds. Default: 1.0.
|
|
2456
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
|
2457
|
+
# trigger a retry.
|
|
2458
|
+
#
|
|
2459
|
+
class Rpcs
|
|
2460
|
+
##
|
|
2461
|
+
# RPC-specific configuration for `create_session`
|
|
2462
|
+
# @return [::Gapic::Config::Method]
|
|
2463
|
+
#
|
|
2464
|
+
attr_reader :create_session
|
|
2465
|
+
##
|
|
2466
|
+
# RPC-specific configuration for `batch_create_sessions`
|
|
2467
|
+
# @return [::Gapic::Config::Method]
|
|
2468
|
+
#
|
|
2469
|
+
attr_reader :batch_create_sessions
|
|
2470
|
+
##
|
|
2471
|
+
# RPC-specific configuration for `get_session`
|
|
2472
|
+
# @return [::Gapic::Config::Method]
|
|
2473
|
+
#
|
|
2474
|
+
attr_reader :get_session
|
|
2475
|
+
##
|
|
2476
|
+
# RPC-specific configuration for `list_sessions`
|
|
2477
|
+
# @return [::Gapic::Config::Method]
|
|
2478
|
+
#
|
|
2479
|
+
attr_reader :list_sessions
|
|
2480
|
+
##
|
|
2481
|
+
# RPC-specific configuration for `delete_session`
|
|
2482
|
+
# @return [::Gapic::Config::Method]
|
|
2483
|
+
#
|
|
2484
|
+
attr_reader :delete_session
|
|
2485
|
+
##
|
|
2486
|
+
# RPC-specific configuration for `execute_sql`
|
|
2487
|
+
# @return [::Gapic::Config::Method]
|
|
2488
|
+
#
|
|
2489
|
+
attr_reader :execute_sql
|
|
2490
|
+
##
|
|
2491
|
+
# RPC-specific configuration for `execute_streaming_sql`
|
|
2492
|
+
# @return [::Gapic::Config::Method]
|
|
2493
|
+
#
|
|
2494
|
+
attr_reader :execute_streaming_sql
|
|
2495
|
+
##
|
|
2496
|
+
# RPC-specific configuration for `execute_batch_dml`
|
|
2497
|
+
# @return [::Gapic::Config::Method]
|
|
2498
|
+
#
|
|
2499
|
+
attr_reader :execute_batch_dml
|
|
2500
|
+
##
|
|
2501
|
+
# RPC-specific configuration for `read`
|
|
2502
|
+
# @return [::Gapic::Config::Method]
|
|
2503
|
+
#
|
|
2504
|
+
attr_reader :read
|
|
2505
|
+
##
|
|
2506
|
+
# RPC-specific configuration for `streaming_read`
|
|
2507
|
+
# @return [::Gapic::Config::Method]
|
|
2508
|
+
#
|
|
2509
|
+
attr_reader :streaming_read
|
|
2510
|
+
##
|
|
2511
|
+
# RPC-specific configuration for `begin_transaction`
|
|
2512
|
+
# @return [::Gapic::Config::Method]
|
|
2513
|
+
#
|
|
2514
|
+
attr_reader :begin_transaction
|
|
2515
|
+
##
|
|
2516
|
+
# RPC-specific configuration for `commit`
|
|
2517
|
+
# @return [::Gapic::Config::Method]
|
|
2518
|
+
#
|
|
2519
|
+
attr_reader :commit
|
|
2520
|
+
##
|
|
2521
|
+
# RPC-specific configuration for `rollback`
|
|
2522
|
+
# @return [::Gapic::Config::Method]
|
|
2523
|
+
#
|
|
2524
|
+
attr_reader :rollback
|
|
2525
|
+
##
|
|
2526
|
+
# RPC-specific configuration for `partition_query`
|
|
2527
|
+
# @return [::Gapic::Config::Method]
|
|
2528
|
+
#
|
|
2529
|
+
attr_reader :partition_query
|
|
2530
|
+
##
|
|
2531
|
+
# RPC-specific configuration for `partition_read`
|
|
2532
|
+
# @return [::Gapic::Config::Method]
|
|
2533
|
+
#
|
|
2534
|
+
attr_reader :partition_read
|
|
2535
|
+
##
|
|
2536
|
+
# RPC-specific configuration for `batch_write`
|
|
2537
|
+
# @return [::Gapic::Config::Method]
|
|
2538
|
+
#
|
|
2539
|
+
attr_reader :batch_write
|
|
2540
|
+
##
|
|
2541
|
+
# RPC-specific configuration for `fetch_cache_update`
|
|
2542
|
+
# @return [::Gapic::Config::Method]
|
|
2543
|
+
#
|
|
2544
|
+
attr_reader :fetch_cache_update
|
|
2545
|
+
|
|
2546
|
+
# @private
|
|
2547
|
+
def initialize parent_rpcs = nil
|
|
2548
|
+
create_session_config = parent_rpcs.create_session if parent_rpcs.respond_to? :create_session
|
|
2549
|
+
@create_session = ::Gapic::Config::Method.new create_session_config
|
|
2550
|
+
batch_create_sessions_config = parent_rpcs.batch_create_sessions if parent_rpcs.respond_to? :batch_create_sessions
|
|
2551
|
+
@batch_create_sessions = ::Gapic::Config::Method.new batch_create_sessions_config
|
|
2552
|
+
get_session_config = parent_rpcs.get_session if parent_rpcs.respond_to? :get_session
|
|
2553
|
+
@get_session = ::Gapic::Config::Method.new get_session_config
|
|
2554
|
+
list_sessions_config = parent_rpcs.list_sessions if parent_rpcs.respond_to? :list_sessions
|
|
2555
|
+
@list_sessions = ::Gapic::Config::Method.new list_sessions_config
|
|
2556
|
+
delete_session_config = parent_rpcs.delete_session if parent_rpcs.respond_to? :delete_session
|
|
2557
|
+
@delete_session = ::Gapic::Config::Method.new delete_session_config
|
|
2558
|
+
execute_sql_config = parent_rpcs.execute_sql if parent_rpcs.respond_to? :execute_sql
|
|
2559
|
+
@execute_sql = ::Gapic::Config::Method.new execute_sql_config
|
|
2560
|
+
execute_streaming_sql_config = parent_rpcs.execute_streaming_sql if parent_rpcs.respond_to? :execute_streaming_sql
|
|
2561
|
+
@execute_streaming_sql = ::Gapic::Config::Method.new execute_streaming_sql_config
|
|
2562
|
+
execute_batch_dml_config = parent_rpcs.execute_batch_dml if parent_rpcs.respond_to? :execute_batch_dml
|
|
2563
|
+
@execute_batch_dml = ::Gapic::Config::Method.new execute_batch_dml_config
|
|
2564
|
+
read_config = parent_rpcs.read if parent_rpcs.respond_to? :read
|
|
2565
|
+
@read = ::Gapic::Config::Method.new read_config
|
|
2566
|
+
streaming_read_config = parent_rpcs.streaming_read if parent_rpcs.respond_to? :streaming_read
|
|
2567
|
+
@streaming_read = ::Gapic::Config::Method.new streaming_read_config
|
|
2568
|
+
begin_transaction_config = parent_rpcs.begin_transaction if parent_rpcs.respond_to? :begin_transaction
|
|
2569
|
+
@begin_transaction = ::Gapic::Config::Method.new begin_transaction_config
|
|
2570
|
+
commit_config = parent_rpcs.commit if parent_rpcs.respond_to? :commit
|
|
2571
|
+
@commit = ::Gapic::Config::Method.new commit_config
|
|
2572
|
+
rollback_config = parent_rpcs.rollback if parent_rpcs.respond_to? :rollback
|
|
2573
|
+
@rollback = ::Gapic::Config::Method.new rollback_config
|
|
2574
|
+
partition_query_config = parent_rpcs.partition_query if parent_rpcs.respond_to? :partition_query
|
|
2575
|
+
@partition_query = ::Gapic::Config::Method.new partition_query_config
|
|
2576
|
+
partition_read_config = parent_rpcs.partition_read if parent_rpcs.respond_to? :partition_read
|
|
2577
|
+
@partition_read = ::Gapic::Config::Method.new partition_read_config
|
|
2578
|
+
batch_write_config = parent_rpcs.batch_write if parent_rpcs.respond_to? :batch_write
|
|
2579
|
+
@batch_write = ::Gapic::Config::Method.new batch_write_config
|
|
2580
|
+
fetch_cache_update_config = parent_rpcs.fetch_cache_update if parent_rpcs.respond_to? :fetch_cache_update
|
|
2581
|
+
@fetch_cache_update = ::Gapic::Config::Method.new fetch_cache_update_config
|
|
2582
|
+
|
|
2583
|
+
yield self if block_given?
|
|
2584
|
+
end
|
|
2585
|
+
end
|
|
2586
|
+
end
|
|
2587
|
+
end
|
|
2588
|
+
end
|
|
2589
|
+
end
|
|
2590
|
+
end
|
|
2591
|
+
end
|
|
2592
|
+
end
|
|
2593
|
+
end
|