google-cloud-spanner-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +203 -0
  5. data/README.md +75 -0
  6. data/lib/google-cloud-spanner-v1.rb +21 -0
  7. data/lib/google/cloud/spanner/v1.rb +35 -0
  8. data/lib/google/cloud/spanner/v1/spanner.rb +52 -0
  9. data/lib/google/cloud/spanner/v1/spanner/client.rb +1947 -0
  10. data/lib/google/cloud/spanner/v1/spanner/credentials.rb +52 -0
  11. data/lib/google/cloud/spanner/v1/spanner/paths.rb +73 -0
  12. data/lib/google/cloud/spanner/v1/version.rb +28 -0
  13. data/lib/google/spanner/v1/keys_pb.rb +37 -0
  14. data/lib/google/spanner/v1/mutation_pb.rb +42 -0
  15. data/lib/google/spanner/v1/query_plan_pb.rb +51 -0
  16. data/lib/google/spanner/v1/result_set_pb.rb +51 -0
  17. data/lib/google/spanner/v1/spanner_pb.rb +182 -0
  18. data/lib/google/spanner/v1/spanner_services_pb.rb +180 -0
  19. data/lib/google/spanner/v1/transaction_pb.rb +59 -0
  20. data/lib/google/spanner/v1/type_pb.rb +47 -0
  21. data/proto_docs/README.md +4 -0
  22. data/proto_docs/google/api/field_behavior.rb +59 -0
  23. data/proto_docs/google/api/resource.rb +247 -0
  24. data/proto_docs/google/protobuf/any.rb +138 -0
  25. data/proto_docs/google/protobuf/duration.rb +98 -0
  26. data/proto_docs/google/protobuf/empty.rb +36 -0
  27. data/proto_docs/google/protobuf/struct.rb +96 -0
  28. data/proto_docs/google/protobuf/timestamp.rb +120 -0
  29. data/proto_docs/google/rpc/status.rb +46 -0
  30. data/proto_docs/google/spanner/v1/keys.rb +162 -0
  31. data/proto_docs/google/spanner/v1/mutation.rb +110 -0
  32. data/proto_docs/google/spanner/v1/query_plan.rb +148 -0
  33. data/proto_docs/google/spanner/v1/result_set.rb +208 -0
  34. data/proto_docs/google/spanner/v1/spanner.rb +681 -0
  35. data/proto_docs/google/spanner/v1/transaction.rb +457 -0
  36. data/proto_docs/google/spanner/v1/type.rb +127 -0
  37. metadata +218 -0
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/spanner/v1"
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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/spanner/v1/spanner"
20
+ require "google/cloud/spanner/v1/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Spanner
25
+ ##
26
+ # To load this package, including all its services, and instantiate a client:
27
+ #
28
+ # require "google/cloud/spanner/v1"
29
+ # client = ::Google::Cloud::Spanner::V1::Spanner::Client.new
30
+ #
31
+ module V1
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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 "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/spanner/v1/version"
24
+
25
+ require "google/cloud/spanner/v1/spanner/credentials"
26
+ require "google/cloud/spanner/v1/spanner/paths"
27
+ require "google/cloud/spanner/v1/spanner/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Spanner
32
+ module V1
33
+ ##
34
+ # Cloud Spanner API
35
+ #
36
+ # The Cloud Spanner API can be used to manage sessions and execute
37
+ # transactions on data stored in Cloud Spanner databases.
38
+ #
39
+ # To load this service and instantiate a client:
40
+ #
41
+ # require "google/cloud/spanner/v1/spanner"
42
+ # client = ::Google::Cloud::Spanner::V1::Spanner::Client.new
43
+ #
44
+ module Spanner
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ helper_path = ::File.join __dir__, "spanner", "helpers.rb"
52
+ require "google/cloud/spanner/v1/spanner/helpers" if ::File.file? helper_path
@@ -0,0 +1,1947 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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
+
22
+ module Google
23
+ module Cloud
24
+ module Spanner
25
+ module V1
26
+ module Spanner
27
+ ##
28
+ # Client for the Spanner service.
29
+ #
30
+ # Cloud Spanner API
31
+ #
32
+ # The Cloud Spanner API can be used to manage sessions and execute
33
+ # transactions on data stored in Cloud Spanner databases.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :spanner_stub
40
+
41
+ ##
42
+ # Configure the Spanner Client class.
43
+ #
44
+ # See {::Google::Cloud::Spanner::V1::Spanner::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # ## Example
48
+ #
49
+ # To modify the configuration for all Spanner clients:
50
+ #
51
+ # ::Google::Cloud::Spanner::V1::Spanner::Client.configure do |config|
52
+ # config.timeout = 10.0
53
+ # end
54
+ #
55
+ # @yield [config] Configure the Client client.
56
+ # @yieldparam config [Client::Configuration]
57
+ #
58
+ # @return [Client::Configuration]
59
+ #
60
+ def self.configure
61
+ @configure ||= begin
62
+ namespace = ["Google", "Cloud", "Spanner", "V1"]
63
+ parent_config = while namespace.any?
64
+ parent_name = namespace.join "::"
65
+ parent_const = const_get parent_name
66
+ break parent_const.configure if parent_const&.respond_to? :configure
67
+ namespace.pop
68
+ end
69
+ default_config = Client::Configuration.new parent_config
70
+
71
+ default_config.rpcs.create_session.timeout = 30.0
72
+ default_config.rpcs.create_session.retry_policy = {
73
+ initial_delay: 0.25,
74
+ max_delay: 32.0,
75
+ multiplier: 1.3,
76
+ retry_codes: ["UNAVAILABLE"]
77
+ }
78
+
79
+ default_config.rpcs.batch_create_sessions.timeout = 60.0
80
+ default_config.rpcs.batch_create_sessions.retry_policy = {
81
+ initial_delay: 0.25,
82
+ max_delay: 32.0,
83
+ multiplier: 1.3,
84
+ retry_codes: ["UNAVAILABLE"]
85
+ }
86
+
87
+ default_config.rpcs.get_session.timeout = 30.0
88
+ default_config.rpcs.get_session.retry_policy = {
89
+ initial_delay: 0.25,
90
+ max_delay: 32.0,
91
+ multiplier: 1.3,
92
+ retry_codes: ["UNAVAILABLE"]
93
+ }
94
+
95
+ default_config.rpcs.list_sessions.timeout = 3600.0
96
+ default_config.rpcs.list_sessions.retry_policy = {
97
+ initial_delay: 0.25,
98
+ max_delay: 32.0,
99
+ multiplier: 1.3,
100
+ retry_codes: ["UNAVAILABLE"]
101
+ }
102
+
103
+ default_config.rpcs.delete_session.timeout = 30.0
104
+ default_config.rpcs.delete_session.retry_policy = {
105
+ initial_delay: 0.25,
106
+ max_delay: 32.0,
107
+ multiplier: 1.3,
108
+ retry_codes: ["UNAVAILABLE"]
109
+ }
110
+
111
+ default_config.rpcs.execute_sql.timeout = 30.0
112
+ default_config.rpcs.execute_sql.retry_policy = {
113
+ initial_delay: 0.25,
114
+ max_delay: 32.0,
115
+ multiplier: 1.3,
116
+ retry_codes: ["UNAVAILABLE"]
117
+ }
118
+
119
+ default_config.rpcs.execute_streaming_sql.timeout = 3600.0
120
+
121
+ default_config.rpcs.execute_batch_dml.timeout = 30.0
122
+ default_config.rpcs.execute_batch_dml.retry_policy = {
123
+ initial_delay: 0.25,
124
+ max_delay: 32.0,
125
+ multiplier: 1.3,
126
+ retry_codes: ["UNAVAILABLE"]
127
+ }
128
+
129
+ default_config.rpcs.read.timeout = 30.0
130
+ default_config.rpcs.read.retry_policy = {
131
+ initial_delay: 0.25,
132
+ max_delay: 32.0,
133
+ multiplier: 1.3,
134
+ retry_codes: ["UNAVAILABLE"]
135
+ }
136
+
137
+ default_config.rpcs.streaming_read.timeout = 3600.0
138
+
139
+ default_config.rpcs.begin_transaction.timeout = 30.0
140
+ default_config.rpcs.begin_transaction.retry_policy = {
141
+ initial_delay: 0.25,
142
+ max_delay: 32.0,
143
+ multiplier: 1.3,
144
+ retry_codes: ["UNAVAILABLE"]
145
+ }
146
+
147
+ default_config.rpcs.commit.timeout = 3600.0
148
+ default_config.rpcs.commit.retry_policy = {
149
+ initial_delay: 0.25,
150
+ max_delay: 32.0,
151
+ multiplier: 1.3,
152
+ retry_codes: ["UNAVAILABLE"]
153
+ }
154
+
155
+ default_config.rpcs.rollback.timeout = 30.0
156
+ default_config.rpcs.rollback.retry_policy = {
157
+ initial_delay: 0.25,
158
+ max_delay: 32.0,
159
+ multiplier: 1.3,
160
+ retry_codes: ["UNAVAILABLE"]
161
+ }
162
+
163
+ default_config.rpcs.partition_query.timeout = 30.0
164
+ default_config.rpcs.partition_query.retry_policy = {
165
+ initial_delay: 0.25,
166
+ max_delay: 32.0,
167
+ multiplier: 1.3,
168
+ retry_codes: ["UNAVAILABLE"]
169
+ }
170
+
171
+ default_config.rpcs.partition_read.timeout = 30.0
172
+ default_config.rpcs.partition_read.retry_policy = {
173
+ initial_delay: 0.25,
174
+ max_delay: 32.0,
175
+ multiplier: 1.3,
176
+ retry_codes: ["UNAVAILABLE"]
177
+ }
178
+
179
+ default_config
180
+ end
181
+ yield @configure if block_given?
182
+ @configure
183
+ end
184
+
185
+ ##
186
+ # Configure the Spanner Client instance.
187
+ #
188
+ # The configuration is set to the derived mode, meaning that values can be changed,
189
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
190
+ # should be made on {Client.configure}.
191
+ #
192
+ # See {::Google::Cloud::Spanner::V1::Spanner::Client::Configuration}
193
+ # for a description of the configuration fields.
194
+ #
195
+ # @yield [config] Configure the Client client.
196
+ # @yieldparam config [Client::Configuration]
197
+ #
198
+ # @return [Client::Configuration]
199
+ #
200
+ def configure
201
+ yield @config if block_given?
202
+ @config
203
+ end
204
+
205
+ ##
206
+ # Create a new Spanner client object.
207
+ #
208
+ # ## Examples
209
+ #
210
+ # To create a new Spanner client with the default
211
+ # configuration:
212
+ #
213
+ # client = ::Google::Cloud::Spanner::V1::Spanner::Client.new
214
+ #
215
+ # To create a new Spanner client with a custom
216
+ # configuration:
217
+ #
218
+ # client = ::Google::Cloud::Spanner::V1::Spanner::Client.new do |config|
219
+ # config.timeout = 10.0
220
+ # end
221
+ #
222
+ # @yield [config] Configure the Spanner client.
223
+ # @yieldparam config [Client::Configuration]
224
+ #
225
+ def initialize
226
+ # These require statements are intentionally placed here to initialize
227
+ # the gRPC module only when it's required.
228
+ # See https://github.com/googleapis/toolkit/issues/446
229
+ require "gapic/grpc"
230
+ require "google/spanner/v1/spanner_services_pb"
231
+
232
+ # Create the configuration object
233
+ @config = Configuration.new Client.configure
234
+
235
+ # Yield the configuration if needed
236
+ yield @config if block_given?
237
+
238
+ # Create credentials
239
+ credentials = @config.credentials
240
+ credentials ||= Credentials.default scope: @config.scope
241
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
242
+ credentials = Credentials.new credentials, scope: @config.scope
243
+ end
244
+ @quota_project_id = @config.quota_project
245
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
246
+
247
+ @spanner_stub = ::Gapic::ServiceStub.new(
248
+ ::Google::Cloud::Spanner::V1::Spanner::Stub,
249
+ credentials: credentials,
250
+ endpoint: @config.endpoint,
251
+ channel_args: @config.channel_args,
252
+ interceptors: @config.interceptors
253
+ )
254
+ end
255
+
256
+ # Service calls
257
+
258
+ ##
259
+ # Creates a new session. A session can be used to perform
260
+ # transactions that read and/or modify data in a Cloud Spanner database.
261
+ # Sessions are meant to be reused for many consecutive
262
+ # transactions.
263
+ #
264
+ # Sessions can only execute one transaction at a time. To execute
265
+ # multiple concurrent read-write/write-only transactions, create
266
+ # multiple sessions. Note that standalone reads and queries use a
267
+ # transaction internally, and count toward the one transaction
268
+ # limit.
269
+ #
270
+ # Active sessions use additional server resources, so it is a good idea to
271
+ # delete idle and unneeded sessions.
272
+ # Aside from explicit deletes, Cloud Spanner may delete sessions for which no
273
+ # operations are sent for more than an hour. If a session is deleted,
274
+ # requests to it return `NOT_FOUND`.
275
+ #
276
+ # Idle sessions can be kept alive by sending a trivial SQL query
277
+ # periodically, e.g., `"SELECT 1"`.
278
+ #
279
+ # @overload create_session(request, options = nil)
280
+ # Pass arguments to `create_session` via a request object, either of type
281
+ # {::Google::Cloud::Spanner::V1::CreateSessionRequest} or an equivalent Hash.
282
+ #
283
+ # @param request [::Google::Cloud::Spanner::V1::CreateSessionRequest, ::Hash]
284
+ # A request object representing the call parameters. Required. To specify no
285
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
286
+ # @param options [::Gapic::CallOptions, ::Hash]
287
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
288
+ #
289
+ # @overload create_session(database: nil, session: nil)
290
+ # Pass arguments to `create_session` via keyword arguments. Note that at
291
+ # least one keyword argument is required. To specify no parameters, or to keep all
292
+ # the default parameter values, pass an empty Hash as a request object (see above).
293
+ #
294
+ # @param database [::String]
295
+ # Required. The database in which the new session is created.
296
+ # @param session [::Google::Cloud::Spanner::V1::Session, ::Hash]
297
+ # The session to create.
298
+ #
299
+ # @yield [response, operation] Access the result along with the RPC operation
300
+ # @yieldparam response [::Google::Cloud::Spanner::V1::Session]
301
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
302
+ #
303
+ # @return [::Google::Cloud::Spanner::V1::Session]
304
+ #
305
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
306
+ #
307
+ def create_session request, options = nil
308
+ raise ::ArgumentError, "request must be provided" if request.nil?
309
+
310
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::CreateSessionRequest
311
+
312
+ # Converts hash and nil to an options object
313
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
314
+
315
+ # Customize the options with defaults
316
+ metadata = @config.rpcs.create_session.metadata.to_h
317
+
318
+ # Set x-goog-api-client and x-goog-user-project headers
319
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
320
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
321
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
322
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
323
+
324
+ header_params = {
325
+ "database" => request.database
326
+ }
327
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
328
+ metadata[:"x-goog-request-params"] ||= request_params_header
329
+
330
+ options.apply_defaults timeout: @config.rpcs.create_session.timeout,
331
+ metadata: metadata,
332
+ retry_policy: @config.rpcs.create_session.retry_policy
333
+ options.apply_defaults metadata: @config.metadata,
334
+ retry_policy: @config.retry_policy
335
+
336
+ @spanner_stub.call_rpc :create_session, request, options: options do |response, operation|
337
+ yield response, operation if block_given?
338
+ return response
339
+ end
340
+ rescue ::GRPC::BadStatus => e
341
+ raise ::Google::Cloud::Error.from_error(e)
342
+ end
343
+
344
+ ##
345
+ # Creates multiple new sessions.
346
+ #
347
+ # This API can be used to initialize a session cache on the clients.
348
+ # See https://goo.gl/TgSFN2 for best practices on session cache management.
349
+ #
350
+ # @overload batch_create_sessions(request, options = nil)
351
+ # Pass arguments to `batch_create_sessions` via a request object, either of type
352
+ # {::Google::Cloud::Spanner::V1::BatchCreateSessionsRequest} or an equivalent Hash.
353
+ #
354
+ # @param request [::Google::Cloud::Spanner::V1::BatchCreateSessionsRequest, ::Hash]
355
+ # A request object representing the call parameters. Required. To specify no
356
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
357
+ # @param options [::Gapic::CallOptions, ::Hash]
358
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
359
+ #
360
+ # @overload batch_create_sessions(database: nil, session_template: nil, session_count: nil)
361
+ # Pass arguments to `batch_create_sessions` via keyword arguments. Note that at
362
+ # least one keyword argument is required. To specify no parameters, or to keep all
363
+ # the default parameter values, pass an empty Hash as a request object (see above).
364
+ #
365
+ # @param database [::String]
366
+ # Required. The database in which the new sessions are created.
367
+ # @param session_template [::Google::Cloud::Spanner::V1::Session, ::Hash]
368
+ # Parameters to be applied to each created session.
369
+ # @param session_count [::Integer]
370
+ # Required. The number of sessions to be created in this batch call.
371
+ # The API may return fewer than the requested number of sessions. If a
372
+ # specific number of sessions are desired, the client can make additional
373
+ # calls to BatchCreateSessions (adjusting
374
+ # {::Google::Cloud::Spanner::V1::BatchCreateSessionsRequest#session_count session_count} as necessary).
375
+ #
376
+ # @yield [response, operation] Access the result along with the RPC operation
377
+ # @yieldparam response [::Google::Cloud::Spanner::V1::BatchCreateSessionsResponse]
378
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
379
+ #
380
+ # @return [::Google::Cloud::Spanner::V1::BatchCreateSessionsResponse]
381
+ #
382
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
383
+ #
384
+ def batch_create_sessions request, options = nil
385
+ raise ::ArgumentError, "request must be provided" if request.nil?
386
+
387
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::BatchCreateSessionsRequest
388
+
389
+ # Converts hash and nil to an options object
390
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
391
+
392
+ # Customize the options with defaults
393
+ metadata = @config.rpcs.batch_create_sessions.metadata.to_h
394
+
395
+ # Set x-goog-api-client and x-goog-user-project headers
396
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
397
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
398
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
399
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
400
+
401
+ header_params = {
402
+ "database" => request.database
403
+ }
404
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
405
+ metadata[:"x-goog-request-params"] ||= request_params_header
406
+
407
+ options.apply_defaults timeout: @config.rpcs.batch_create_sessions.timeout,
408
+ metadata: metadata,
409
+ retry_policy: @config.rpcs.batch_create_sessions.retry_policy
410
+ options.apply_defaults metadata: @config.metadata,
411
+ retry_policy: @config.retry_policy
412
+
413
+ @spanner_stub.call_rpc :batch_create_sessions, request, options: options do |response, operation|
414
+ yield response, operation if block_given?
415
+ return response
416
+ end
417
+ rescue ::GRPC::BadStatus => e
418
+ raise ::Google::Cloud::Error.from_error(e)
419
+ end
420
+
421
+ ##
422
+ # Gets a session. Returns `NOT_FOUND` if the session does not exist.
423
+ # This is mainly useful for determining whether a session is still
424
+ # alive.
425
+ #
426
+ # @overload get_session(request, options = nil)
427
+ # Pass arguments to `get_session` via a request object, either of type
428
+ # {::Google::Cloud::Spanner::V1::GetSessionRequest} or an equivalent Hash.
429
+ #
430
+ # @param request [::Google::Cloud::Spanner::V1::GetSessionRequest, ::Hash]
431
+ # A request object representing the call parameters. Required. To specify no
432
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
433
+ # @param options [::Gapic::CallOptions, ::Hash]
434
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
435
+ #
436
+ # @overload get_session(name: nil)
437
+ # Pass arguments to `get_session` via keyword arguments. Note that at
438
+ # least one keyword argument is required. To specify no parameters, or to keep all
439
+ # the default parameter values, pass an empty Hash as a request object (see above).
440
+ #
441
+ # @param name [::String]
442
+ # Required. The name of the session to retrieve.
443
+ #
444
+ # @yield [response, operation] Access the result along with the RPC operation
445
+ # @yieldparam response [::Google::Cloud::Spanner::V1::Session]
446
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
447
+ #
448
+ # @return [::Google::Cloud::Spanner::V1::Session]
449
+ #
450
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
451
+ #
452
+ def get_session request, options = nil
453
+ raise ::ArgumentError, "request must be provided" if request.nil?
454
+
455
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::GetSessionRequest
456
+
457
+ # Converts hash and nil to an options object
458
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
459
+
460
+ # Customize the options with defaults
461
+ metadata = @config.rpcs.get_session.metadata.to_h
462
+
463
+ # Set x-goog-api-client and x-goog-user-project headers
464
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
465
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
466
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
467
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
468
+
469
+ header_params = {
470
+ "name" => request.name
471
+ }
472
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
473
+ metadata[:"x-goog-request-params"] ||= request_params_header
474
+
475
+ options.apply_defaults timeout: @config.rpcs.get_session.timeout,
476
+ metadata: metadata,
477
+ retry_policy: @config.rpcs.get_session.retry_policy
478
+ options.apply_defaults metadata: @config.metadata,
479
+ retry_policy: @config.retry_policy
480
+
481
+ @spanner_stub.call_rpc :get_session, request, options: options do |response, operation|
482
+ yield response, operation if block_given?
483
+ return response
484
+ end
485
+ rescue ::GRPC::BadStatus => e
486
+ raise ::Google::Cloud::Error.from_error(e)
487
+ end
488
+
489
+ ##
490
+ # Lists all sessions in a given database.
491
+ #
492
+ # @overload list_sessions(request, options = nil)
493
+ # Pass arguments to `list_sessions` via a request object, either of type
494
+ # {::Google::Cloud::Spanner::V1::ListSessionsRequest} or an equivalent Hash.
495
+ #
496
+ # @param request [::Google::Cloud::Spanner::V1::ListSessionsRequest, ::Hash]
497
+ # A request object representing the call parameters. Required. To specify no
498
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
499
+ # @param options [::Gapic::CallOptions, ::Hash]
500
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
501
+ #
502
+ # @overload list_sessions(database: nil, page_size: nil, page_token: nil, filter: nil)
503
+ # Pass arguments to `list_sessions` via keyword arguments. Note that at
504
+ # least one keyword argument is required. To specify no parameters, or to keep all
505
+ # the default parameter values, pass an empty Hash as a request object (see above).
506
+ #
507
+ # @param database [::String]
508
+ # Required. The database in which to list sessions.
509
+ # @param page_size [::Integer]
510
+ # Number of sessions to be returned in the response. If 0 or less, defaults
511
+ # to the server's maximum allowed page size.
512
+ # @param page_token [::String]
513
+ # If non-empty, `page_token` should contain a
514
+ # {::Google::Cloud::Spanner::V1::ListSessionsResponse#next_page_token next_page_token} from a previous
515
+ # {::Google::Cloud::Spanner::V1::ListSessionsResponse ListSessionsResponse}.
516
+ # @param filter [::String]
517
+ # An expression for filtering the results of the request. Filter rules are
518
+ # case insensitive. The fields eligible for filtering are:
519
+ #
520
+ # * `labels.key` where key is the name of a label
521
+ #
522
+ # Some examples of using filters are:
523
+ #
524
+ # * `labels.env:*` --> The session has the label "env".
525
+ # * `labels.env:dev` --> The session has the label "env" and the value of
526
+ # the label contains the string "dev".
527
+ #
528
+ # @yield [response, operation] Access the result along with the RPC operation
529
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::V1::Session>]
530
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
531
+ #
532
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::V1::Session>]
533
+ #
534
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
535
+ #
536
+ def list_sessions request, options = nil
537
+ raise ::ArgumentError, "request must be provided" if request.nil?
538
+
539
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ListSessionsRequest
540
+
541
+ # Converts hash and nil to an options object
542
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
543
+
544
+ # Customize the options with defaults
545
+ metadata = @config.rpcs.list_sessions.metadata.to_h
546
+
547
+ # Set x-goog-api-client and x-goog-user-project headers
548
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
549
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
550
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
551
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
552
+
553
+ header_params = {
554
+ "database" => request.database
555
+ }
556
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
557
+ metadata[:"x-goog-request-params"] ||= request_params_header
558
+
559
+ options.apply_defaults timeout: @config.rpcs.list_sessions.timeout,
560
+ metadata: metadata,
561
+ retry_policy: @config.rpcs.list_sessions.retry_policy
562
+ options.apply_defaults metadata: @config.metadata,
563
+ retry_policy: @config.retry_policy
564
+
565
+ @spanner_stub.call_rpc :list_sessions, request, options: options do |response, operation|
566
+ response = ::Gapic::PagedEnumerable.new @spanner_stub, :list_sessions, request, response, operation, options
567
+ yield response, operation if block_given?
568
+ return response
569
+ end
570
+ rescue ::GRPC::BadStatus => e
571
+ raise ::Google::Cloud::Error.from_error(e)
572
+ end
573
+
574
+ ##
575
+ # Ends a session, releasing server resources associated with it. This will
576
+ # asynchronously trigger cancellation of any operations that are running with
577
+ # this session.
578
+ #
579
+ # @overload delete_session(request, options = nil)
580
+ # Pass arguments to `delete_session` via a request object, either of type
581
+ # {::Google::Cloud::Spanner::V1::DeleteSessionRequest} or an equivalent Hash.
582
+ #
583
+ # @param request [::Google::Cloud::Spanner::V1::DeleteSessionRequest, ::Hash]
584
+ # A request object representing the call parameters. Required. To specify no
585
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
586
+ # @param options [::Gapic::CallOptions, ::Hash]
587
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
588
+ #
589
+ # @overload delete_session(name: nil)
590
+ # Pass arguments to `delete_session` via keyword arguments. Note that at
591
+ # least one keyword argument is required. To specify no parameters, or to keep all
592
+ # the default parameter values, pass an empty Hash as a request object (see above).
593
+ #
594
+ # @param name [::String]
595
+ # Required. The name of the session to delete.
596
+ #
597
+ # @yield [response, operation] Access the result along with the RPC operation
598
+ # @yieldparam response [::Google::Protobuf::Empty]
599
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
600
+ #
601
+ # @return [::Google::Protobuf::Empty]
602
+ #
603
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
604
+ #
605
+ def delete_session request, options = nil
606
+ raise ::ArgumentError, "request must be provided" if request.nil?
607
+
608
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::DeleteSessionRequest
609
+
610
+ # Converts hash and nil to an options object
611
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
612
+
613
+ # Customize the options with defaults
614
+ metadata = @config.rpcs.delete_session.metadata.to_h
615
+
616
+ # Set x-goog-api-client and x-goog-user-project headers
617
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
618
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
619
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
620
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
621
+
622
+ header_params = {
623
+ "name" => request.name
624
+ }
625
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
626
+ metadata[:"x-goog-request-params"] ||= request_params_header
627
+
628
+ options.apply_defaults timeout: @config.rpcs.delete_session.timeout,
629
+ metadata: metadata,
630
+ retry_policy: @config.rpcs.delete_session.retry_policy
631
+ options.apply_defaults metadata: @config.metadata,
632
+ retry_policy: @config.retry_policy
633
+
634
+ @spanner_stub.call_rpc :delete_session, request, options: options do |response, operation|
635
+ yield response, operation if block_given?
636
+ return response
637
+ end
638
+ rescue ::GRPC::BadStatus => e
639
+ raise ::Google::Cloud::Error.from_error(e)
640
+ end
641
+
642
+ ##
643
+ # Executes an SQL statement, returning all results in a single reply. This
644
+ # method cannot be used to return a result set larger than 10 MiB;
645
+ # if the query yields more data than that, the query fails with
646
+ # a `FAILED_PRECONDITION` error.
647
+ #
648
+ # Operations inside read-write transactions might return `ABORTED`. If
649
+ # this occurs, the application should restart the transaction from
650
+ # the beginning. See {::Google::Cloud::Spanner::V1::Transaction Transaction} for more details.
651
+ #
652
+ # Larger result sets can be fetched in streaming fashion by calling
653
+ # {::Google::Cloud::Spanner::V1::Spanner::Client#execute_streaming_sql ExecuteStreamingSql} instead.
654
+ #
655
+ # @overload execute_sql(request, options = nil)
656
+ # Pass arguments to `execute_sql` via a request object, either of type
657
+ # {::Google::Cloud::Spanner::V1::ExecuteSqlRequest} or an equivalent Hash.
658
+ #
659
+ # @param request [::Google::Cloud::Spanner::V1::ExecuteSqlRequest, ::Hash]
660
+ # A request object representing the call parameters. Required. To specify no
661
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
662
+ # @param options [::Gapic::CallOptions, ::Hash]
663
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
664
+ #
665
+ # @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)
666
+ # Pass arguments to `execute_sql` via keyword arguments. Note that at
667
+ # least one keyword argument is required. To specify no parameters, or to keep all
668
+ # the default parameter values, pass an empty Hash as a request object (see above).
669
+ #
670
+ # @param session [::String]
671
+ # Required. The session in which the SQL query should be performed.
672
+ # @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
673
+ # The transaction to use.
674
+ #
675
+ # For queries, if none is provided, the default is a temporary read-only
676
+ # transaction with strong concurrency.
677
+ #
678
+ # Standard DML statements require a read-write transaction. To protect
679
+ # against replays, single-use transactions are not supported. The caller
680
+ # must either supply an existing transaction ID or begin a new transaction.
681
+ #
682
+ # Partitioned DML requires an existing Partitioned DML transaction ID.
683
+ # @param sql [::String]
684
+ # Required. The SQL string.
685
+ # @param params [::Google::Protobuf::Struct, ::Hash]
686
+ # Parameter names and values that bind to placeholders in the SQL string.
687
+ #
688
+ # A parameter placeholder consists of the `@` character followed by the
689
+ # parameter name (for example, `@firstName`). Parameter names can contain
690
+ # letters, numbers, and underscores.
691
+ #
692
+ # Parameters can appear anywhere that a literal value is expected. The same
693
+ # parameter name can be used more than once, for example:
694
+ #
695
+ # `"WHERE id > @msg_id AND id < @msg_id + 100"`
696
+ #
697
+ # It is an error to execute a SQL statement with unbound parameters.
698
+ # @param param_types [::Hash{::String => ::Google::Cloud::Spanner::V1::Type, ::Hash}]
699
+ # It is not always possible for Cloud Spanner to infer the right SQL type
700
+ # from a JSON value. For example, values of type `BYTES` and values
701
+ # of type `STRING` both appear in {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#params params} as JSON strings.
702
+ #
703
+ # In these cases, `param_types` can be used to specify the exact
704
+ # SQL type for some or all of the SQL statement parameters. See the
705
+ # definition of {::Google::Cloud::Spanner::V1::Type Type} for more information
706
+ # about SQL types.
707
+ # @param resume_token [::String]
708
+ # If this request is resuming a previously interrupted SQL statement
709
+ # execution, `resume_token` should be copied from the last
710
+ # {::Google::Cloud::Spanner::V1::PartialResultSet PartialResultSet} yielded before the interruption. Doing this
711
+ # enables the new SQL statement execution to resume where the last one left
712
+ # off. The rest of the request parameters must exactly match the
713
+ # request that yielded this token.
714
+ # @param query_mode [::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryMode]
715
+ # Used to control the amount of debugging information returned in
716
+ # {::Google::Cloud::Spanner::V1::ResultSetStats ResultSetStats}. If {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#partition_token partition_token} is set, {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#query_mode query_mode} can only
717
+ # be set to {::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryMode::NORMAL QueryMode.NORMAL}.
718
+ # @param partition_token [::String]
719
+ # If present, results will be restricted to the specified partition
720
+ # previously created using PartitionQuery(). There must be an exact
721
+ # match for the values of fields common to this message and the
722
+ # PartitionQueryRequest message used to create this partition_token.
723
+ # @param seqno [::Integer]
724
+ # A per-transaction sequence number used to identify this request. This field
725
+ # makes each request idempotent such that if the request is received multiple
726
+ # times, at most one will succeed.
727
+ #
728
+ # The sequence number must be monotonically increasing within the
729
+ # transaction. If a request arrives for the first time with an out-of-order
730
+ # sequence number, the transaction may be aborted. Replays of previously
731
+ # handled requests will yield the same response as the first execution.
732
+ #
733
+ # Required for DML statements. Ignored for queries.
734
+ # @param query_options [::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryOptions, ::Hash]
735
+ # Query optimizer configuration to use for the given query.
736
+ #
737
+ # @yield [response, operation] Access the result along with the RPC operation
738
+ # @yieldparam response [::Google::Cloud::Spanner::V1::ResultSet]
739
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
740
+ #
741
+ # @return [::Google::Cloud::Spanner::V1::ResultSet]
742
+ #
743
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
744
+ #
745
+ def execute_sql request, options = nil
746
+ raise ::ArgumentError, "request must be provided" if request.nil?
747
+
748
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ExecuteSqlRequest
749
+
750
+ # Converts hash and nil to an options object
751
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
752
+
753
+ # Customize the options with defaults
754
+ metadata = @config.rpcs.execute_sql.metadata.to_h
755
+
756
+ # Set x-goog-api-client and x-goog-user-project headers
757
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
758
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
759
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
760
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
761
+
762
+ header_params = {
763
+ "session" => request.session
764
+ }
765
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
766
+ metadata[:"x-goog-request-params"] ||= request_params_header
767
+
768
+ options.apply_defaults timeout: @config.rpcs.execute_sql.timeout,
769
+ metadata: metadata,
770
+ retry_policy: @config.rpcs.execute_sql.retry_policy
771
+ options.apply_defaults metadata: @config.metadata,
772
+ retry_policy: @config.retry_policy
773
+
774
+ @spanner_stub.call_rpc :execute_sql, request, options: options do |response, operation|
775
+ yield response, operation if block_given?
776
+ return response
777
+ end
778
+ rescue ::GRPC::BadStatus => e
779
+ raise ::Google::Cloud::Error.from_error(e)
780
+ end
781
+
782
+ ##
783
+ # Like {::Google::Cloud::Spanner::V1::Spanner::Client#execute_sql ExecuteSql}, except returns the result
784
+ # set as a stream. Unlike {::Google::Cloud::Spanner::V1::Spanner::Client#execute_sql ExecuteSql}, there
785
+ # is no limit on the size of the returned result set. However, no
786
+ # individual row in the result set can exceed 100 MiB, and no
787
+ # column value can exceed 10 MiB.
788
+ #
789
+ # @overload execute_streaming_sql(request, options = nil)
790
+ # Pass arguments to `execute_streaming_sql` via a request object, either of type
791
+ # {::Google::Cloud::Spanner::V1::ExecuteSqlRequest} or an equivalent Hash.
792
+ #
793
+ # @param request [::Google::Cloud::Spanner::V1::ExecuteSqlRequest, ::Hash]
794
+ # A request object representing the call parameters. Required. To specify no
795
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
796
+ # @param options [::Gapic::CallOptions, ::Hash]
797
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
798
+ #
799
+ # @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)
800
+ # Pass arguments to `execute_streaming_sql` via keyword arguments. Note that at
801
+ # least one keyword argument is required. To specify no parameters, or to keep all
802
+ # the default parameter values, pass an empty Hash as a request object (see above).
803
+ #
804
+ # @param session [::String]
805
+ # Required. The session in which the SQL query should be performed.
806
+ # @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
807
+ # The transaction to use.
808
+ #
809
+ # For queries, if none is provided, the default is a temporary read-only
810
+ # transaction with strong concurrency.
811
+ #
812
+ # Standard DML statements require a read-write transaction. To protect
813
+ # against replays, single-use transactions are not supported. The caller
814
+ # must either supply an existing transaction ID or begin a new transaction.
815
+ #
816
+ # Partitioned DML requires an existing Partitioned DML transaction ID.
817
+ # @param sql [::String]
818
+ # Required. The SQL string.
819
+ # @param params [::Google::Protobuf::Struct, ::Hash]
820
+ # Parameter names and values that bind to placeholders in the SQL string.
821
+ #
822
+ # A parameter placeholder consists of the `@` character followed by the
823
+ # parameter name (for example, `@firstName`). Parameter names can contain
824
+ # letters, numbers, and underscores.
825
+ #
826
+ # Parameters can appear anywhere that a literal value is expected. The same
827
+ # parameter name can be used more than once, for example:
828
+ #
829
+ # `"WHERE id > @msg_id AND id < @msg_id + 100"`
830
+ #
831
+ # It is an error to execute a SQL statement with unbound parameters.
832
+ # @param param_types [::Hash{::String => ::Google::Cloud::Spanner::V1::Type, ::Hash}]
833
+ # It is not always possible for Cloud Spanner to infer the right SQL type
834
+ # from a JSON value. For example, values of type `BYTES` and values
835
+ # of type `STRING` both appear in {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#params params} as JSON strings.
836
+ #
837
+ # In these cases, `param_types` can be used to specify the exact
838
+ # SQL type for some or all of the SQL statement parameters. See the
839
+ # definition of {::Google::Cloud::Spanner::V1::Type Type} for more information
840
+ # about SQL types.
841
+ # @param resume_token [::String]
842
+ # If this request is resuming a previously interrupted SQL statement
843
+ # execution, `resume_token` should be copied from the last
844
+ # {::Google::Cloud::Spanner::V1::PartialResultSet PartialResultSet} yielded before the interruption. Doing this
845
+ # enables the new SQL statement execution to resume where the last one left
846
+ # off. The rest of the request parameters must exactly match the
847
+ # request that yielded this token.
848
+ # @param query_mode [::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryMode]
849
+ # Used to control the amount of debugging information returned in
850
+ # {::Google::Cloud::Spanner::V1::ResultSetStats ResultSetStats}. If {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#partition_token partition_token} is set, {::Google::Cloud::Spanner::V1::ExecuteSqlRequest#query_mode query_mode} can only
851
+ # be set to {::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryMode::NORMAL QueryMode.NORMAL}.
852
+ # @param partition_token [::String]
853
+ # If present, results will be restricted to the specified partition
854
+ # previously created using PartitionQuery(). There must be an exact
855
+ # match for the values of fields common to this message and the
856
+ # PartitionQueryRequest message used to create this partition_token.
857
+ # @param seqno [::Integer]
858
+ # A per-transaction sequence number used to identify this request. This field
859
+ # makes each request idempotent such that if the request is received multiple
860
+ # times, at most one will succeed.
861
+ #
862
+ # The sequence number must be monotonically increasing within the
863
+ # transaction. If a request arrives for the first time with an out-of-order
864
+ # sequence number, the transaction may be aborted. Replays of previously
865
+ # handled requests will yield the same response as the first execution.
866
+ #
867
+ # Required for DML statements. Ignored for queries.
868
+ # @param query_options [::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryOptions, ::Hash]
869
+ # Query optimizer configuration to use for the given query.
870
+ #
871
+ # @yield [response, operation] Access the result along with the RPC operation
872
+ # @yieldparam response [::Enumerable<::Google::Cloud::Spanner::V1::PartialResultSet>]
873
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
874
+ #
875
+ # @return [::Enumerable<::Google::Cloud::Spanner::V1::PartialResultSet>]
876
+ #
877
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
878
+ #
879
+ def execute_streaming_sql request, options = nil
880
+ raise ::ArgumentError, "request must be provided" if request.nil?
881
+
882
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ExecuteSqlRequest
883
+
884
+ # Converts hash and nil to an options object
885
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
886
+
887
+ # Customize the options with defaults
888
+ metadata = @config.rpcs.execute_streaming_sql.metadata.to_h
889
+
890
+ # Set x-goog-api-client and x-goog-user-project headers
891
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
892
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
893
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
894
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
895
+
896
+ header_params = {
897
+ "session" => request.session
898
+ }
899
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
900
+ metadata[:"x-goog-request-params"] ||= request_params_header
901
+
902
+ options.apply_defaults timeout: @config.rpcs.execute_streaming_sql.timeout,
903
+ metadata: metadata,
904
+ retry_policy: @config.rpcs.execute_streaming_sql.retry_policy
905
+ options.apply_defaults metadata: @config.metadata,
906
+ retry_policy: @config.retry_policy
907
+
908
+ @spanner_stub.call_rpc :execute_streaming_sql, request, options: options do |response, operation|
909
+ yield response, operation if block_given?
910
+ return response
911
+ end
912
+ rescue ::GRPC::BadStatus => e
913
+ raise ::Google::Cloud::Error.from_error(e)
914
+ end
915
+
916
+ ##
917
+ # Executes a batch of SQL DML statements. This method allows many statements
918
+ # to be run with lower latency than submitting them sequentially with
919
+ # {::Google::Cloud::Spanner::V1::Spanner::Client#execute_sql ExecuteSql}.
920
+ #
921
+ # Statements are executed in sequential order. A request can succeed even if
922
+ # a statement fails. The {::Google::Cloud::Spanner::V1::ExecuteBatchDmlResponse#status ExecuteBatchDmlResponse.status} field in the
923
+ # response provides information about the statement that failed. Clients must
924
+ # inspect this field to determine whether an error occurred.
925
+ #
926
+ # Execution stops after the first failed statement; the remaining statements
927
+ # are not executed.
928
+ #
929
+ # @overload execute_batch_dml(request, options = nil)
930
+ # Pass arguments to `execute_batch_dml` via a request object, either of type
931
+ # {::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest} or an equivalent Hash.
932
+ #
933
+ # @param request [::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest, ::Hash]
934
+ # A request object representing the call parameters. Required. To specify no
935
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
936
+ # @param options [::Gapic::CallOptions, ::Hash]
937
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
938
+ #
939
+ # @overload execute_batch_dml(session: nil, transaction: nil, statements: nil, seqno: nil)
940
+ # Pass arguments to `execute_batch_dml` via keyword arguments. Note that at
941
+ # least one keyword argument is required. To specify no parameters, or to keep all
942
+ # the default parameter values, pass an empty Hash as a request object (see above).
943
+ #
944
+ # @param session [::String]
945
+ # Required. The session in which the DML statements should be performed.
946
+ # @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
947
+ # Required. The transaction to use. Must be a read-write transaction.
948
+ #
949
+ # To protect against replays, single-use transactions are not supported. The
950
+ # caller must either supply an existing transaction ID or begin a new
951
+ # transaction.
952
+ # @param statements [::Array<::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest::Statement, ::Hash>]
953
+ # Required. The list of statements to execute in this batch. Statements are executed
954
+ # serially, such that the effects of statement `i` are visible to statement
955
+ # `i+1`. Each statement must be a DML statement. Execution stops at the
956
+ # first failed statement; the remaining statements are not executed.
957
+ #
958
+ # Callers must provide at least one statement.
959
+ # @param seqno [::Integer]
960
+ # Required. A per-transaction sequence number used to identify this request. This field
961
+ # makes each request idempotent such that if the request is received multiple
962
+ # times, at most one will succeed.
963
+ #
964
+ # The sequence number must be monotonically increasing within the
965
+ # transaction. If a request arrives for the first time with an out-of-order
966
+ # sequence number, the transaction may be aborted. Replays of previously
967
+ # handled requests will yield the same response as the first execution.
968
+ #
969
+ # @yield [response, operation] Access the result along with the RPC operation
970
+ # @yieldparam response [::Google::Cloud::Spanner::V1::ExecuteBatchDmlResponse]
971
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
972
+ #
973
+ # @return [::Google::Cloud::Spanner::V1::ExecuteBatchDmlResponse]
974
+ #
975
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
976
+ #
977
+ def execute_batch_dml request, options = nil
978
+ raise ::ArgumentError, "request must be provided" if request.nil?
979
+
980
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest
981
+
982
+ # Converts hash and nil to an options object
983
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
984
+
985
+ # Customize the options with defaults
986
+ metadata = @config.rpcs.execute_batch_dml.metadata.to_h
987
+
988
+ # Set x-goog-api-client and x-goog-user-project headers
989
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
990
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
991
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
992
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
993
+
994
+ header_params = {
995
+ "session" => request.session
996
+ }
997
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
998
+ metadata[:"x-goog-request-params"] ||= request_params_header
999
+
1000
+ options.apply_defaults timeout: @config.rpcs.execute_batch_dml.timeout,
1001
+ metadata: metadata,
1002
+ retry_policy: @config.rpcs.execute_batch_dml.retry_policy
1003
+ options.apply_defaults metadata: @config.metadata,
1004
+ retry_policy: @config.retry_policy
1005
+
1006
+ @spanner_stub.call_rpc :execute_batch_dml, request, options: options do |response, operation|
1007
+ yield response, operation if block_given?
1008
+ return response
1009
+ end
1010
+ rescue ::GRPC::BadStatus => e
1011
+ raise ::Google::Cloud::Error.from_error(e)
1012
+ end
1013
+
1014
+ ##
1015
+ # Reads rows from the database using key lookups and scans, as a
1016
+ # simple key/value style alternative to
1017
+ # {::Google::Cloud::Spanner::V1::Spanner::Client#execute_sql ExecuteSql}. This method cannot be used to
1018
+ # return a result set larger than 10 MiB; if the read matches more
1019
+ # data than that, the read fails with a `FAILED_PRECONDITION`
1020
+ # error.
1021
+ #
1022
+ # Reads inside read-write transactions might return `ABORTED`. If
1023
+ # this occurs, the application should restart the transaction from
1024
+ # the beginning. See {::Google::Cloud::Spanner::V1::Transaction Transaction} for more details.
1025
+ #
1026
+ # Larger result sets can be yielded in streaming fashion by calling
1027
+ # {::Google::Cloud::Spanner::V1::Spanner::Client#streaming_read StreamingRead} instead.
1028
+ #
1029
+ # @overload read(request, options = nil)
1030
+ # Pass arguments to `read` via a request object, either of type
1031
+ # {::Google::Cloud::Spanner::V1::ReadRequest} or an equivalent Hash.
1032
+ #
1033
+ # @param request [::Google::Cloud::Spanner::V1::ReadRequest, ::Hash]
1034
+ # A request object representing the call parameters. Required. To specify no
1035
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1036
+ # @param options [::Gapic::CallOptions, ::Hash]
1037
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1038
+ #
1039
+ # @overload read(session: nil, transaction: nil, table: nil, index: nil, columns: nil, key_set: nil, limit: nil, resume_token: nil, partition_token: nil)
1040
+ # Pass arguments to `read` via keyword arguments. Note that at
1041
+ # least one keyword argument is required. To specify no parameters, or to keep all
1042
+ # the default parameter values, pass an empty Hash as a request object (see above).
1043
+ #
1044
+ # @param session [::String]
1045
+ # Required. The session in which the read should be performed.
1046
+ # @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
1047
+ # The transaction to use. If none is provided, the default is a
1048
+ # temporary read-only transaction with strong concurrency.
1049
+ # @param table [::String]
1050
+ # Required. The name of the table in the database to be read.
1051
+ # @param index [::String]
1052
+ # If non-empty, the name of an index on {::Google::Cloud::Spanner::V1::ReadRequest#table table}. This index is
1053
+ # used instead of the table primary key when interpreting {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set}
1054
+ # and sorting result rows. See {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set} for further information.
1055
+ # @param columns [::Array<::String>]
1056
+ # Required. The columns of {::Google::Cloud::Spanner::V1::ReadRequest#table table} to be returned for each row matching
1057
+ # this request.
1058
+ # @param key_set [::Google::Cloud::Spanner::V1::KeySet, ::Hash]
1059
+ # Required. `key_set` identifies the rows to be yielded. `key_set` names the
1060
+ # primary keys of the rows in {::Google::Cloud::Spanner::V1::ReadRequest#table table} to be yielded, unless {::Google::Cloud::Spanner::V1::ReadRequest#index index}
1061
+ # is present. If {::Google::Cloud::Spanner::V1::ReadRequest#index index} is present, then {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set} instead names
1062
+ # index keys in {::Google::Cloud::Spanner::V1::ReadRequest#index index}.
1063
+ #
1064
+ # If the {::Google::Cloud::Spanner::V1::ReadRequest#partition_token partition_token} field is empty, rows are yielded
1065
+ # in table primary key order (if {::Google::Cloud::Spanner::V1::ReadRequest#index index} is empty) or index key order
1066
+ # (if {::Google::Cloud::Spanner::V1::ReadRequest#index index} is non-empty). If the {::Google::Cloud::Spanner::V1::ReadRequest#partition_token partition_token} field is not
1067
+ # empty, rows will be yielded in an unspecified order.
1068
+ #
1069
+ # It is not an error for the `key_set` to name rows that do not
1070
+ # exist in the database. Read yields nothing for nonexistent rows.
1071
+ # @param limit [::Integer]
1072
+ # If greater than zero, only the first `limit` rows are yielded. If `limit`
1073
+ # is zero, the default is no limit. A limit cannot be specified if
1074
+ # `partition_token` is set.
1075
+ # @param resume_token [::String]
1076
+ # If this request is resuming a previously interrupted read,
1077
+ # `resume_token` should be copied from the last
1078
+ # {::Google::Cloud::Spanner::V1::PartialResultSet PartialResultSet} yielded before the interruption. Doing this
1079
+ # enables the new read to resume where the last read left off. The
1080
+ # rest of the request parameters must exactly match the request
1081
+ # that yielded this token.
1082
+ # @param partition_token [::String]
1083
+ # If present, results will be restricted to the specified partition
1084
+ # previously created using PartitionRead(). There must be an exact
1085
+ # match for the values of fields common to this message and the
1086
+ # PartitionReadRequest message used to create this partition_token.
1087
+ #
1088
+ # @yield [response, operation] Access the result along with the RPC operation
1089
+ # @yieldparam response [::Google::Cloud::Spanner::V1::ResultSet]
1090
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1091
+ #
1092
+ # @return [::Google::Cloud::Spanner::V1::ResultSet]
1093
+ #
1094
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1095
+ #
1096
+ def read request, options = nil
1097
+ raise ::ArgumentError, "request must be provided" if request.nil?
1098
+
1099
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ReadRequest
1100
+
1101
+ # Converts hash and nil to an options object
1102
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1103
+
1104
+ # Customize the options with defaults
1105
+ metadata = @config.rpcs.read.metadata.to_h
1106
+
1107
+ # Set x-goog-api-client and x-goog-user-project headers
1108
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1109
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1110
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1111
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1112
+
1113
+ header_params = {
1114
+ "session" => request.session
1115
+ }
1116
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1117
+ metadata[:"x-goog-request-params"] ||= request_params_header
1118
+
1119
+ options.apply_defaults timeout: @config.rpcs.read.timeout,
1120
+ metadata: metadata,
1121
+ retry_policy: @config.rpcs.read.retry_policy
1122
+ options.apply_defaults metadata: @config.metadata,
1123
+ retry_policy: @config.retry_policy
1124
+
1125
+ @spanner_stub.call_rpc :read, request, options: options do |response, operation|
1126
+ yield response, operation if block_given?
1127
+ return response
1128
+ end
1129
+ rescue ::GRPC::BadStatus => e
1130
+ raise ::Google::Cloud::Error.from_error(e)
1131
+ end
1132
+
1133
+ ##
1134
+ # Like {::Google::Cloud::Spanner::V1::Spanner::Client#read Read}, except returns the result set as a
1135
+ # stream. Unlike {::Google::Cloud::Spanner::V1::Spanner::Client#read Read}, there is no limit on the
1136
+ # size of the returned result set. However, no individual row in
1137
+ # the result set can exceed 100 MiB, and no column value can exceed
1138
+ # 10 MiB.
1139
+ #
1140
+ # @overload streaming_read(request, options = nil)
1141
+ # Pass arguments to `streaming_read` via a request object, either of type
1142
+ # {::Google::Cloud::Spanner::V1::ReadRequest} or an equivalent Hash.
1143
+ #
1144
+ # @param request [::Google::Cloud::Spanner::V1::ReadRequest, ::Hash]
1145
+ # A request object representing the call parameters. Required. To specify no
1146
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1147
+ # @param options [::Gapic::CallOptions, ::Hash]
1148
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1149
+ #
1150
+ # @overload streaming_read(session: nil, transaction: nil, table: nil, index: nil, columns: nil, key_set: nil, limit: nil, resume_token: nil, partition_token: nil)
1151
+ # Pass arguments to `streaming_read` via keyword arguments. Note that at
1152
+ # least one keyword argument is required. To specify no parameters, or to keep all
1153
+ # the default parameter values, pass an empty Hash as a request object (see above).
1154
+ #
1155
+ # @param session [::String]
1156
+ # Required. The session in which the read should be performed.
1157
+ # @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
1158
+ # The transaction to use. If none is provided, the default is a
1159
+ # temporary read-only transaction with strong concurrency.
1160
+ # @param table [::String]
1161
+ # Required. The name of the table in the database to be read.
1162
+ # @param index [::String]
1163
+ # If non-empty, the name of an index on {::Google::Cloud::Spanner::V1::ReadRequest#table table}. This index is
1164
+ # used instead of the table primary key when interpreting {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set}
1165
+ # and sorting result rows. See {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set} for further information.
1166
+ # @param columns [::Array<::String>]
1167
+ # Required. The columns of {::Google::Cloud::Spanner::V1::ReadRequest#table table} to be returned for each row matching
1168
+ # this request.
1169
+ # @param key_set [::Google::Cloud::Spanner::V1::KeySet, ::Hash]
1170
+ # Required. `key_set` identifies the rows to be yielded. `key_set` names the
1171
+ # primary keys of the rows in {::Google::Cloud::Spanner::V1::ReadRequest#table table} to be yielded, unless {::Google::Cloud::Spanner::V1::ReadRequest#index index}
1172
+ # is present. If {::Google::Cloud::Spanner::V1::ReadRequest#index index} is present, then {::Google::Cloud::Spanner::V1::ReadRequest#key_set key_set} instead names
1173
+ # index keys in {::Google::Cloud::Spanner::V1::ReadRequest#index index}.
1174
+ #
1175
+ # If the {::Google::Cloud::Spanner::V1::ReadRequest#partition_token partition_token} field is empty, rows are yielded
1176
+ # in table primary key order (if {::Google::Cloud::Spanner::V1::ReadRequest#index index} is empty) or index key order
1177
+ # (if {::Google::Cloud::Spanner::V1::ReadRequest#index index} is non-empty). If the {::Google::Cloud::Spanner::V1::ReadRequest#partition_token partition_token} field is not
1178
+ # empty, rows will be yielded in an unspecified order.
1179
+ #
1180
+ # It is not an error for the `key_set` to name rows that do not
1181
+ # exist in the database. Read yields nothing for nonexistent rows.
1182
+ # @param limit [::Integer]
1183
+ # If greater than zero, only the first `limit` rows are yielded. If `limit`
1184
+ # is zero, the default is no limit. A limit cannot be specified if
1185
+ # `partition_token` is set.
1186
+ # @param resume_token [::String]
1187
+ # If this request is resuming a previously interrupted read,
1188
+ # `resume_token` should be copied from the last
1189
+ # {::Google::Cloud::Spanner::V1::PartialResultSet PartialResultSet} yielded before the interruption. Doing this
1190
+ # enables the new read to resume where the last read left off. The
1191
+ # rest of the request parameters must exactly match the request
1192
+ # that yielded this token.
1193
+ # @param partition_token [::String]
1194
+ # If present, results will be restricted to the specified partition
1195
+ # previously created using PartitionRead(). There must be an exact
1196
+ # match for the values of fields common to this message and the
1197
+ # PartitionReadRequest message used to create this partition_token.
1198
+ #
1199
+ # @yield [response, operation] Access the result along with the RPC operation
1200
+ # @yieldparam response [::Enumerable<::Google::Cloud::Spanner::V1::PartialResultSet>]
1201
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1202
+ #
1203
+ # @return [::Enumerable<::Google::Cloud::Spanner::V1::PartialResultSet>]
1204
+ #
1205
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1206
+ #
1207
+ def streaming_read request, options = nil
1208
+ raise ::ArgumentError, "request must be provided" if request.nil?
1209
+
1210
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ReadRequest
1211
+
1212
+ # Converts hash and nil to an options object
1213
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1214
+
1215
+ # Customize the options with defaults
1216
+ metadata = @config.rpcs.streaming_read.metadata.to_h
1217
+
1218
+ # Set x-goog-api-client and x-goog-user-project headers
1219
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1220
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1221
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1222
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1223
+
1224
+ header_params = {
1225
+ "session" => request.session
1226
+ }
1227
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1228
+ metadata[:"x-goog-request-params"] ||= request_params_header
1229
+
1230
+ options.apply_defaults timeout: @config.rpcs.streaming_read.timeout,
1231
+ metadata: metadata,
1232
+ retry_policy: @config.rpcs.streaming_read.retry_policy
1233
+ options.apply_defaults metadata: @config.metadata,
1234
+ retry_policy: @config.retry_policy
1235
+
1236
+ @spanner_stub.call_rpc :streaming_read, request, options: options do |response, operation|
1237
+ yield response, operation if block_given?
1238
+ return response
1239
+ end
1240
+ rescue ::GRPC::BadStatus => e
1241
+ raise ::Google::Cloud::Error.from_error(e)
1242
+ end
1243
+
1244
+ ##
1245
+ # Begins a new transaction. This step can often be skipped:
1246
+ # {::Google::Cloud::Spanner::V1::Spanner::Client#read Read}, {::Google::Cloud::Spanner::V1::Spanner::Client#execute_sql ExecuteSql} and
1247
+ # {::Google::Cloud::Spanner::V1::Spanner::Client#commit Commit} can begin a new transaction as a
1248
+ # side-effect.
1249
+ #
1250
+ # @overload begin_transaction(request, options = nil)
1251
+ # Pass arguments to `begin_transaction` via a request object, either of type
1252
+ # {::Google::Cloud::Spanner::V1::BeginTransactionRequest} or an equivalent Hash.
1253
+ #
1254
+ # @param request [::Google::Cloud::Spanner::V1::BeginTransactionRequest, ::Hash]
1255
+ # A request object representing the call parameters. Required. To specify no
1256
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1257
+ # @param options [::Gapic::CallOptions, ::Hash]
1258
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1259
+ #
1260
+ # @overload begin_transaction(session: nil, options: nil)
1261
+ # Pass arguments to `begin_transaction` via keyword arguments. Note that at
1262
+ # least one keyword argument is required. To specify no parameters, or to keep all
1263
+ # the default parameter values, pass an empty Hash as a request object (see above).
1264
+ #
1265
+ # @param session [::String]
1266
+ # Required. The session in which the transaction runs.
1267
+ # @param options [::Google::Cloud::Spanner::V1::TransactionOptions, ::Hash]
1268
+ # Required. Options for the new transaction.
1269
+ #
1270
+ # @yield [response, operation] Access the result along with the RPC operation
1271
+ # @yieldparam response [::Google::Cloud::Spanner::V1::Transaction]
1272
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1273
+ #
1274
+ # @return [::Google::Cloud::Spanner::V1::Transaction]
1275
+ #
1276
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1277
+ #
1278
+ def begin_transaction request, options = nil
1279
+ raise ::ArgumentError, "request must be provided" if request.nil?
1280
+
1281
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::BeginTransactionRequest
1282
+
1283
+ # Converts hash and nil to an options object
1284
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1285
+
1286
+ # Customize the options with defaults
1287
+ metadata = @config.rpcs.begin_transaction.metadata.to_h
1288
+
1289
+ # Set x-goog-api-client and x-goog-user-project headers
1290
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1291
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1292
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1293
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1294
+
1295
+ header_params = {
1296
+ "session" => request.session
1297
+ }
1298
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1299
+ metadata[:"x-goog-request-params"] ||= request_params_header
1300
+
1301
+ options.apply_defaults timeout: @config.rpcs.begin_transaction.timeout,
1302
+ metadata: metadata,
1303
+ retry_policy: @config.rpcs.begin_transaction.retry_policy
1304
+ options.apply_defaults metadata: @config.metadata,
1305
+ retry_policy: @config.retry_policy
1306
+
1307
+ @spanner_stub.call_rpc :begin_transaction, request, options: options do |response, operation|
1308
+ yield response, operation if block_given?
1309
+ return response
1310
+ end
1311
+ rescue ::GRPC::BadStatus => e
1312
+ raise ::Google::Cloud::Error.from_error(e)
1313
+ end
1314
+
1315
+ ##
1316
+ # Commits a transaction. The request includes the mutations to be
1317
+ # applied to rows in the database.
1318
+ #
1319
+ # `Commit` might return an `ABORTED` error. This can occur at any time;
1320
+ # commonly, the cause is conflicts with concurrent
1321
+ # transactions. However, it can also happen for a variety of other
1322
+ # reasons. If `Commit` returns `ABORTED`, the caller should re-attempt
1323
+ # the transaction from the beginning, re-using the same session.
1324
+ #
1325
+ # @overload commit(request, options = nil)
1326
+ # Pass arguments to `commit` via a request object, either of type
1327
+ # {::Google::Cloud::Spanner::V1::CommitRequest} or an equivalent Hash.
1328
+ #
1329
+ # @param request [::Google::Cloud::Spanner::V1::CommitRequest, ::Hash]
1330
+ # A request object representing the call parameters. Required. To specify no
1331
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1332
+ # @param options [::Gapic::CallOptions, ::Hash]
1333
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1334
+ #
1335
+ # @overload commit(session: nil, transaction_id: nil, single_use_transaction: nil, mutations: nil)
1336
+ # Pass arguments to `commit` via keyword arguments. Note that at
1337
+ # least one keyword argument is required. To specify no parameters, or to keep all
1338
+ # the default parameter values, pass an empty Hash as a request object (see above).
1339
+ #
1340
+ # @param session [::String]
1341
+ # Required. The session in which the transaction to be committed is running.
1342
+ # @param transaction_id [::String]
1343
+ # Commit a previously-started transaction.
1344
+ # @param single_use_transaction [::Google::Cloud::Spanner::V1::TransactionOptions, ::Hash]
1345
+ # Execute mutations in a temporary transaction. Note that unlike
1346
+ # commit of a previously-started transaction, commit with a
1347
+ # temporary transaction is non-idempotent. That is, if the
1348
+ # `CommitRequest` is sent to Cloud Spanner more than once (for
1349
+ # instance, due to retries in the application, or in the
1350
+ # transport library), it is possible that the mutations are
1351
+ # executed more than once. If this is undesirable, use
1352
+ # {::Google::Cloud::Spanner::V1::Spanner::Client#begin_transaction BeginTransaction} and
1353
+ # {::Google::Cloud::Spanner::V1::Spanner::Client#commit Commit} instead.
1354
+ # @param mutations [::Array<::Google::Cloud::Spanner::V1::Mutation, ::Hash>]
1355
+ # The mutations to be executed when this transaction commits. All
1356
+ # mutations are applied atomically, in the order they appear in
1357
+ # this list.
1358
+ #
1359
+ # @yield [response, operation] Access the result along with the RPC operation
1360
+ # @yieldparam response [::Google::Cloud::Spanner::V1::CommitResponse]
1361
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1362
+ #
1363
+ # @return [::Google::Cloud::Spanner::V1::CommitResponse]
1364
+ #
1365
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1366
+ #
1367
+ def commit request, options = nil
1368
+ raise ::ArgumentError, "request must be provided" if request.nil?
1369
+
1370
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::CommitRequest
1371
+
1372
+ # Converts hash and nil to an options object
1373
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1374
+
1375
+ # Customize the options with defaults
1376
+ metadata = @config.rpcs.commit.metadata.to_h
1377
+
1378
+ # Set x-goog-api-client and x-goog-user-project headers
1379
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1380
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1381
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1382
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1383
+
1384
+ header_params = {
1385
+ "session" => request.session
1386
+ }
1387
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1388
+ metadata[:"x-goog-request-params"] ||= request_params_header
1389
+
1390
+ options.apply_defaults timeout: @config.rpcs.commit.timeout,
1391
+ metadata: metadata,
1392
+ retry_policy: @config.rpcs.commit.retry_policy
1393
+ options.apply_defaults metadata: @config.metadata,
1394
+ retry_policy: @config.retry_policy
1395
+
1396
+ @spanner_stub.call_rpc :commit, request, options: options do |response, operation|
1397
+ yield response, operation if block_given?
1398
+ return response
1399
+ end
1400
+ rescue ::GRPC::BadStatus => e
1401
+ raise ::Google::Cloud::Error.from_error(e)
1402
+ end
1403
+
1404
+ ##
1405
+ # Rolls back a transaction, releasing any locks it holds. It is a good
1406
+ # idea to call this for any transaction that includes one or more
1407
+ # {::Google::Cloud::Spanner::V1::Spanner::Client#read Read} or {::Google::Cloud::Spanner::V1::Spanner::Client#execute_sql ExecuteSql} requests and
1408
+ # ultimately decides not to commit.
1409
+ #
1410
+ # `Rollback` returns `OK` if it successfully aborts the transaction, the
1411
+ # transaction was already aborted, or the transaction is not
1412
+ # found. `Rollback` never returns `ABORTED`.
1413
+ #
1414
+ # @overload rollback(request, options = nil)
1415
+ # Pass arguments to `rollback` via a request object, either of type
1416
+ # {::Google::Cloud::Spanner::V1::RollbackRequest} or an equivalent Hash.
1417
+ #
1418
+ # @param request [::Google::Cloud::Spanner::V1::RollbackRequest, ::Hash]
1419
+ # A request object representing the call parameters. Required. To specify no
1420
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1421
+ # @param options [::Gapic::CallOptions, ::Hash]
1422
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1423
+ #
1424
+ # @overload rollback(session: nil, transaction_id: nil)
1425
+ # Pass arguments to `rollback` via keyword arguments. Note that at
1426
+ # least one keyword argument is required. To specify no parameters, or to keep all
1427
+ # the default parameter values, pass an empty Hash as a request object (see above).
1428
+ #
1429
+ # @param session [::String]
1430
+ # Required. The session in which the transaction to roll back is running.
1431
+ # @param transaction_id [::String]
1432
+ # Required. The transaction to roll back.
1433
+ #
1434
+ # @yield [response, operation] Access the result along with the RPC operation
1435
+ # @yieldparam response [::Google::Protobuf::Empty]
1436
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1437
+ #
1438
+ # @return [::Google::Protobuf::Empty]
1439
+ #
1440
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1441
+ #
1442
+ def rollback request, options = nil
1443
+ raise ::ArgumentError, "request must be provided" if request.nil?
1444
+
1445
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::RollbackRequest
1446
+
1447
+ # Converts hash and nil to an options object
1448
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1449
+
1450
+ # Customize the options with defaults
1451
+ metadata = @config.rpcs.rollback.metadata.to_h
1452
+
1453
+ # Set x-goog-api-client and x-goog-user-project headers
1454
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1455
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1456
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1457
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1458
+
1459
+ header_params = {
1460
+ "session" => request.session
1461
+ }
1462
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1463
+ metadata[:"x-goog-request-params"] ||= request_params_header
1464
+
1465
+ options.apply_defaults timeout: @config.rpcs.rollback.timeout,
1466
+ metadata: metadata,
1467
+ retry_policy: @config.rpcs.rollback.retry_policy
1468
+ options.apply_defaults metadata: @config.metadata,
1469
+ retry_policy: @config.retry_policy
1470
+
1471
+ @spanner_stub.call_rpc :rollback, request, options: options do |response, operation|
1472
+ yield response, operation if block_given?
1473
+ return response
1474
+ end
1475
+ rescue ::GRPC::BadStatus => e
1476
+ raise ::Google::Cloud::Error.from_error(e)
1477
+ end
1478
+
1479
+ ##
1480
+ # Creates a set of partition tokens that can be used to execute a query
1481
+ # operation in parallel. Each of the returned partition tokens can be used
1482
+ # by {::Google::Cloud::Spanner::V1::Spanner::Client#execute_streaming_sql ExecuteStreamingSql} to specify a subset
1483
+ # of the query result to read. The same session and read-only transaction
1484
+ # must be used by the PartitionQueryRequest used to create the
1485
+ # partition tokens and the ExecuteSqlRequests that use the partition tokens.
1486
+ #
1487
+ # Partition tokens become invalid when the session used to create them
1488
+ # is deleted, is idle for too long, begins a new transaction, or becomes too
1489
+ # old. When any of these happen, it is not possible to resume the query, and
1490
+ # the whole operation must be restarted from the beginning.
1491
+ #
1492
+ # @overload partition_query(request, options = nil)
1493
+ # Pass arguments to `partition_query` via a request object, either of type
1494
+ # {::Google::Cloud::Spanner::V1::PartitionQueryRequest} or an equivalent Hash.
1495
+ #
1496
+ # @param request [::Google::Cloud::Spanner::V1::PartitionQueryRequest, ::Hash]
1497
+ # A request object representing the call parameters. Required. To specify no
1498
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1499
+ # @param options [::Gapic::CallOptions, ::Hash]
1500
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1501
+ #
1502
+ # @overload partition_query(session: nil, transaction: nil, sql: nil, params: nil, param_types: nil, partition_options: nil)
1503
+ # Pass arguments to `partition_query` via keyword arguments. Note that at
1504
+ # least one keyword argument is required. To specify no parameters, or to keep all
1505
+ # the default parameter values, pass an empty Hash as a request object (see above).
1506
+ #
1507
+ # @param session [::String]
1508
+ # Required. The session used to create the partitions.
1509
+ # @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
1510
+ # Read only snapshot transactions are supported, read/write and single use
1511
+ # transactions are not.
1512
+ # @param sql [::String]
1513
+ # Required. The query request to generate partitions for. The request will fail if
1514
+ # the query is not root partitionable. The query plan of a root
1515
+ # partitionable query has a single distributed union operator. A distributed
1516
+ # union operator conceptually divides one or more tables into multiple
1517
+ # splits, remotely evaluates a subquery independently on each split, and
1518
+ # then unions all results.
1519
+ #
1520
+ # This must not contain DML commands, such as INSERT, UPDATE, or
1521
+ # DELETE. Use {::Google::Cloud::Spanner::V1::Spanner::Client#execute_streaming_sql ExecuteStreamingSql} with a
1522
+ # PartitionedDml transaction for large, partition-friendly DML operations.
1523
+ # @param params [::Google::Protobuf::Struct, ::Hash]
1524
+ # Parameter names and values that bind to placeholders in the SQL string.
1525
+ #
1526
+ # A parameter placeholder consists of the `@` character followed by the
1527
+ # parameter name (for example, `@firstName`). Parameter names can contain
1528
+ # letters, numbers, and underscores.
1529
+ #
1530
+ # Parameters can appear anywhere that a literal value is expected. The same
1531
+ # parameter name can be used more than once, for example:
1532
+ #
1533
+ # `"WHERE id > @msg_id AND id < @msg_id + 100"`
1534
+ #
1535
+ # It is an error to execute a SQL statement with unbound parameters.
1536
+ # @param param_types [::Hash{::String => ::Google::Cloud::Spanner::V1::Type, ::Hash}]
1537
+ # It is not always possible for Cloud Spanner to infer the right SQL type
1538
+ # from a JSON value. For example, values of type `BYTES` and values
1539
+ # of type `STRING` both appear in {::Google::Cloud::Spanner::V1::PartitionQueryRequest#params params} as JSON strings.
1540
+ #
1541
+ # In these cases, `param_types` can be used to specify the exact
1542
+ # SQL type for some or all of the SQL query parameters. See the
1543
+ # definition of {::Google::Cloud::Spanner::V1::Type Type} for more information
1544
+ # about SQL types.
1545
+ # @param partition_options [::Google::Cloud::Spanner::V1::PartitionOptions, ::Hash]
1546
+ # Additional options that affect how many partitions are created.
1547
+ #
1548
+ # @yield [response, operation] Access the result along with the RPC operation
1549
+ # @yieldparam response [::Google::Cloud::Spanner::V1::PartitionResponse]
1550
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1551
+ #
1552
+ # @return [::Google::Cloud::Spanner::V1::PartitionResponse]
1553
+ #
1554
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1555
+ #
1556
+ def partition_query request, options = nil
1557
+ raise ::ArgumentError, "request must be provided" if request.nil?
1558
+
1559
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::PartitionQueryRequest
1560
+
1561
+ # Converts hash and nil to an options object
1562
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1563
+
1564
+ # Customize the options with defaults
1565
+ metadata = @config.rpcs.partition_query.metadata.to_h
1566
+
1567
+ # Set x-goog-api-client and x-goog-user-project headers
1568
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1569
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1570
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1571
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1572
+
1573
+ header_params = {
1574
+ "session" => request.session
1575
+ }
1576
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1577
+ metadata[:"x-goog-request-params"] ||= request_params_header
1578
+
1579
+ options.apply_defaults timeout: @config.rpcs.partition_query.timeout,
1580
+ metadata: metadata,
1581
+ retry_policy: @config.rpcs.partition_query.retry_policy
1582
+ options.apply_defaults metadata: @config.metadata,
1583
+ retry_policy: @config.retry_policy
1584
+
1585
+ @spanner_stub.call_rpc :partition_query, request, options: options do |response, operation|
1586
+ yield response, operation if block_given?
1587
+ return response
1588
+ end
1589
+ rescue ::GRPC::BadStatus => e
1590
+ raise ::Google::Cloud::Error.from_error(e)
1591
+ end
1592
+
1593
+ ##
1594
+ # Creates a set of partition tokens that can be used to execute a read
1595
+ # operation in parallel. Each of the returned partition tokens can be used
1596
+ # by {::Google::Cloud::Spanner::V1::Spanner::Client#streaming_read StreamingRead} to specify a subset of the read
1597
+ # result to read. The same session and read-only transaction must be used by
1598
+ # the PartitionReadRequest used to create the partition tokens and the
1599
+ # ReadRequests that use the partition tokens. There are no ordering
1600
+ # guarantees on rows returned among the returned partition tokens, or even
1601
+ # within each individual StreamingRead call issued with a partition_token.
1602
+ #
1603
+ # Partition tokens become invalid when the session used to create them
1604
+ # is deleted, is idle for too long, begins a new transaction, or becomes too
1605
+ # old. When any of these happen, it is not possible to resume the read, and
1606
+ # the whole operation must be restarted from the beginning.
1607
+ #
1608
+ # @overload partition_read(request, options = nil)
1609
+ # Pass arguments to `partition_read` via a request object, either of type
1610
+ # {::Google::Cloud::Spanner::V1::PartitionReadRequest} or an equivalent Hash.
1611
+ #
1612
+ # @param request [::Google::Cloud::Spanner::V1::PartitionReadRequest, ::Hash]
1613
+ # A request object representing the call parameters. Required. To specify no
1614
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1615
+ # @param options [::Gapic::CallOptions, ::Hash]
1616
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1617
+ #
1618
+ # @overload partition_read(session: nil, transaction: nil, table: nil, index: nil, columns: nil, key_set: nil, partition_options: nil)
1619
+ # Pass arguments to `partition_read` via keyword arguments. Note that at
1620
+ # least one keyword argument is required. To specify no parameters, or to keep all
1621
+ # the default parameter values, pass an empty Hash as a request object (see above).
1622
+ #
1623
+ # @param session [::String]
1624
+ # Required. The session used to create the partitions.
1625
+ # @param transaction [::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash]
1626
+ # Read only snapshot transactions are supported, read/write and single use
1627
+ # transactions are not.
1628
+ # @param table [::String]
1629
+ # Required. The name of the table in the database to be read.
1630
+ # @param index [::String]
1631
+ # If non-empty, the name of an index on {::Google::Cloud::Spanner::V1::PartitionReadRequest#table table}. This index is
1632
+ # used instead of the table primary key when interpreting {::Google::Cloud::Spanner::V1::PartitionReadRequest#key_set key_set}
1633
+ # and sorting result rows. See {::Google::Cloud::Spanner::V1::PartitionReadRequest#key_set key_set} for further information.
1634
+ # @param columns [::Array<::String>]
1635
+ # The columns of {::Google::Cloud::Spanner::V1::PartitionReadRequest#table table} to be returned for each row matching
1636
+ # this request.
1637
+ # @param key_set [::Google::Cloud::Spanner::V1::KeySet, ::Hash]
1638
+ # Required. `key_set` identifies the rows to be yielded. `key_set` names the
1639
+ # primary keys of the rows in {::Google::Cloud::Spanner::V1::PartitionReadRequest#table table} to be yielded, unless {::Google::Cloud::Spanner::V1::PartitionReadRequest#index index}
1640
+ # is present. If {::Google::Cloud::Spanner::V1::PartitionReadRequest#index index} is present, then {::Google::Cloud::Spanner::V1::PartitionReadRequest#key_set key_set} instead names
1641
+ # index keys in {::Google::Cloud::Spanner::V1::PartitionReadRequest#index index}.
1642
+ #
1643
+ # It is not an error for the `key_set` to name rows that do not
1644
+ # exist in the database. Read yields nothing for nonexistent rows.
1645
+ # @param partition_options [::Google::Cloud::Spanner::V1::PartitionOptions, ::Hash]
1646
+ # Additional options that affect how many partitions are created.
1647
+ #
1648
+ # @yield [response, operation] Access the result along with the RPC operation
1649
+ # @yieldparam response [::Google::Cloud::Spanner::V1::PartitionResponse]
1650
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1651
+ #
1652
+ # @return [::Google::Cloud::Spanner::V1::PartitionResponse]
1653
+ #
1654
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1655
+ #
1656
+ def partition_read request, options = nil
1657
+ raise ::ArgumentError, "request must be provided" if request.nil?
1658
+
1659
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::PartitionReadRequest
1660
+
1661
+ # Converts hash and nil to an options object
1662
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1663
+
1664
+ # Customize the options with defaults
1665
+ metadata = @config.rpcs.partition_read.metadata.to_h
1666
+
1667
+ # Set x-goog-api-client and x-goog-user-project headers
1668
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1669
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1670
+ gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1671
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1672
+
1673
+ header_params = {
1674
+ "session" => request.session
1675
+ }
1676
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1677
+ metadata[:"x-goog-request-params"] ||= request_params_header
1678
+
1679
+ options.apply_defaults timeout: @config.rpcs.partition_read.timeout,
1680
+ metadata: metadata,
1681
+ retry_policy: @config.rpcs.partition_read.retry_policy
1682
+ options.apply_defaults metadata: @config.metadata,
1683
+ retry_policy: @config.retry_policy
1684
+
1685
+ @spanner_stub.call_rpc :partition_read, request, options: options do |response, operation|
1686
+ yield response, operation if block_given?
1687
+ return response
1688
+ end
1689
+ rescue ::GRPC::BadStatus => e
1690
+ raise ::Google::Cloud::Error.from_error(e)
1691
+ end
1692
+
1693
+ ##
1694
+ # Configuration class for the Spanner API.
1695
+ #
1696
+ # This class represents the configuration for Spanner,
1697
+ # providing control over timeouts, retry behavior, logging, transport
1698
+ # parameters, and other low-level controls. Certain parameters can also be
1699
+ # applied individually to specific RPCs. See
1700
+ # {::Google::Cloud::Spanner::V1::Spanner::Client::Configuration::Rpcs}
1701
+ # for a list of RPCs that can be configured independently.
1702
+ #
1703
+ # Configuration can be applied globally to all clients, or to a single client
1704
+ # on construction.
1705
+ #
1706
+ # # Examples
1707
+ #
1708
+ # To modify the global config, setting the timeout for create_session
1709
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
1710
+ #
1711
+ # ::Google::Cloud::Spanner::V1::Spanner::Client.configure do |config|
1712
+ # config.timeout = 10.0
1713
+ # config.rpcs.create_session.timeout = 20.0
1714
+ # end
1715
+ #
1716
+ # To apply the above configuration only to a new client:
1717
+ #
1718
+ # client = ::Google::Cloud::Spanner::V1::Spanner::Client.new do |config|
1719
+ # config.timeout = 10.0
1720
+ # config.rpcs.create_session.timeout = 20.0
1721
+ # end
1722
+ #
1723
+ # @!attribute [rw] endpoint
1724
+ # The hostname or hostname:port of the service endpoint.
1725
+ # Defaults to `"spanner.googleapis.com"`.
1726
+ # @return [::String]
1727
+ # @!attribute [rw] credentials
1728
+ # Credentials to send with calls. You may provide any of the following types:
1729
+ # * (`String`) The path to a service account key file in JSON format
1730
+ # * (`Hash`) A service account key as a Hash
1731
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1732
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
1733
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1734
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
1735
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
1736
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
1737
+ # * (`nil`) indicating no credentials
1738
+ # @return [::Object]
1739
+ # @!attribute [rw] scope
1740
+ # The OAuth scopes
1741
+ # @return [::Array<::String>]
1742
+ # @!attribute [rw] lib_name
1743
+ # The library name as recorded in instrumentation and logging
1744
+ # @return [::String]
1745
+ # @!attribute [rw] lib_version
1746
+ # The library version as recorded in instrumentation and logging
1747
+ # @return [::String]
1748
+ # @!attribute [rw] channel_args
1749
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
1750
+ # `GRPC::Core::Channel` object is provided as the credential.
1751
+ # @return [::Hash]
1752
+ # @!attribute [rw] interceptors
1753
+ # An array of interceptors that are run before calls are executed.
1754
+ # @return [::Array<::GRPC::ClientInterceptor>]
1755
+ # @!attribute [rw] timeout
1756
+ # The call timeout in seconds.
1757
+ # @return [::Numeric]
1758
+ # @!attribute [rw] metadata
1759
+ # Additional gRPC headers to be sent with the call.
1760
+ # @return [::Hash{::Symbol=>::String}]
1761
+ # @!attribute [rw] retry_policy
1762
+ # The retry policy. The value is a hash with the following keys:
1763
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1764
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1765
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1766
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1767
+ # trigger a retry.
1768
+ # @return [::Hash]
1769
+ # @!attribute [rw] quota_project
1770
+ # A separate project against which to charge quota.
1771
+ # @return [::String]
1772
+ #
1773
+ class Configuration
1774
+ extend ::Gapic::Config
1775
+
1776
+ config_attr :endpoint, "spanner.googleapis.com", ::String
1777
+ config_attr :credentials, nil do |value|
1778
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1779
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
1780
+ allowed.any? { |klass| klass === value }
1781
+ end
1782
+ config_attr :scope, nil, ::String, ::Array, nil
1783
+ config_attr :lib_name, nil, ::String, nil
1784
+ config_attr :lib_version, nil, ::String, nil
1785
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
1786
+ config_attr :interceptors, nil, ::Array, nil
1787
+ config_attr :timeout, nil, ::Numeric, nil
1788
+ config_attr :metadata, nil, ::Hash, nil
1789
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1790
+ config_attr :quota_project, nil, ::String, nil
1791
+
1792
+ # @private
1793
+ def initialize parent_config = nil
1794
+ @parent_config = parent_config unless parent_config.nil?
1795
+
1796
+ yield self if block_given?
1797
+ end
1798
+
1799
+ ##
1800
+ # Configurations for individual RPCs
1801
+ # @return [Rpcs]
1802
+ #
1803
+ def rpcs
1804
+ @rpcs ||= begin
1805
+ parent_rpcs = nil
1806
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
1807
+ Rpcs.new parent_rpcs
1808
+ end
1809
+ end
1810
+
1811
+ ##
1812
+ # Configuration RPC class for the Spanner API.
1813
+ #
1814
+ # Includes fields providing the configuration for each RPC in this service.
1815
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1816
+ # the following configuration fields:
1817
+ #
1818
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
1819
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1820
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1821
+ # include the following keys:
1822
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1823
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1824
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1825
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1826
+ # trigger a retry.
1827
+ #
1828
+ class Rpcs
1829
+ ##
1830
+ # RPC-specific configuration for `create_session`
1831
+ # @return [::Gapic::Config::Method]
1832
+ #
1833
+ attr_reader :create_session
1834
+ ##
1835
+ # RPC-specific configuration for `batch_create_sessions`
1836
+ # @return [::Gapic::Config::Method]
1837
+ #
1838
+ attr_reader :batch_create_sessions
1839
+ ##
1840
+ # RPC-specific configuration for `get_session`
1841
+ # @return [::Gapic::Config::Method]
1842
+ #
1843
+ attr_reader :get_session
1844
+ ##
1845
+ # RPC-specific configuration for `list_sessions`
1846
+ # @return [::Gapic::Config::Method]
1847
+ #
1848
+ attr_reader :list_sessions
1849
+ ##
1850
+ # RPC-specific configuration for `delete_session`
1851
+ # @return [::Gapic::Config::Method]
1852
+ #
1853
+ attr_reader :delete_session
1854
+ ##
1855
+ # RPC-specific configuration for `execute_sql`
1856
+ # @return [::Gapic::Config::Method]
1857
+ #
1858
+ attr_reader :execute_sql
1859
+ ##
1860
+ # RPC-specific configuration for `execute_streaming_sql`
1861
+ # @return [::Gapic::Config::Method]
1862
+ #
1863
+ attr_reader :execute_streaming_sql
1864
+ ##
1865
+ # RPC-specific configuration for `execute_batch_dml`
1866
+ # @return [::Gapic::Config::Method]
1867
+ #
1868
+ attr_reader :execute_batch_dml
1869
+ ##
1870
+ # RPC-specific configuration for `read`
1871
+ # @return [::Gapic::Config::Method]
1872
+ #
1873
+ attr_reader :read
1874
+ ##
1875
+ # RPC-specific configuration for `streaming_read`
1876
+ # @return [::Gapic::Config::Method]
1877
+ #
1878
+ attr_reader :streaming_read
1879
+ ##
1880
+ # RPC-specific configuration for `begin_transaction`
1881
+ # @return [::Gapic::Config::Method]
1882
+ #
1883
+ attr_reader :begin_transaction
1884
+ ##
1885
+ # RPC-specific configuration for `commit`
1886
+ # @return [::Gapic::Config::Method]
1887
+ #
1888
+ attr_reader :commit
1889
+ ##
1890
+ # RPC-specific configuration for `rollback`
1891
+ # @return [::Gapic::Config::Method]
1892
+ #
1893
+ attr_reader :rollback
1894
+ ##
1895
+ # RPC-specific configuration for `partition_query`
1896
+ # @return [::Gapic::Config::Method]
1897
+ #
1898
+ attr_reader :partition_query
1899
+ ##
1900
+ # RPC-specific configuration for `partition_read`
1901
+ # @return [::Gapic::Config::Method]
1902
+ #
1903
+ attr_reader :partition_read
1904
+
1905
+ # @private
1906
+ def initialize parent_rpcs = nil
1907
+ create_session_config = parent_rpcs&.create_session if parent_rpcs&.respond_to? :create_session
1908
+ @create_session = ::Gapic::Config::Method.new create_session_config
1909
+ batch_create_sessions_config = parent_rpcs&.batch_create_sessions if parent_rpcs&.respond_to? :batch_create_sessions
1910
+ @batch_create_sessions = ::Gapic::Config::Method.new batch_create_sessions_config
1911
+ get_session_config = parent_rpcs&.get_session if parent_rpcs&.respond_to? :get_session
1912
+ @get_session = ::Gapic::Config::Method.new get_session_config
1913
+ list_sessions_config = parent_rpcs&.list_sessions if parent_rpcs&.respond_to? :list_sessions
1914
+ @list_sessions = ::Gapic::Config::Method.new list_sessions_config
1915
+ delete_session_config = parent_rpcs&.delete_session if parent_rpcs&.respond_to? :delete_session
1916
+ @delete_session = ::Gapic::Config::Method.new delete_session_config
1917
+ execute_sql_config = parent_rpcs&.execute_sql if parent_rpcs&.respond_to? :execute_sql
1918
+ @execute_sql = ::Gapic::Config::Method.new execute_sql_config
1919
+ execute_streaming_sql_config = parent_rpcs&.execute_streaming_sql if parent_rpcs&.respond_to? :execute_streaming_sql
1920
+ @execute_streaming_sql = ::Gapic::Config::Method.new execute_streaming_sql_config
1921
+ execute_batch_dml_config = parent_rpcs&.execute_batch_dml if parent_rpcs&.respond_to? :execute_batch_dml
1922
+ @execute_batch_dml = ::Gapic::Config::Method.new execute_batch_dml_config
1923
+ read_config = parent_rpcs&.read if parent_rpcs&.respond_to? :read
1924
+ @read = ::Gapic::Config::Method.new read_config
1925
+ streaming_read_config = parent_rpcs&.streaming_read if parent_rpcs&.respond_to? :streaming_read
1926
+ @streaming_read = ::Gapic::Config::Method.new streaming_read_config
1927
+ begin_transaction_config = parent_rpcs&.begin_transaction if parent_rpcs&.respond_to? :begin_transaction
1928
+ @begin_transaction = ::Gapic::Config::Method.new begin_transaction_config
1929
+ commit_config = parent_rpcs&.commit if parent_rpcs&.respond_to? :commit
1930
+ @commit = ::Gapic::Config::Method.new commit_config
1931
+ rollback_config = parent_rpcs&.rollback if parent_rpcs&.respond_to? :rollback
1932
+ @rollback = ::Gapic::Config::Method.new rollback_config
1933
+ partition_query_config = parent_rpcs&.partition_query if parent_rpcs&.respond_to? :partition_query
1934
+ @partition_query = ::Gapic::Config::Method.new partition_query_config
1935
+ partition_read_config = parent_rpcs&.partition_read if parent_rpcs&.respond_to? :partition_read
1936
+ @partition_read = ::Gapic::Config::Method.new partition_read_config
1937
+
1938
+ yield self if block_given?
1939
+ end
1940
+ end
1941
+ end
1942
+ end
1943
+ end
1944
+ end
1945
+ end
1946
+ end
1947
+ end