google-cloud-spanner 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/lib/google-cloud-spanner.rb +13 -10
  3. data/lib/google/cloud/spanner.rb +21 -18
  4. data/lib/google/cloud/spanner/admin/database.rb +111 -0
  5. data/lib/google/cloud/spanner/admin/database/credentials.rb +35 -0
  6. data/lib/google/cloud/spanner/admin/database/v1.rb +100 -3
  7. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +129 -138
  8. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +8 -8
  9. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +12 -2
  10. data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +22 -22
  11. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +33 -20
  12. data/lib/google/cloud/spanner/admin/database/v1/doc/overview.rb +57 -0
  13. data/lib/google/cloud/spanner/admin/instance.rb +127 -0
  14. data/lib/google/cloud/spanner/admin/instance/credentials.rb +35 -0
  15. data/lib/google/cloud/spanner/admin/instance/v1.rb +116 -3
  16. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +8 -8
  17. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +12 -2
  18. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +22 -22
  19. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +58 -43
  20. data/lib/google/cloud/spanner/admin/instance/v1/doc/overview.rb +57 -0
  21. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +180 -189
  22. data/lib/google/cloud/spanner/client.rb +3 -3
  23. data/lib/google/cloud/spanner/credentials.rb +33 -7
  24. data/lib/google/cloud/spanner/database.rb +3 -6
  25. data/lib/google/cloud/spanner/instance.rb +2 -4
  26. data/lib/google/cloud/spanner/instance/config.rb +2 -4
  27. data/lib/google/cloud/spanner/project.rb +6 -6
  28. data/lib/google/cloud/spanner/service.rb +5 -26
  29. data/lib/google/cloud/spanner/session.rb +4 -4
  30. data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +14 -1
  31. data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +26 -1
  32. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +3 -3
  33. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +12 -12
  34. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +9 -9
  35. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +33 -33
  36. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +99 -28
  37. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +41 -31
  38. data/lib/google/cloud/spanner/v1/doc/overview.rb +54 -0
  39. data/lib/google/cloud/spanner/v1/spanner_client.rb +277 -195
  40. data/lib/google/cloud/spanner/v1/spanner_client_config.json +5 -0
  41. data/lib/google/cloud/spanner/version.rb +1 -1
  42. data/lib/google/spanner/v1/spanner_pb.rb +16 -1
  43. data/lib/google/spanner/v1/spanner_services_pb.rb +2 -0
  44. metadata +16 -23
@@ -0,0 +1,54 @@
1
+ # Copyright 2017, Google Inc. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Cloud
17
+ # rubocop:disable LineLength
18
+
19
+ ##
20
+ # # Ruby Client for Cloud Spanner API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
+ #
22
+ # [Cloud Spanner API][Product Documentation]:
23
+ # Cloud Spanner is a managed, mission-critical, globally consistent and scalable
24
+ # relational database service.
25
+ # - [Product Documentation][]
26
+ #
27
+ # ## Quick Start
28
+ # In order to use this library, you first need to go through the following
29
+ # steps:
30
+ #
31
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
32
+ # 2. [Enable the Cloud Spanner API.](https://console.cloud.google.com/apis/api/spanner)
33
+ # 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
34
+ #
35
+ # ### Installation
36
+ # ```
37
+ # $ gem install google-cloud-spanner
38
+ # ```
39
+ #
40
+ # ### Next Steps
41
+ # - Read the [Cloud Spanner API Product documentation][Product Documentation]
42
+ # to learn more about the product and see How-to Guides.
43
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
44
+ # to see the full list of Cloud APIs that we cover.
45
+ #
46
+ # [Product Documentation]: https://cloud.google.com/spanner
47
+ #
48
+ #
49
+ module Spanner
50
+ module V1
51
+ end
52
+ end
53
+ end
54
+ end
@@ -28,6 +28,7 @@ require "pathname"
28
28
  require "google/gax"
29
29
 
30
30
  require "google/spanner/v1/spanner_pb"
31
+ require "google/cloud/spanner/credentials"
31
32
 
32
33
  module Google
33
34
  module Cloud
@@ -51,6 +52,15 @@ module Google
51
52
 
52
53
  DEFAULT_TIMEOUT = 30
53
54
 
55
+ PAGE_DESCRIPTORS = {
56
+ "list_sessions" => Google::Gax::PageDescriptor.new(
57
+ "page_token",
58
+ "next_page_token",
59
+ "sessions")
60
+ }.freeze
61
+
62
+ private_constant :PAGE_DESCRIPTORS
63
+
54
64
  # The scopes needed to make gRPC calls to all of the methods defined in
55
65
  # this service.
56
66
  ALL_SCOPES = [
@@ -98,64 +108,24 @@ module Google
98
108
  )
99
109
  end
100
110
 
101
- # Parses the project from a database resource.
102
- # @param database_name [String]
103
- # @return [String]
104
- def self.match_project_from_database_name database_name
105
- DATABASE_PATH_TEMPLATE.match(database_name)["project"]
106
- end
107
-
108
- # Parses the instance from a database resource.
109
- # @param database_name [String]
110
- # @return [String]
111
- def self.match_instance_from_database_name database_name
112
- DATABASE_PATH_TEMPLATE.match(database_name)["instance"]
113
- end
114
-
115
- # Parses the database from a database resource.
116
- # @param database_name [String]
117
- # @return [String]
118
- def self.match_database_from_database_name database_name
119
- DATABASE_PATH_TEMPLATE.match(database_name)["database"]
120
- end
121
-
122
- # Parses the project from a session resource.
123
- # @param session_name [String]
124
- # @return [String]
125
- def self.match_project_from_session_name session_name
126
- SESSION_PATH_TEMPLATE.match(session_name)["project"]
127
- end
128
-
129
- # Parses the instance from a session resource.
130
- # @param session_name [String]
131
- # @return [String]
132
- def self.match_instance_from_session_name session_name
133
- SESSION_PATH_TEMPLATE.match(session_name)["instance"]
134
- end
135
-
136
- # Parses the database from a session resource.
137
- # @param session_name [String]
138
- # @return [String]
139
- def self.match_database_from_session_name session_name
140
- SESSION_PATH_TEMPLATE.match(session_name)["database"]
141
- end
142
-
143
- # Parses the session from a session resource.
144
- # @param session_name [String]
145
- # @return [String]
146
- def self.match_session_from_session_name session_name
147
- SESSION_PATH_TEMPLATE.match(session_name)["session"]
148
- end
149
-
150
- # @param service_path [String]
151
- # The domain name of the API remote host.
152
- # @param port [Integer]
153
- # The port on which to connect to the remote host.
154
- # @param channel [Channel]
155
- # A Channel object through which to make calls.
156
- # @param chan_creds [Grpc::ChannelCredentials]
157
- # A ChannelCredentials for the setting up the RPC client.
158
- # @param client_config[Hash]
111
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
112
+ # Provides the means for authenticating requests made by the client. This parameter can
113
+ # be many types.
114
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
115
+ # authenticating requests made by this client.
116
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
117
+ # credentials for this client.
118
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
119
+ # credentials for this client.
120
+ # A `GRPC::Core::Channel` will be used to make calls through.
121
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
122
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
123
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
124
+ # metadata for requests, generally, to give OAuth credentials.
125
+ # @param scopes [Array<String>]
126
+ # The OAuth scopes for this service. This parameter is ignored if
127
+ # an updater_proc is supplied.
128
+ # @param client_config [Hash]
159
129
  # A Hash for call options for each method. See
160
130
  # Google::Gax#construct_settings for the structure of
161
131
  # this data. Falls back to the default config if not specified
@@ -167,11 +137,11 @@ module Google
167
137
  port: DEFAULT_SERVICE_PORT,
168
138
  channel: nil,
169
139
  chan_creds: nil,
140
+ updater_proc: nil,
141
+ credentials: nil,
170
142
  scopes: ALL_SCOPES,
171
143
  client_config: {},
172
144
  timeout: DEFAULT_TIMEOUT,
173
- app_name: nil,
174
- app_version: nil,
175
145
  lib_name: nil,
176
146
  lib_version: ""
177
147
  # These require statements are intentionally placed here to initialize
@@ -180,14 +150,38 @@ module Google
180
150
  require "google/gax/grpc"
181
151
  require "google/spanner/v1/spanner_services_pb"
182
152
 
153
+ if channel || chan_creds || updater_proc
154
+ warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
155
+ "on 2017/09/08"
156
+ credentials ||= channel
157
+ credentials ||= chan_creds
158
+ credentials ||= updater_proc
159
+ end
160
+ if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
161
+ warn "`service_path` and `port` parameters are deprecated and will be removed"
162
+ end
183
163
 
184
- if app_name || app_version
185
- warn "`app_name` and `app_version` are no longer being used in the request headers."
164
+ credentials ||= Google::Cloud::Spanner::Credentials.default
165
+
166
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
167
+ updater_proc = Google::Cloud::Spanner::Credentials.new(credentials).updater_proc
168
+ end
169
+ if credentials.is_a?(GRPC::Core::Channel)
170
+ channel = credentials
171
+ end
172
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
173
+ chan_creds = credentials
174
+ end
175
+ if credentials.is_a?(Proc)
176
+ updater_proc = credentials
177
+ end
178
+ if credentials.is_a?(Google::Auth::Credentials)
179
+ updater_proc = credentials.updater_proc
186
180
  end
187
181
 
188
182
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
189
183
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
190
- google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
184
+ google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
191
185
  google_api_client << " grpc/#{GRPC::VERSION}"
192
186
  google_api_client.freeze
193
187
 
@@ -202,6 +196,7 @@ module Google
202
196
  client_config,
203
197
  Google::Gax::Grpc::STATUS_CODE_NAMES,
204
198
  timeout,
199
+ page_descriptors: PAGE_DESCRIPTORS,
205
200
  errors: Google::Gax::Grpc::API_ERRORS,
206
201
  kwargs: headers
207
202
  )
@@ -211,6 +206,7 @@ module Google
211
206
  port,
212
207
  chan_creds: chan_creds,
213
208
  channel: channel,
209
+ updater_proc: updater_proc,
214
210
  scopes: scopes,
215
211
  &Google::Spanner::V1::Spanner::Stub.method(:new)
216
212
  )
@@ -223,6 +219,10 @@ module Google
223
219
  @spanner_stub.method(:get_session),
224
220
  defaults["get_session"]
225
221
  )
222
+ @list_sessions = Google::Gax.create_api_call(
223
+ @spanner_stub.method(:list_sessions),
224
+ defaults["list_sessions"]
225
+ )
226
226
  @delete_session = Google::Gax.create_api_call(
227
227
  @spanner_stub.method(:delete_session),
228
228
  defaults["delete_session"]
@@ -281,26 +281,31 @@ module Google
281
281
  #
282
282
  # @param database [String]
283
283
  # Required. The database in which the new session is created.
284
+ # @param session [Google::Spanner::V1::Session | Hash]
285
+ # The session to create.
286
+ # A hash of the same form as `Google::Spanner::V1::Session`
287
+ # can also be provided.
284
288
  # @param options [Google::Gax::CallOptions]
285
289
  # Overrides the default settings for this call, e.g, timeout,
286
290
  # retries, etc.
287
291
  # @return [Google::Spanner::V1::Session]
288
292
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
289
293
  # @example
290
- # require "google/cloud/spanner/v1/spanner_client"
291
- #
292
- # SpannerClient = Google::Cloud::Spanner::V1::SpannerClient
294
+ # require "google/cloud/spanner/v1"
293
295
  #
294
- # spanner_client = SpannerClient.new
295
- # formatted_database = SpannerClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
296
+ # spanner_client = Google::Cloud::Spanner::V1.new
297
+ # formatted_database = Google::Cloud::Spanner::V1::SpannerClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
296
298
  # response = spanner_client.create_session(formatted_database)
297
299
 
298
300
  def create_session \
299
301
  database,
302
+ session: nil,
300
303
  options: nil
301
- req = Google::Spanner::V1::CreateSessionRequest.new({
302
- database: database
303
- }.delete_if { |_, v| v.nil? })
304
+ req = {
305
+ database: database,
306
+ session: session
307
+ }.delete_if { |_, v| v.nil? }
308
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::CreateSessionRequest)
304
309
  @create_session.call(req, options)
305
310
  end
306
311
 
@@ -316,23 +321,85 @@ module Google
316
321
  # @return [Google::Spanner::V1::Session]
317
322
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
318
323
  # @example
319
- # require "google/cloud/spanner/v1/spanner_client"
324
+ # require "google/cloud/spanner/v1"
320
325
  #
321
- # SpannerClient = Google::Cloud::Spanner::V1::SpannerClient
322
- #
323
- # spanner_client = SpannerClient.new
324
- # formatted_name = SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
326
+ # spanner_client = Google::Cloud::Spanner::V1.new
327
+ # formatted_name = Google::Cloud::Spanner::V1::SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
325
328
  # response = spanner_client.get_session(formatted_name)
326
329
 
327
330
  def get_session \
328
331
  name,
329
332
  options: nil
330
- req = Google::Spanner::V1::GetSessionRequest.new({
333
+ req = {
331
334
  name: name
332
- }.delete_if { |_, v| v.nil? })
335
+ }.delete_if { |_, v| v.nil? }
336
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::GetSessionRequest)
333
337
  @get_session.call(req, options)
334
338
  end
335
339
 
340
+ # Lists all sessions in a given database.
341
+ #
342
+ # @param database [String]
343
+ # Required. The database in which to list sessions.
344
+ # @param page_size [Integer]
345
+ # The maximum number of resources contained in the underlying API
346
+ # response. If page streaming is performed per-resource, this
347
+ # parameter does not affect the return value. If page streaming is
348
+ # performed per-page, this determines the maximum number of
349
+ # resources in a page.
350
+ # @param filter [String]
351
+ # An expression for filtering the results of the request. Filter rules are
352
+ # case insensitive. The fields eligible for filtering are:
353
+ #
354
+ # * +labels.key+ where key is the name of a label
355
+ #
356
+ # Some examples of using filters are:
357
+ #
358
+ # * +labels.env:*+ --> The session has the label "env".
359
+ # * +labels.env:dev+ --> The session has the label "env" and the value of
360
+ # the label contains the string "dev".
361
+ # @param options [Google::Gax::CallOptions]
362
+ # Overrides the default settings for this call, e.g, timeout,
363
+ # retries, etc.
364
+ # @return [Google::Gax::PagedEnumerable<Google::Spanner::V1::Session>]
365
+ # An enumerable of Google::Spanner::V1::Session instances.
366
+ # See Google::Gax::PagedEnumerable documentation for other
367
+ # operations such as per-page iteration or access to the response
368
+ # object.
369
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
370
+ # @example
371
+ # require "google/cloud/spanner/v1"
372
+ #
373
+ # spanner_client = Google::Cloud::Spanner::V1.new
374
+ # formatted_database = Google::Cloud::Spanner::V1::SpannerClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
375
+ #
376
+ # # Iterate over all results.
377
+ # spanner_client.list_sessions(formatted_database).each do |element|
378
+ # # Process element.
379
+ # end
380
+ #
381
+ # # Or iterate over results one page at a time.
382
+ # spanner_client.list_sessions(formatted_database).each_page do |page|
383
+ # # Process each page at a time.
384
+ # page.each do |element|
385
+ # # Process element.
386
+ # end
387
+ # end
388
+
389
+ def list_sessions \
390
+ database,
391
+ page_size: nil,
392
+ filter: nil,
393
+ options: nil
394
+ req = {
395
+ database: database,
396
+ page_size: page_size,
397
+ filter: filter
398
+ }.delete_if { |_, v| v.nil? }
399
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::ListSessionsRequest)
400
+ @list_sessions.call(req, options)
401
+ end
402
+
336
403
  # Ends a session, releasing server resources associated with it.
337
404
  #
338
405
  # @param name [String]
@@ -342,20 +409,19 @@ module Google
342
409
  # retries, etc.
343
410
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
344
411
  # @example
345
- # require "google/cloud/spanner/v1/spanner_client"
346
- #
347
- # SpannerClient = Google::Cloud::Spanner::V1::SpannerClient
412
+ # require "google/cloud/spanner/v1"
348
413
  #
349
- # spanner_client = SpannerClient.new
350
- # formatted_name = SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
414
+ # spanner_client = Google::Cloud::Spanner::V1.new
415
+ # formatted_name = Google::Cloud::Spanner::V1::SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
351
416
  # spanner_client.delete_session(formatted_name)
352
417
 
353
418
  def delete_session \
354
419
  name,
355
420
  options: nil
356
- req = Google::Spanner::V1::DeleteSessionRequest.new({
421
+ req = {
357
422
  name: name
358
- }.delete_if { |_, v| v.nil? })
423
+ }.delete_if { |_, v| v.nil? }
424
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::DeleteSessionRequest)
359
425
  @delete_session.call(req, options)
360
426
  nil
361
427
  end
@@ -367,19 +433,21 @@ module Google
367
433
  #
368
434
  # Queries inside read-write transactions might return +ABORTED+. If
369
435
  # this occurs, the application should restart the transaction from
370
- # the beginning. See Transaction for more details.
436
+ # the beginning. See {Google::Spanner::V1::Transaction Transaction} for more details.
371
437
  #
372
438
  # Larger result sets can be fetched in streaming fashion by calling
373
- # ExecuteStreamingSql instead.
439
+ # {Google::Spanner::V1::Spanner::ExecuteStreamingSql ExecuteStreamingSql} instead.
374
440
  #
375
441
  # @param session [String]
376
442
  # Required. The session in which the SQL query should be performed.
377
443
  # @param sql [String]
378
444
  # Required. The SQL query string.
379
- # @param transaction [Google::Spanner::V1::TransactionSelector]
445
+ # @param transaction [Google::Spanner::V1::TransactionSelector | Hash]
380
446
  # The transaction to use. If none is provided, the default is a
381
447
  # temporary read-only transaction with strong concurrency.
382
- # @param params [Google::Protobuf::Struct]
448
+ # A hash of the same form as `Google::Spanner::V1::TransactionSelector`
449
+ # can also be provided.
450
+ # @param params [Google::Protobuf::Struct | Hash]
383
451
  # The SQL query string can contain parameter placeholders. A parameter
384
452
  # placeholder consists of +'@'+ followed by the parameter
385
453
  # name. Parameter names consist of any combination of letters,
@@ -394,37 +462,39 @@ module Google
394
462
  # Parameter values are specified using +params+, which is a JSON
395
463
  # object whose keys are parameter names, and whose values are the
396
464
  # corresponding parameter values.
397
- # @param param_types [Hash{String => Google::Spanner::V1::Type}]
465
+ # A hash of the same form as `Google::Protobuf::Struct`
466
+ # can also be provided.
467
+ # @param param_types [Hash{String => Google::Spanner::V1::Type | Hash}]
398
468
  # It is not always possible for Cloud Spanner to infer the right SQL type
399
469
  # from a JSON value. For example, values of type +BYTES+ and values
400
- # of type +STRING+ both appear in Params as JSON strings.
470
+ # of type +STRING+ both appear in {Google::Spanner::V1::ExecuteSqlRequest#params params} as JSON strings.
401
471
  #
402
472
  # In these cases, +param_types+ can be used to specify the exact
403
473
  # SQL type for some or all of the SQL query parameters. See the
404
- # definition of Type for more information
474
+ # definition of {Google::Spanner::V1::Type Type} for more information
405
475
  # about SQL types.
476
+ # A hash of the same form as `Google::Spanner::V1::Type`
477
+ # can also be provided.
406
478
  # @param resume_token [String]
407
479
  # If this request is resuming a previously interrupted SQL query
408
480
  # execution, +resume_token+ should be copied from the last
409
- # PartialResultSet yielded before the interruption. Doing this
481
+ # {Google::Spanner::V1::PartialResultSet PartialResultSet} yielded before the interruption. Doing this
410
482
  # enables the new SQL query execution to resume where the last one left
411
483
  # off. The rest of the request parameters must exactly match the
412
484
  # request that yielded this token.
413
485
  # @param query_mode [Google::Spanner::V1::ExecuteSqlRequest::QueryMode]
414
486
  # Used to control the amount of debugging information returned in
415
- # ResultSetStats.
487
+ # {Google::Spanner::V1::ResultSetStats ResultSetStats}.
416
488
  # @param options [Google::Gax::CallOptions]
417
489
  # Overrides the default settings for this call, e.g, timeout,
418
490
  # retries, etc.
419
491
  # @return [Google::Spanner::V1::ResultSet]
420
492
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
421
493
  # @example
422
- # require "google/cloud/spanner/v1/spanner_client"
494
+ # require "google/cloud/spanner/v1"
423
495
  #
424
- # SpannerClient = Google::Cloud::Spanner::V1::SpannerClient
425
- #
426
- # spanner_client = SpannerClient.new
427
- # formatted_session = SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
496
+ # spanner_client = Google::Cloud::Spanner::V1.new
497
+ # formatted_session = Google::Cloud::Spanner::V1::SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
428
498
  # sql = ''
429
499
  # response = spanner_client.execute_sql(formatted_session, sql)
430
500
 
@@ -437,7 +507,7 @@ module Google
437
507
  resume_token: nil,
438
508
  query_mode: nil,
439
509
  options: nil
440
- req = Google::Spanner::V1::ExecuteSqlRequest.new({
510
+ req = {
441
511
  session: session,
442
512
  sql: sql,
443
513
  transaction: transaction,
@@ -445,12 +515,13 @@ module Google
445
515
  param_types: param_types,
446
516
  resume_token: resume_token,
447
517
  query_mode: query_mode
448
- }.delete_if { |_, v| v.nil? })
518
+ }.delete_if { |_, v| v.nil? }
519
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::ExecuteSqlRequest)
449
520
  @execute_sql.call(req, options)
450
521
  end
451
522
 
452
- # Like ExecuteSql, except returns the result
453
- # set as a stream. Unlike ExecuteSql, there
523
+ # Like {Google::Spanner::V1::Spanner::ExecuteSql ExecuteSql}, except returns the result
524
+ # set as a stream. Unlike {Google::Spanner::V1::Spanner::ExecuteSql ExecuteSql}, there
454
525
  # is no limit on the size of the returned result set. However, no
455
526
  # individual row in the result set can exceed 100 MiB, and no
456
527
  # column value can exceed 10 MiB.
@@ -459,10 +530,12 @@ module Google
459
530
  # Required. The session in which the SQL query should be performed.
460
531
  # @param sql [String]
461
532
  # Required. The SQL query string.
462
- # @param transaction [Google::Spanner::V1::TransactionSelector]
533
+ # @param transaction [Google::Spanner::V1::TransactionSelector | Hash]
463
534
  # The transaction to use. If none is provided, the default is a
464
535
  # temporary read-only transaction with strong concurrency.
465
- # @param params [Google::Protobuf::Struct]
536
+ # A hash of the same form as `Google::Spanner::V1::TransactionSelector`
537
+ # can also be provided.
538
+ # @param params [Google::Protobuf::Struct | Hash]
466
539
  # The SQL query string can contain parameter placeholders. A parameter
467
540
  # placeholder consists of +'@'+ followed by the parameter
468
541
  # name. Parameter names consist of any combination of letters,
@@ -477,25 +550,29 @@ module Google
477
550
  # Parameter values are specified using +params+, which is a JSON
478
551
  # object whose keys are parameter names, and whose values are the
479
552
  # corresponding parameter values.
480
- # @param param_types [Hash{String => Google::Spanner::V1::Type}]
553
+ # A hash of the same form as `Google::Protobuf::Struct`
554
+ # can also be provided.
555
+ # @param param_types [Hash{String => Google::Spanner::V1::Type | Hash}]
481
556
  # It is not always possible for Cloud Spanner to infer the right SQL type
482
557
  # from a JSON value. For example, values of type +BYTES+ and values
483
- # of type +STRING+ both appear in Params as JSON strings.
558
+ # of type +STRING+ both appear in {Google::Spanner::V1::ExecuteSqlRequest#params params} as JSON strings.
484
559
  #
485
560
  # In these cases, +param_types+ can be used to specify the exact
486
561
  # SQL type for some or all of the SQL query parameters. See the
487
- # definition of Type for more information
562
+ # definition of {Google::Spanner::V1::Type Type} for more information
488
563
  # about SQL types.
564
+ # A hash of the same form as `Google::Spanner::V1::Type`
565
+ # can also be provided.
489
566
  # @param resume_token [String]
490
567
  # If this request is resuming a previously interrupted SQL query
491
568
  # execution, +resume_token+ should be copied from the last
492
- # PartialResultSet yielded before the interruption. Doing this
569
+ # {Google::Spanner::V1::PartialResultSet PartialResultSet} yielded before the interruption. Doing this
493
570
  # enables the new SQL query execution to resume where the last one left
494
571
  # off. The rest of the request parameters must exactly match the
495
572
  # request that yielded this token.
496
573
  # @param query_mode [Google::Spanner::V1::ExecuteSqlRequest::QueryMode]
497
574
  # Used to control the amount of debugging information returned in
498
- # ResultSetStats.
575
+ # {Google::Spanner::V1::ResultSetStats ResultSetStats}.
499
576
  # @param options [Google::Gax::CallOptions]
500
577
  # Overrides the default settings for this call, e.g, timeout,
501
578
  # retries, etc.
@@ -504,12 +581,10 @@ module Google
504
581
  #
505
582
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
506
583
  # @example
507
- # require "google/cloud/spanner/v1/spanner_client"
508
- #
509
- # SpannerClient = Google::Cloud::Spanner::V1::SpannerClient
584
+ # require "google/cloud/spanner/v1"
510
585
  #
511
- # spanner_client = SpannerClient.new
512
- # formatted_session = SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
586
+ # spanner_client = Google::Cloud::Spanner::V1.new
587
+ # formatted_session = Google::Cloud::Spanner::V1::SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
513
588
  # sql = ''
514
589
  # spanner_client.execute_streaming_sql(formatted_session, sql).each do |element|
515
590
  # # Process element.
@@ -524,7 +599,7 @@ module Google
524
599
  resume_token: nil,
525
600
  query_mode: nil,
526
601
  options: nil
527
- req = Google::Spanner::V1::ExecuteSqlRequest.new({
602
+ req = {
528
603
  session: session,
529
604
  sql: sql,
530
605
  transaction: transaction,
@@ -532,56 +607,61 @@ module Google
532
607
  param_types: param_types,
533
608
  resume_token: resume_token,
534
609
  query_mode: query_mode
535
- }.delete_if { |_, v| v.nil? })
610
+ }.delete_if { |_, v| v.nil? }
611
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::ExecuteSqlRequest)
536
612
  @execute_streaming_sql.call(req, options)
537
613
  end
538
614
 
539
615
  # Reads rows from the database using key lookups and scans, as a
540
616
  # simple key/value style alternative to
541
- # ExecuteSql. This method cannot be used to
617
+ # {Google::Spanner::V1::Spanner::ExecuteSql ExecuteSql}. This method cannot be used to
542
618
  # return a result set larger than 10 MiB; if the read matches more
543
619
  # data than that, the read fails with a +FAILED_PRECONDITION+
544
620
  # error.
545
621
  #
546
622
  # Reads inside read-write transactions might return +ABORTED+. If
547
623
  # this occurs, the application should restart the transaction from
548
- # the beginning. See Transaction for more details.
624
+ # the beginning. See {Google::Spanner::V1::Transaction Transaction} for more details.
549
625
  #
550
626
  # Larger result sets can be yielded in streaming fashion by calling
551
- # StreamingRead instead.
627
+ # {Google::Spanner::V1::Spanner::StreamingRead StreamingRead} instead.
552
628
  #
553
629
  # @param session [String]
554
630
  # Required. The session in which the read should be performed.
555
631
  # @param table [String]
556
632
  # Required. The name of the table in the database to be read.
557
633
  # @param columns [Array<String>]
558
- # The columns of Table to be returned for each row matching
634
+ # The columns of {Google::Spanner::V1::ReadRequest#table table} to be returned for each row matching
559
635
  # this request.
560
- # @param key_set [Google::Spanner::V1::KeySet]
636
+ # @param key_set [Google::Spanner::V1::KeySet | Hash]
561
637
  # Required. +key_set+ identifies the rows to be yielded. +key_set+ names the
562
- # primary keys of the rows in Table to be yielded, unless Index
563
- # is present. If Index is present, then Key_set instead names
564
- # index keys in Index.
638
+ # primary keys of the rows in {Google::Spanner::V1::ReadRequest#table table} to be yielded, unless {Google::Spanner::V1::ReadRequest#index index}
639
+ # is present. If {Google::Spanner::V1::ReadRequest#index index} is present, then {Google::Spanner::V1::ReadRequest#key_set key_set} instead names
640
+ # index keys in {Google::Spanner::V1::ReadRequest#index index}.
565
641
  #
566
- # Rows are yielded in table primary key order (if Index is empty)
567
- # or index key order (if Index is non-empty).
642
+ # Rows are yielded in table primary key order (if {Google::Spanner::V1::ReadRequest#index index} is empty)
643
+ # or index key order (if {Google::Spanner::V1::ReadRequest#index index} is non-empty).
568
644
  #
569
645
  # It is not an error for the +key_set+ to name rows that do not
570
646
  # exist in the database. Read yields nothing for nonexistent rows.
571
- # @param transaction [Google::Spanner::V1::TransactionSelector]
647
+ # A hash of the same form as `Google::Spanner::V1::KeySet`
648
+ # can also be provided.
649
+ # @param transaction [Google::Spanner::V1::TransactionSelector | Hash]
572
650
  # The transaction to use. If none is provided, the default is a
573
651
  # temporary read-only transaction with strong concurrency.
652
+ # A hash of the same form as `Google::Spanner::V1::TransactionSelector`
653
+ # can also be provided.
574
654
  # @param index [String]
575
- # If non-empty, the name of an index on Table. This index is
576
- # used instead of the table primary key when interpreting Key_set
577
- # and sorting result rows. See Key_set for further information.
655
+ # If non-empty, the name of an index on {Google::Spanner::V1::ReadRequest#table table}. This index is
656
+ # used instead of the table primary key when interpreting {Google::Spanner::V1::ReadRequest#key_set key_set}
657
+ # and sorting result rows. See {Google::Spanner::V1::ReadRequest#key_set key_set} for further information.
578
658
  # @param limit [Integer]
579
659
  # If greater than zero, only the first +limit+ rows are yielded. If +limit+
580
660
  # is zero, the default is no limit.
581
661
  # @param resume_token [String]
582
662
  # If this request is resuming a previously interrupted read,
583
663
  # +resume_token+ should be copied from the last
584
- # PartialResultSet yielded before the interruption. Doing this
664
+ # {Google::Spanner::V1::PartialResultSet PartialResultSet} yielded before the interruption. Doing this
585
665
  # enables the new read to resume where the last read left off. The
586
666
  # rest of the request parameters must exactly match the request
587
667
  # that yielded this token.
@@ -591,16 +671,13 @@ module Google
591
671
  # @return [Google::Spanner::V1::ResultSet]
592
672
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
593
673
  # @example
594
- # require "google/cloud/spanner/v1/spanner_client"
674
+ # require "google/cloud/spanner/v1"
595
675
  #
596
- # KeySet = Google::Spanner::V1::KeySet
597
- # SpannerClient = Google::Cloud::Spanner::V1::SpannerClient
598
- #
599
- # spanner_client = SpannerClient.new
600
- # formatted_session = SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
676
+ # spanner_client = Google::Cloud::Spanner::V1.new
677
+ # formatted_session = Google::Cloud::Spanner::V1::SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
601
678
  # table = ''
602
679
  # columns = []
603
- # key_set = KeySet.new
680
+ # key_set = {}
604
681
  # response = spanner_client.read(formatted_session, table, columns, key_set)
605
682
 
606
683
  def read \
@@ -613,7 +690,7 @@ module Google
613
690
  limit: nil,
614
691
  resume_token: nil,
615
692
  options: nil
616
- req = Google::Spanner::V1::ReadRequest.new({
693
+ req = {
617
694
  session: session,
618
695
  table: table,
619
696
  columns: columns,
@@ -622,12 +699,13 @@ module Google
622
699
  index: index,
623
700
  limit: limit,
624
701
  resume_token: resume_token
625
- }.delete_if { |_, v| v.nil? })
702
+ }.delete_if { |_, v| v.nil? }
703
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::ReadRequest)
626
704
  @read.call(req, options)
627
705
  end
628
706
 
629
- # Like Read, except returns the result set as a
630
- # stream. Unlike Read, there is no limit on the
707
+ # Like {Google::Spanner::V1::Spanner::Read Read}, except returns the result set as a
708
+ # stream. Unlike {Google::Spanner::V1::Spanner::Read Read}, there is no limit on the
631
709
  # size of the returned result set. However, no individual row in
632
710
  # the result set can exceed 100 MiB, and no column value can exceed
633
711
  # 10 MiB.
@@ -637,33 +715,37 @@ module Google
637
715
  # @param table [String]
638
716
  # Required. The name of the table in the database to be read.
639
717
  # @param columns [Array<String>]
640
- # The columns of Table to be returned for each row matching
718
+ # The columns of {Google::Spanner::V1::ReadRequest#table table} to be returned for each row matching
641
719
  # this request.
642
- # @param key_set [Google::Spanner::V1::KeySet]
720
+ # @param key_set [Google::Spanner::V1::KeySet | Hash]
643
721
  # Required. +key_set+ identifies the rows to be yielded. +key_set+ names the
644
- # primary keys of the rows in Table to be yielded, unless Index
645
- # is present. If Index is present, then Key_set instead names
646
- # index keys in Index.
722
+ # primary keys of the rows in {Google::Spanner::V1::ReadRequest#table table} to be yielded, unless {Google::Spanner::V1::ReadRequest#index index}
723
+ # is present. If {Google::Spanner::V1::ReadRequest#index index} is present, then {Google::Spanner::V1::ReadRequest#key_set key_set} instead names
724
+ # index keys in {Google::Spanner::V1::ReadRequest#index index}.
647
725
  #
648
- # Rows are yielded in table primary key order (if Index is empty)
649
- # or index key order (if Index is non-empty).
726
+ # Rows are yielded in table primary key order (if {Google::Spanner::V1::ReadRequest#index index} is empty)
727
+ # or index key order (if {Google::Spanner::V1::ReadRequest#index index} is non-empty).
650
728
  #
651
729
  # It is not an error for the +key_set+ to name rows that do not
652
730
  # exist in the database. Read yields nothing for nonexistent rows.
653
- # @param transaction [Google::Spanner::V1::TransactionSelector]
731
+ # A hash of the same form as `Google::Spanner::V1::KeySet`
732
+ # can also be provided.
733
+ # @param transaction [Google::Spanner::V1::TransactionSelector | Hash]
654
734
  # The transaction to use. If none is provided, the default is a
655
735
  # temporary read-only transaction with strong concurrency.
736
+ # A hash of the same form as `Google::Spanner::V1::TransactionSelector`
737
+ # can also be provided.
656
738
  # @param index [String]
657
- # If non-empty, the name of an index on Table. This index is
658
- # used instead of the table primary key when interpreting Key_set
659
- # and sorting result rows. See Key_set for further information.
739
+ # If non-empty, the name of an index on {Google::Spanner::V1::ReadRequest#table table}. This index is
740
+ # used instead of the table primary key when interpreting {Google::Spanner::V1::ReadRequest#key_set key_set}
741
+ # and sorting result rows. See {Google::Spanner::V1::ReadRequest#key_set key_set} for further information.
660
742
  # @param limit [Integer]
661
743
  # If greater than zero, only the first +limit+ rows are yielded. If +limit+
662
744
  # is zero, the default is no limit.
663
745
  # @param resume_token [String]
664
746
  # If this request is resuming a previously interrupted read,
665
747
  # +resume_token+ should be copied from the last
666
- # PartialResultSet yielded before the interruption. Doing this
748
+ # {Google::Spanner::V1::PartialResultSet PartialResultSet} yielded before the interruption. Doing this
667
749
  # enables the new read to resume where the last read left off. The
668
750
  # rest of the request parameters must exactly match the request
669
751
  # that yielded this token.
@@ -675,16 +757,13 @@ module Google
675
757
  #
676
758
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
677
759
  # @example
678
- # require "google/cloud/spanner/v1/spanner_client"
679
- #
680
- # KeySet = Google::Spanner::V1::KeySet
681
- # SpannerClient = Google::Cloud::Spanner::V1::SpannerClient
760
+ # require "google/cloud/spanner/v1"
682
761
  #
683
- # spanner_client = SpannerClient.new
684
- # formatted_session = SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
762
+ # spanner_client = Google::Cloud::Spanner::V1.new
763
+ # formatted_session = Google::Cloud::Spanner::V1::SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
685
764
  # table = ''
686
765
  # columns = []
687
- # key_set = KeySet.new
766
+ # key_set = {}
688
767
  # spanner_client.streaming_read(formatted_session, table, columns, key_set).each do |element|
689
768
  # # Process element.
690
769
  # end
@@ -699,7 +778,7 @@ module Google
699
778
  limit: nil,
700
779
  resume_token: nil,
701
780
  options: nil
702
- req = Google::Spanner::V1::ReadRequest.new({
781
+ req = {
703
782
  session: session,
704
783
  table: table,
705
784
  columns: columns,
@@ -708,43 +787,44 @@ module Google
708
787
  index: index,
709
788
  limit: limit,
710
789
  resume_token: resume_token
711
- }.delete_if { |_, v| v.nil? })
790
+ }.delete_if { |_, v| v.nil? }
791
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::ReadRequest)
712
792
  @streaming_read.call(req, options)
713
793
  end
714
794
 
715
795
  # Begins a new transaction. This step can often be skipped:
716
- # Read, ExecuteSql and
717
- # Commit can begin a new transaction as a
796
+ # {Google::Spanner::V1::Spanner::Read Read}, {Google::Spanner::V1::Spanner::ExecuteSql ExecuteSql} and
797
+ # {Google::Spanner::V1::Spanner::Commit Commit} can begin a new transaction as a
718
798
  # side-effect.
719
799
  #
720
800
  # @param session [String]
721
801
  # Required. The session in which the transaction runs.
722
- # @param options_ [Google::Spanner::V1::TransactionOptions]
802
+ # @param options_ [Google::Spanner::V1::TransactionOptions | Hash]
723
803
  # Required. Options for the new transaction.
804
+ # A hash of the same form as `Google::Spanner::V1::TransactionOptions`
805
+ # can also be provided.
724
806
  # @param options [Google::Gax::CallOptions]
725
807
  # Overrides the default settings for this call, e.g, timeout,
726
808
  # retries, etc.
727
809
  # @return [Google::Spanner::V1::Transaction]
728
810
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
729
811
  # @example
730
- # require "google/cloud/spanner/v1/spanner_client"
812
+ # require "google/cloud/spanner/v1"
731
813
  #
732
- # SpannerClient = Google::Cloud::Spanner::V1::SpannerClient
733
- # TransactionOptions = Google::Spanner::V1::TransactionOptions
734
- #
735
- # spanner_client = SpannerClient.new
736
- # formatted_session = SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
737
- # options_ = TransactionOptions.new
814
+ # spanner_client = Google::Cloud::Spanner::V1.new
815
+ # formatted_session = Google::Cloud::Spanner::V1::SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
816
+ # options_ = {}
738
817
  # response = spanner_client.begin_transaction(formatted_session, options_)
739
818
 
740
819
  def begin_transaction \
741
820
  session,
742
821
  options_,
743
822
  options: nil
744
- req = Google::Spanner::V1::BeginTransactionRequest.new({
823
+ req = {
745
824
  session: session,
746
825
  options: options_
747
- }.delete_if { |_, v| v.nil? })
826
+ }.delete_if { |_, v| v.nil? }
827
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::BeginTransactionRequest)
748
828
  @begin_transaction.call(req, options)
749
829
  end
750
830
 
@@ -759,13 +839,15 @@ module Google
759
839
  #
760
840
  # @param session [String]
761
841
  # Required. The session in which the transaction to be committed is running.
762
- # @param mutations [Array<Google::Spanner::V1::Mutation>]
842
+ # @param mutations [Array<Google::Spanner::V1::Mutation | Hash>]
763
843
  # The mutations to be executed when this transaction commits. All
764
844
  # mutations are applied atomically, in the order they appear in
765
845
  # this list.
846
+ # A hash of the same form as `Google::Spanner::V1::Mutation`
847
+ # can also be provided.
766
848
  # @param transaction_id [String]
767
849
  # Commit a previously-started transaction.
768
- # @param single_use_transaction [Google::Spanner::V1::TransactionOptions]
850
+ # @param single_use_transaction [Google::Spanner::V1::TransactionOptions | Hash]
769
851
  # Execute mutations in a temporary transaction. Note that unlike
770
852
  # commit of a previously-started transaction, commit with a
771
853
  # temporary transaction is non-idempotent. That is, if the
@@ -773,20 +855,20 @@ module Google
773
855
  # instance, due to retries in the application, or in the
774
856
  # transport library), it is possible that the mutations are
775
857
  # executed more than once. If this is undesirable, use
776
- # BeginTransaction and
777
- # Commit instead.
858
+ # {Google::Spanner::V1::Spanner::BeginTransaction BeginTransaction} and
859
+ # {Google::Spanner::V1::Spanner::Commit Commit} instead.
860
+ # A hash of the same form as `Google::Spanner::V1::TransactionOptions`
861
+ # can also be provided.
778
862
  # @param options [Google::Gax::CallOptions]
779
863
  # Overrides the default settings for this call, e.g, timeout,
780
864
  # retries, etc.
781
865
  # @return [Google::Spanner::V1::CommitResponse]
782
866
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
783
867
  # @example
784
- # require "google/cloud/spanner/v1/spanner_client"
785
- #
786
- # SpannerClient = Google::Cloud::Spanner::V1::SpannerClient
868
+ # require "google/cloud/spanner/v1"
787
869
  #
788
- # spanner_client = SpannerClient.new
789
- # formatted_session = SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
870
+ # spanner_client = Google::Cloud::Spanner::V1.new
871
+ # formatted_session = Google::Cloud::Spanner::V1::SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
790
872
  # mutations = []
791
873
  # response = spanner_client.commit(formatted_session, mutations)
792
874
 
@@ -796,18 +878,19 @@ module Google
796
878
  transaction_id: nil,
797
879
  single_use_transaction: nil,
798
880
  options: nil
799
- req = Google::Spanner::V1::CommitRequest.new({
881
+ req = {
800
882
  session: session,
801
883
  mutations: mutations,
802
884
  transaction_id: transaction_id,
803
885
  single_use_transaction: single_use_transaction
804
- }.delete_if { |_, v| v.nil? })
886
+ }.delete_if { |_, v| v.nil? }
887
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::CommitRequest)
805
888
  @commit.call(req, options)
806
889
  end
807
890
 
808
891
  # Rolls back a transaction, releasing any locks it holds. It is a good
809
892
  # idea to call this for any transaction that includes one or more
810
- # Read or ExecuteSql requests and
893
+ # {Google::Spanner::V1::Spanner::Read Read} or {Google::Spanner::V1::Spanner::ExecuteSql ExecuteSql} requests and
811
894
  # ultimately decides not to commit.
812
895
  #
813
896
  # +Rollback+ returns +OK+ if it successfully aborts the transaction, the
@@ -823,12 +906,10 @@ module Google
823
906
  # retries, etc.
824
907
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
825
908
  # @example
826
- # require "google/cloud/spanner/v1/spanner_client"
827
- #
828
- # SpannerClient = Google::Cloud::Spanner::V1::SpannerClient
909
+ # require "google/cloud/spanner/v1"
829
910
  #
830
- # spanner_client = SpannerClient.new
831
- # formatted_session = SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
911
+ # spanner_client = Google::Cloud::Spanner::V1.new
912
+ # formatted_session = Google::Cloud::Spanner::V1::SpannerClient.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
832
913
  # transaction_id = ''
833
914
  # spanner_client.rollback(formatted_session, transaction_id)
834
915
 
@@ -836,10 +917,11 @@ module Google
836
917
  session,
837
918
  transaction_id,
838
919
  options: nil
839
- req = Google::Spanner::V1::RollbackRequest.new({
920
+ req = {
840
921
  session: session,
841
922
  transaction_id: transaction_id
842
- }.delete_if { |_, v| v.nil? })
923
+ }.delete_if { |_, v| v.nil? }
924
+ req = Google::Gax::to_proto(req, Google::Spanner::V1::RollbackRequest)
843
925
  @rollback.call(req, options)
844
926
  nil
845
927
  end