google-cloud-spanner-v1 0.7.0 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,13 +44,12 @@ module Google
44
44
  # See {::Google::Cloud::Spanner::V1::Spanner::Client::Configuration}
45
45
  # for a description of the configuration fields.
46
46
  #
47
- # ## Example
47
+ # @example
48
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
49
+ # # Modify the configuration for all Spanner clients
50
+ # ::Google::Cloud::Spanner::V1::Spanner::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
54
53
  #
55
54
  # @yield [config] Configure the Client client.
56
55
  # @yieldparam config [Client::Configuration]
@@ -70,110 +69,71 @@ module Google
70
69
 
71
70
  default_config.rpcs.create_session.timeout = 30.0
72
71
  default_config.rpcs.create_session.retry_policy = {
73
- initial_delay: 0.25,
74
- max_delay: 32.0,
75
- multiplier: 1.3,
76
- retry_codes: [14]
72
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
77
73
  }
78
74
 
79
75
  default_config.rpcs.batch_create_sessions.timeout = 60.0
80
76
  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: [14]
77
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
85
78
  }
86
79
 
87
80
  default_config.rpcs.get_session.timeout = 30.0
88
81
  default_config.rpcs.get_session.retry_policy = {
89
- initial_delay: 0.25,
90
- max_delay: 32.0,
91
- multiplier: 1.3,
92
- retry_codes: [14]
82
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
93
83
  }
94
84
 
95
85
  default_config.rpcs.list_sessions.timeout = 3600.0
96
86
  default_config.rpcs.list_sessions.retry_policy = {
97
- initial_delay: 0.25,
98
- max_delay: 32.0,
99
- multiplier: 1.3,
100
- retry_codes: [14]
87
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
101
88
  }
102
89
 
103
90
  default_config.rpcs.delete_session.timeout = 30.0
104
91
  default_config.rpcs.delete_session.retry_policy = {
105
- initial_delay: 0.25,
106
- max_delay: 32.0,
107
- multiplier: 1.3,
108
- retry_codes: [14]
92
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
109
93
  }
110
94
 
111
95
  default_config.rpcs.execute_sql.timeout = 30.0
112
96
  default_config.rpcs.execute_sql.retry_policy = {
113
- initial_delay: 0.25,
114
- max_delay: 32.0,
115
- multiplier: 1.3,
116
- retry_codes: [14]
97
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
117
98
  }
118
99
 
119
100
  default_config.rpcs.execute_streaming_sql.timeout = 3600.0
120
101
 
121
102
  default_config.rpcs.execute_batch_dml.timeout = 30.0
122
103
  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: [14]
104
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
127
105
  }
128
106
 
129
107
  default_config.rpcs.read.timeout = 30.0
130
108
  default_config.rpcs.read.retry_policy = {
131
- initial_delay: 0.25,
132
- max_delay: 32.0,
133
- multiplier: 1.3,
134
- retry_codes: [14]
109
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
135
110
  }
136
111
 
137
112
  default_config.rpcs.streaming_read.timeout = 3600.0
138
113
 
139
114
  default_config.rpcs.begin_transaction.timeout = 30.0
140
115
  default_config.rpcs.begin_transaction.retry_policy = {
141
- initial_delay: 0.25,
142
- max_delay: 32.0,
143
- multiplier: 1.3,
144
- retry_codes: [14]
116
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
145
117
  }
146
118
 
147
119
  default_config.rpcs.commit.timeout = 3600.0
148
120
  default_config.rpcs.commit.retry_policy = {
149
- initial_delay: 0.25,
150
- max_delay: 32.0,
151
- multiplier: 1.3,
152
- retry_codes: [14]
121
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
153
122
  }
154
123
 
155
124
  default_config.rpcs.rollback.timeout = 30.0
156
125
  default_config.rpcs.rollback.retry_policy = {
157
- initial_delay: 0.25,
158
- max_delay: 32.0,
159
- multiplier: 1.3,
160
- retry_codes: [14]
126
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
161
127
  }
162
128
 
163
129
  default_config.rpcs.partition_query.timeout = 30.0
164
130
  default_config.rpcs.partition_query.retry_policy = {
165
- initial_delay: 0.25,
166
- max_delay: 32.0,
167
- multiplier: 1.3,
168
- retry_codes: [14]
131
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
169
132
  }
170
133
 
171
134
  default_config.rpcs.partition_read.timeout = 30.0
172
135
  default_config.rpcs.partition_read.retry_policy = {
173
- initial_delay: 0.25,
174
- max_delay: 32.0,
175
- multiplier: 1.3,
176
- retry_codes: [14]
136
+ initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14]
177
137
  }
178
138
 
179
139
  default_config
@@ -205,19 +165,15 @@ module Google
205
165
  ##
206
166
  # Create a new Spanner client object.
207
167
  #
208
- # ## Examples
209
- #
210
- # To create a new Spanner client with the default
211
- # configuration:
168
+ # @example
212
169
  #
213
- # client = ::Google::Cloud::Spanner::V1::Spanner::Client.new
170
+ # # Create a client using the default configuration
171
+ # client = ::Google::Cloud::Spanner::V1::Spanner::Client.new
214
172
  #
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
173
+ # # Create a client using a custom configuration
174
+ # client = ::Google::Cloud::Spanner::V1::Spanner::Client.new do |config|
175
+ # config.timeout = 10.0
176
+ # end
221
177
  #
222
178
  # @yield [config] Configure the Spanner client.
223
179
  # @yieldparam config [Client::Configuration]
@@ -237,14 +193,13 @@ module Google
237
193
 
238
194
  # Create credentials
239
195
  credentials = @config.credentials
240
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
196
+ # Use self-signed JWT if the endpoint is unchanged from default,
241
197
  # but only if the default endpoint does not have a region prefix.
242
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
243
- @config.endpoint == Client.configure.endpoint &&
198
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
244
199
  !@config.endpoint.split(".").first.include?("-")
245
200
  credentials ||= Credentials.default scope: @config.scope,
246
201
  enable_self_signed_jwt: enable_self_signed_jwt
247
- if credentials.is_a?(String) || credentials.is_a?(Hash)
202
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
248
203
  credentials = Credentials.new credentials, scope: @config.scope
249
204
  end
250
205
  @quota_project_id = @config.quota_project
@@ -310,6 +265,21 @@ module Google
310
265
  #
311
266
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
312
267
  #
268
+ # @example Basic example
269
+ # require "google/cloud/spanner/v1"
270
+ #
271
+ # # Create a client object. The client can be reused for multiple calls.
272
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
273
+ #
274
+ # # Create a request. To set request fields, pass in keyword arguments.
275
+ # request = Google::Cloud::Spanner::V1::CreateSessionRequest.new
276
+ #
277
+ # # Call the create_session method.
278
+ # result = client.create_session request
279
+ #
280
+ # # The returned object is of type Google::Cloud::Spanner::V1::Session.
281
+ # p result
282
+ #
313
283
  def create_session request, options = nil
314
284
  raise ::ArgumentError, "request must be provided" if request.nil?
315
285
 
@@ -327,16 +297,20 @@ module Google
327
297
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
328
298
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
329
299
 
330
- header_params = {
331
- "database" => request.database
332
- }
300
+ header_params = {}
301
+ if request.database
302
+ header_params["database"] = request.database
303
+ end
304
+
333
305
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
334
306
  metadata[:"x-goog-request-params"] ||= request_params_header
335
307
 
336
308
  options.apply_defaults timeout: @config.rpcs.create_session.timeout,
337
309
  metadata: metadata,
338
310
  retry_policy: @config.rpcs.create_session.retry_policy
339
- options.apply_defaults metadata: @config.metadata,
311
+
312
+ options.apply_defaults timeout: @config.timeout,
313
+ metadata: @config.metadata,
340
314
  retry_policy: @config.retry_policy
341
315
 
342
316
  @spanner_stub.call_rpc :create_session, request, options: options do |response, operation|
@@ -387,6 +361,21 @@ module Google
387
361
  #
388
362
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
389
363
  #
364
+ # @example Basic example
365
+ # require "google/cloud/spanner/v1"
366
+ #
367
+ # # Create a client object. The client can be reused for multiple calls.
368
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
369
+ #
370
+ # # Create a request. To set request fields, pass in keyword arguments.
371
+ # request = Google::Cloud::Spanner::V1::BatchCreateSessionsRequest.new
372
+ #
373
+ # # Call the batch_create_sessions method.
374
+ # result = client.batch_create_sessions request
375
+ #
376
+ # # The returned object is of type Google::Cloud::Spanner::V1::BatchCreateSessionsResponse.
377
+ # p result
378
+ #
390
379
  def batch_create_sessions request, options = nil
391
380
  raise ::ArgumentError, "request must be provided" if request.nil?
392
381
 
@@ -404,16 +393,20 @@ module Google
404
393
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
405
394
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
406
395
 
407
- header_params = {
408
- "database" => request.database
409
- }
396
+ header_params = {}
397
+ if request.database
398
+ header_params["database"] = request.database
399
+ end
400
+
410
401
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
411
402
  metadata[:"x-goog-request-params"] ||= request_params_header
412
403
 
413
404
  options.apply_defaults timeout: @config.rpcs.batch_create_sessions.timeout,
414
405
  metadata: metadata,
415
406
  retry_policy: @config.rpcs.batch_create_sessions.retry_policy
416
- options.apply_defaults metadata: @config.metadata,
407
+
408
+ options.apply_defaults timeout: @config.timeout,
409
+ metadata: @config.metadata,
417
410
  retry_policy: @config.retry_policy
418
411
 
419
412
  @spanner_stub.call_rpc :batch_create_sessions, request, options: options do |response, operation|
@@ -455,6 +448,21 @@ module Google
455
448
  #
456
449
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
457
450
  #
451
+ # @example Basic example
452
+ # require "google/cloud/spanner/v1"
453
+ #
454
+ # # Create a client object. The client can be reused for multiple calls.
455
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
456
+ #
457
+ # # Create a request. To set request fields, pass in keyword arguments.
458
+ # request = Google::Cloud::Spanner::V1::GetSessionRequest.new
459
+ #
460
+ # # Call the get_session method.
461
+ # result = client.get_session request
462
+ #
463
+ # # The returned object is of type Google::Cloud::Spanner::V1::Session.
464
+ # p result
465
+ #
458
466
  def get_session request, options = nil
459
467
  raise ::ArgumentError, "request must be provided" if request.nil?
460
468
 
@@ -472,16 +480,20 @@ module Google
472
480
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
473
481
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
474
482
 
475
- header_params = {
476
- "name" => request.name
477
- }
483
+ header_params = {}
484
+ if request.name
485
+ header_params["name"] = request.name
486
+ end
487
+
478
488
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
479
489
  metadata[:"x-goog-request-params"] ||= request_params_header
480
490
 
481
491
  options.apply_defaults timeout: @config.rpcs.get_session.timeout,
482
492
  metadata: metadata,
483
493
  retry_policy: @config.rpcs.get_session.retry_policy
484
- options.apply_defaults metadata: @config.metadata,
494
+
495
+ options.apply_defaults timeout: @config.timeout,
496
+ metadata: @config.metadata,
485
497
  retry_policy: @config.retry_policy
486
498
 
487
499
  @spanner_stub.call_rpc :get_session, request, options: options do |response, operation|
@@ -539,6 +551,27 @@ module Google
539
551
  #
540
552
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
541
553
  #
554
+ # @example Basic example
555
+ # require "google/cloud/spanner/v1"
556
+ #
557
+ # # Create a client object. The client can be reused for multiple calls.
558
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
559
+ #
560
+ # # Create a request. To set request fields, pass in keyword arguments.
561
+ # request = Google::Cloud::Spanner::V1::ListSessionsRequest.new
562
+ #
563
+ # # Call the list_sessions method.
564
+ # result = client.list_sessions request
565
+ #
566
+ # # The returned object is of type Gapic::PagedEnumerable. You can
567
+ # # iterate over all elements by calling #each, and the enumerable
568
+ # # will lazily make API calls to fetch subsequent pages. Other
569
+ # # methods are also available for managing paging directly.
570
+ # result.each do |response|
571
+ # # Each element is of type ::Google::Cloud::Spanner::V1::Session.
572
+ # p response
573
+ # end
574
+ #
542
575
  def list_sessions request, options = nil
543
576
  raise ::ArgumentError, "request must be provided" if request.nil?
544
577
 
@@ -556,16 +589,20 @@ module Google
556
589
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
557
590
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
558
591
 
559
- header_params = {
560
- "database" => request.database
561
- }
592
+ header_params = {}
593
+ if request.database
594
+ header_params["database"] = request.database
595
+ end
596
+
562
597
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
563
598
  metadata[:"x-goog-request-params"] ||= request_params_header
564
599
 
565
600
  options.apply_defaults timeout: @config.rpcs.list_sessions.timeout,
566
601
  metadata: metadata,
567
602
  retry_policy: @config.rpcs.list_sessions.retry_policy
568
- options.apply_defaults metadata: @config.metadata,
603
+
604
+ options.apply_defaults timeout: @config.timeout,
605
+ metadata: @config.metadata,
569
606
  retry_policy: @config.retry_policy
570
607
 
571
608
  @spanner_stub.call_rpc :list_sessions, request, options: options do |response, operation|
@@ -608,6 +645,21 @@ module Google
608
645
  #
609
646
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
610
647
  #
648
+ # @example Basic example
649
+ # require "google/cloud/spanner/v1"
650
+ #
651
+ # # Create a client object. The client can be reused for multiple calls.
652
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
653
+ #
654
+ # # Create a request. To set request fields, pass in keyword arguments.
655
+ # request = Google::Cloud::Spanner::V1::DeleteSessionRequest.new
656
+ #
657
+ # # Call the delete_session method.
658
+ # result = client.delete_session request
659
+ #
660
+ # # The returned object is of type Google::Protobuf::Empty.
661
+ # p result
662
+ #
611
663
  def delete_session request, options = nil
612
664
  raise ::ArgumentError, "request must be provided" if request.nil?
613
665
 
@@ -625,16 +677,20 @@ module Google
625
677
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
626
678
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
627
679
 
628
- header_params = {
629
- "name" => request.name
630
- }
680
+ header_params = {}
681
+ if request.name
682
+ header_params["name"] = request.name
683
+ end
684
+
631
685
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
632
686
  metadata[:"x-goog-request-params"] ||= request_params_header
633
687
 
634
688
  options.apply_defaults timeout: @config.rpcs.delete_session.timeout,
635
689
  metadata: metadata,
636
690
  retry_policy: @config.rpcs.delete_session.retry_policy
637
- options.apply_defaults metadata: @config.metadata,
691
+
692
+ options.apply_defaults timeout: @config.timeout,
693
+ metadata: @config.metadata,
638
694
  retry_policy: @config.retry_policy
639
695
 
640
696
  @spanner_stub.call_rpc :delete_session, request, options: options do |response, operation|
@@ -751,6 +807,21 @@ module Google
751
807
  #
752
808
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
753
809
  #
810
+ # @example Basic example
811
+ # require "google/cloud/spanner/v1"
812
+ #
813
+ # # Create a client object. The client can be reused for multiple calls.
814
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
815
+ #
816
+ # # Create a request. To set request fields, pass in keyword arguments.
817
+ # request = Google::Cloud::Spanner::V1::ExecuteSqlRequest.new
818
+ #
819
+ # # Call the execute_sql method.
820
+ # result = client.execute_sql request
821
+ #
822
+ # # The returned object is of type Google::Cloud::Spanner::V1::ResultSet.
823
+ # p result
824
+ #
754
825
  def execute_sql request, options = nil
755
826
  raise ::ArgumentError, "request must be provided" if request.nil?
756
827
 
@@ -768,16 +839,20 @@ module Google
768
839
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
769
840
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
770
841
 
771
- header_params = {
772
- "session" => request.session
773
- }
842
+ header_params = {}
843
+ if request.session
844
+ header_params["session"] = request.session
845
+ end
846
+
774
847
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
775
848
  metadata[:"x-goog-request-params"] ||= request_params_header
776
849
 
777
850
  options.apply_defaults timeout: @config.rpcs.execute_sql.timeout,
778
851
  metadata: metadata,
779
852
  retry_policy: @config.rpcs.execute_sql.retry_policy
780
- options.apply_defaults metadata: @config.metadata,
853
+
854
+ options.apply_defaults timeout: @config.timeout,
855
+ metadata: @config.metadata,
781
856
  retry_policy: @config.retry_policy
782
857
 
783
858
  @spanner_stub.call_rpc :execute_sql, request, options: options do |response, operation|
@@ -888,6 +963,24 @@ module Google
888
963
  #
889
964
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
890
965
  #
966
+ # @example Basic example
967
+ # require "google/cloud/spanner/v1"
968
+ #
969
+ # # Create a client object. The client can be reused for multiple calls.
970
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
971
+ #
972
+ # # Create a request. To set request fields, pass in keyword arguments.
973
+ # request = Google::Cloud::Spanner::V1::ExecuteSqlRequest.new
974
+ #
975
+ # # Call the execute_streaming_sql method.
976
+ # result = client.execute_streaming_sql request
977
+ #
978
+ # # The returned object is a streamed enumerable yielding elements of
979
+ # # type ::Google::Cloud::Spanner::V1::PartialResultSet.
980
+ # result.each do |response|
981
+ # p response
982
+ # end
983
+ #
891
984
  def execute_streaming_sql request, options = nil
892
985
  raise ::ArgumentError, "request must be provided" if request.nil?
893
986
 
@@ -905,16 +998,20 @@ module Google
905
998
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
906
999
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
907
1000
 
908
- header_params = {
909
- "session" => request.session
910
- }
1001
+ header_params = {}
1002
+ if request.session
1003
+ header_params["session"] = request.session
1004
+ end
1005
+
911
1006
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
912
1007
  metadata[:"x-goog-request-params"] ||= request_params_header
913
1008
 
914
1009
  options.apply_defaults timeout: @config.rpcs.execute_streaming_sql.timeout,
915
1010
  metadata: metadata,
916
1011
  retry_policy: @config.rpcs.execute_streaming_sql.retry_policy
917
- options.apply_defaults metadata: @config.metadata,
1012
+
1013
+ options.apply_defaults timeout: @config.timeout,
1014
+ metadata: @config.metadata,
918
1015
  retry_policy: @config.retry_policy
919
1016
 
920
1017
  @spanner_stub.call_rpc :execute_streaming_sql, request, options: options do |response, operation|
@@ -988,6 +1085,21 @@ module Google
988
1085
  #
989
1086
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
990
1087
  #
1088
+ # @example Basic example
1089
+ # require "google/cloud/spanner/v1"
1090
+ #
1091
+ # # Create a client object. The client can be reused for multiple calls.
1092
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
1093
+ #
1094
+ # # Create a request. To set request fields, pass in keyword arguments.
1095
+ # request = Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest.new
1096
+ #
1097
+ # # Call the execute_batch_dml method.
1098
+ # result = client.execute_batch_dml request
1099
+ #
1100
+ # # The returned object is of type Google::Cloud::Spanner::V1::ExecuteBatchDmlResponse.
1101
+ # p result
1102
+ #
991
1103
  def execute_batch_dml request, options = nil
992
1104
  raise ::ArgumentError, "request must be provided" if request.nil?
993
1105
 
@@ -1005,16 +1117,20 @@ module Google
1005
1117
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1006
1118
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1007
1119
 
1008
- header_params = {
1009
- "session" => request.session
1010
- }
1120
+ header_params = {}
1121
+ if request.session
1122
+ header_params["session"] = request.session
1123
+ end
1124
+
1011
1125
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1012
1126
  metadata[:"x-goog-request-params"] ||= request_params_header
1013
1127
 
1014
1128
  options.apply_defaults timeout: @config.rpcs.execute_batch_dml.timeout,
1015
1129
  metadata: metadata,
1016
1130
  retry_policy: @config.rpcs.execute_batch_dml.retry_policy
1017
- options.apply_defaults metadata: @config.metadata,
1131
+
1132
+ options.apply_defaults timeout: @config.timeout,
1133
+ metadata: @config.metadata,
1018
1134
  retry_policy: @config.retry_policy
1019
1135
 
1020
1136
  @spanner_stub.call_rpc :execute_batch_dml, request, options: options do |response, operation|
@@ -1109,6 +1225,21 @@ module Google
1109
1225
  #
1110
1226
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1111
1227
  #
1228
+ # @example Basic example
1229
+ # require "google/cloud/spanner/v1"
1230
+ #
1231
+ # # Create a client object. The client can be reused for multiple calls.
1232
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
1233
+ #
1234
+ # # Create a request. To set request fields, pass in keyword arguments.
1235
+ # request = Google::Cloud::Spanner::V1::ReadRequest.new
1236
+ #
1237
+ # # Call the read method.
1238
+ # result = client.read request
1239
+ #
1240
+ # # The returned object is of type Google::Cloud::Spanner::V1::ResultSet.
1241
+ # p result
1242
+ #
1112
1243
  def read request, options = nil
1113
1244
  raise ::ArgumentError, "request must be provided" if request.nil?
1114
1245
 
@@ -1126,16 +1257,20 @@ module Google
1126
1257
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1127
1258
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1128
1259
 
1129
- header_params = {
1130
- "session" => request.session
1131
- }
1260
+ header_params = {}
1261
+ if request.session
1262
+ header_params["session"] = request.session
1263
+ end
1264
+
1132
1265
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1133
1266
  metadata[:"x-goog-request-params"] ||= request_params_header
1134
1267
 
1135
1268
  options.apply_defaults timeout: @config.rpcs.read.timeout,
1136
1269
  metadata: metadata,
1137
1270
  retry_policy: @config.rpcs.read.retry_policy
1138
- options.apply_defaults metadata: @config.metadata,
1271
+
1272
+ options.apply_defaults timeout: @config.timeout,
1273
+ metadata: @config.metadata,
1139
1274
  retry_policy: @config.retry_policy
1140
1275
 
1141
1276
  @spanner_stub.call_rpc :read, request, options: options do |response, operation|
@@ -1222,6 +1357,24 @@ module Google
1222
1357
  #
1223
1358
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1224
1359
  #
1360
+ # @example Basic example
1361
+ # require "google/cloud/spanner/v1"
1362
+ #
1363
+ # # Create a client object. The client can be reused for multiple calls.
1364
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
1365
+ #
1366
+ # # Create a request. To set request fields, pass in keyword arguments.
1367
+ # request = Google::Cloud::Spanner::V1::ReadRequest.new
1368
+ #
1369
+ # # Call the streaming_read method.
1370
+ # result = client.streaming_read request
1371
+ #
1372
+ # # The returned object is a streamed enumerable yielding elements of
1373
+ # # type ::Google::Cloud::Spanner::V1::PartialResultSet.
1374
+ # result.each do |response|
1375
+ # p response
1376
+ # end
1377
+ #
1225
1378
  def streaming_read request, options = nil
1226
1379
  raise ::ArgumentError, "request must be provided" if request.nil?
1227
1380
 
@@ -1239,16 +1392,20 @@ module Google
1239
1392
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1240
1393
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1241
1394
 
1242
- header_params = {
1243
- "session" => request.session
1244
- }
1395
+ header_params = {}
1396
+ if request.session
1397
+ header_params["session"] = request.session
1398
+ end
1399
+
1245
1400
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1246
1401
  metadata[:"x-goog-request-params"] ||= request_params_header
1247
1402
 
1248
1403
  options.apply_defaults timeout: @config.rpcs.streaming_read.timeout,
1249
1404
  metadata: metadata,
1250
1405
  retry_policy: @config.rpcs.streaming_read.retry_policy
1251
- options.apply_defaults metadata: @config.metadata,
1406
+
1407
+ options.apply_defaults timeout: @config.timeout,
1408
+ metadata: @config.metadata,
1252
1409
  retry_policy: @config.retry_policy
1253
1410
 
1254
1411
  @spanner_stub.call_rpc :streaming_read, request, options: options do |response, operation|
@@ -1299,6 +1456,21 @@ module Google
1299
1456
  #
1300
1457
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1301
1458
  #
1459
+ # @example Basic example
1460
+ # require "google/cloud/spanner/v1"
1461
+ #
1462
+ # # Create a client object. The client can be reused for multiple calls.
1463
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
1464
+ #
1465
+ # # Create a request. To set request fields, pass in keyword arguments.
1466
+ # request = Google::Cloud::Spanner::V1::BeginTransactionRequest.new
1467
+ #
1468
+ # # Call the begin_transaction method.
1469
+ # result = client.begin_transaction request
1470
+ #
1471
+ # # The returned object is of type Google::Cloud::Spanner::V1::Transaction.
1472
+ # p result
1473
+ #
1302
1474
  def begin_transaction request, options = nil
1303
1475
  raise ::ArgumentError, "request must be provided" if request.nil?
1304
1476
 
@@ -1316,16 +1488,20 @@ module Google
1316
1488
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1317
1489
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1318
1490
 
1319
- header_params = {
1320
- "session" => request.session
1321
- }
1491
+ header_params = {}
1492
+ if request.session
1493
+ header_params["session"] = request.session
1494
+ end
1495
+
1322
1496
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1323
1497
  metadata[:"x-goog-request-params"] ||= request_params_header
1324
1498
 
1325
1499
  options.apply_defaults timeout: @config.rpcs.begin_transaction.timeout,
1326
1500
  metadata: metadata,
1327
1501
  retry_policy: @config.rpcs.begin_transaction.retry_policy
1328
- options.apply_defaults metadata: @config.metadata,
1502
+
1503
+ options.apply_defaults timeout: @config.timeout,
1504
+ metadata: @config.metadata,
1329
1505
  retry_policy: @config.retry_policy
1330
1506
 
1331
1507
  @spanner_stub.call_rpc :begin_transaction, request, options: options do |response, operation|
@@ -1400,6 +1576,21 @@ module Google
1400
1576
  #
1401
1577
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1402
1578
  #
1579
+ # @example Basic example
1580
+ # require "google/cloud/spanner/v1"
1581
+ #
1582
+ # # Create a client object. The client can be reused for multiple calls.
1583
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
1584
+ #
1585
+ # # Create a request. To set request fields, pass in keyword arguments.
1586
+ # request = Google::Cloud::Spanner::V1::CommitRequest.new
1587
+ #
1588
+ # # Call the commit method.
1589
+ # result = client.commit request
1590
+ #
1591
+ # # The returned object is of type Google::Cloud::Spanner::V1::CommitResponse.
1592
+ # p result
1593
+ #
1403
1594
  def commit request, options = nil
1404
1595
  raise ::ArgumentError, "request must be provided" if request.nil?
1405
1596
 
@@ -1417,16 +1608,20 @@ module Google
1417
1608
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1418
1609
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1419
1610
 
1420
- header_params = {
1421
- "session" => request.session
1422
- }
1611
+ header_params = {}
1612
+ if request.session
1613
+ header_params["session"] = request.session
1614
+ end
1615
+
1423
1616
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1424
1617
  metadata[:"x-goog-request-params"] ||= request_params_header
1425
1618
 
1426
1619
  options.apply_defaults timeout: @config.rpcs.commit.timeout,
1427
1620
  metadata: metadata,
1428
1621
  retry_policy: @config.rpcs.commit.retry_policy
1429
- options.apply_defaults metadata: @config.metadata,
1622
+
1623
+ options.apply_defaults timeout: @config.timeout,
1624
+ metadata: @config.metadata,
1430
1625
  retry_policy: @config.retry_policy
1431
1626
 
1432
1627
  @spanner_stub.call_rpc :commit, request, options: options do |response, operation|
@@ -1475,6 +1670,21 @@ module Google
1475
1670
  #
1476
1671
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1477
1672
  #
1673
+ # @example Basic example
1674
+ # require "google/cloud/spanner/v1"
1675
+ #
1676
+ # # Create a client object. The client can be reused for multiple calls.
1677
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
1678
+ #
1679
+ # # Create a request. To set request fields, pass in keyword arguments.
1680
+ # request = Google::Cloud::Spanner::V1::RollbackRequest.new
1681
+ #
1682
+ # # Call the rollback method.
1683
+ # result = client.rollback request
1684
+ #
1685
+ # # The returned object is of type Google::Protobuf::Empty.
1686
+ # p result
1687
+ #
1478
1688
  def rollback request, options = nil
1479
1689
  raise ::ArgumentError, "request must be provided" if request.nil?
1480
1690
 
@@ -1492,16 +1702,20 @@ module Google
1492
1702
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1493
1703
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1494
1704
 
1495
- header_params = {
1496
- "session" => request.session
1497
- }
1705
+ header_params = {}
1706
+ if request.session
1707
+ header_params["session"] = request.session
1708
+ end
1709
+
1498
1710
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1499
1711
  metadata[:"x-goog-request-params"] ||= request_params_header
1500
1712
 
1501
1713
  options.apply_defaults timeout: @config.rpcs.rollback.timeout,
1502
1714
  metadata: metadata,
1503
1715
  retry_policy: @config.rpcs.rollback.retry_policy
1504
- options.apply_defaults metadata: @config.metadata,
1716
+
1717
+ options.apply_defaults timeout: @config.timeout,
1718
+ metadata: @config.metadata,
1505
1719
  retry_policy: @config.retry_policy
1506
1720
 
1507
1721
  @spanner_stub.call_rpc :rollback, request, options: options do |response, operation|
@@ -1589,6 +1803,21 @@ module Google
1589
1803
  #
1590
1804
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1591
1805
  #
1806
+ # @example Basic example
1807
+ # require "google/cloud/spanner/v1"
1808
+ #
1809
+ # # Create a client object. The client can be reused for multiple calls.
1810
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
1811
+ #
1812
+ # # Create a request. To set request fields, pass in keyword arguments.
1813
+ # request = Google::Cloud::Spanner::V1::PartitionQueryRequest.new
1814
+ #
1815
+ # # Call the partition_query method.
1816
+ # result = client.partition_query request
1817
+ #
1818
+ # # The returned object is of type Google::Cloud::Spanner::V1::PartitionResponse.
1819
+ # p result
1820
+ #
1592
1821
  def partition_query request, options = nil
1593
1822
  raise ::ArgumentError, "request must be provided" if request.nil?
1594
1823
 
@@ -1606,16 +1835,20 @@ module Google
1606
1835
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1607
1836
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1608
1837
 
1609
- header_params = {
1610
- "session" => request.session
1611
- }
1838
+ header_params = {}
1839
+ if request.session
1840
+ header_params["session"] = request.session
1841
+ end
1842
+
1612
1843
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1613
1844
  metadata[:"x-goog-request-params"] ||= request_params_header
1614
1845
 
1615
1846
  options.apply_defaults timeout: @config.rpcs.partition_query.timeout,
1616
1847
  metadata: metadata,
1617
1848
  retry_policy: @config.rpcs.partition_query.retry_policy
1618
- options.apply_defaults metadata: @config.metadata,
1849
+
1850
+ options.apply_defaults timeout: @config.timeout,
1851
+ metadata: @config.metadata,
1619
1852
  retry_policy: @config.retry_policy
1620
1853
 
1621
1854
  @spanner_stub.call_rpc :partition_query, request, options: options do |response, operation|
@@ -1689,6 +1922,21 @@ module Google
1689
1922
  #
1690
1923
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1691
1924
  #
1925
+ # @example Basic example
1926
+ # require "google/cloud/spanner/v1"
1927
+ #
1928
+ # # Create a client object. The client can be reused for multiple calls.
1929
+ # client = Google::Cloud::Spanner::V1::Spanner::Client.new
1930
+ #
1931
+ # # Create a request. To set request fields, pass in keyword arguments.
1932
+ # request = Google::Cloud::Spanner::V1::PartitionReadRequest.new
1933
+ #
1934
+ # # Call the partition_read method.
1935
+ # result = client.partition_read request
1936
+ #
1937
+ # # The returned object is of type Google::Cloud::Spanner::V1::PartitionResponse.
1938
+ # p result
1939
+ #
1692
1940
  def partition_read request, options = nil
1693
1941
  raise ::ArgumentError, "request must be provided" if request.nil?
1694
1942
 
@@ -1706,16 +1954,20 @@ module Google
1706
1954
  gapic_version: ::Google::Cloud::Spanner::V1::VERSION
1707
1955
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1708
1956
 
1709
- header_params = {
1710
- "session" => request.session
1711
- }
1957
+ header_params = {}
1958
+ if request.session
1959
+ header_params["session"] = request.session
1960
+ end
1961
+
1712
1962
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1713
1963
  metadata[:"x-goog-request-params"] ||= request_params_header
1714
1964
 
1715
1965
  options.apply_defaults timeout: @config.rpcs.partition_read.timeout,
1716
1966
  metadata: metadata,
1717
1967
  retry_policy: @config.rpcs.partition_read.retry_policy
1718
- options.apply_defaults metadata: @config.metadata,
1968
+
1969
+ options.apply_defaults timeout: @config.timeout,
1970
+ metadata: @config.metadata,
1719
1971
  retry_policy: @config.retry_policy
1720
1972
 
1721
1973
  @spanner_stub.call_rpc :partition_read, request, options: options do |response, operation|
@@ -1739,22 +1991,21 @@ module Google
1739
1991
  # Configuration can be applied globally to all clients, or to a single client
1740
1992
  # on construction.
1741
1993
  #
1742
- # # Examples
1743
- #
1744
- # To modify the global config, setting the timeout for create_session
1745
- # to 20 seconds, and all remaining timeouts to 10 seconds:
1746
- #
1747
- # ::Google::Cloud::Spanner::V1::Spanner::Client.configure do |config|
1748
- # config.timeout = 10.0
1749
- # config.rpcs.create_session.timeout = 20.0
1750
- # end
1751
- #
1752
- # To apply the above configuration only to a new client:
1753
- #
1754
- # client = ::Google::Cloud::Spanner::V1::Spanner::Client.new do |config|
1755
- # config.timeout = 10.0
1756
- # config.rpcs.create_session.timeout = 20.0
1757
- # end
1994
+ # @example
1995
+ #
1996
+ # # Modify the global config, setting the timeout for
1997
+ # # create_session to 20 seconds,
1998
+ # # and all remaining timeouts to 10 seconds.
1999
+ # ::Google::Cloud::Spanner::V1::Spanner::Client.configure do |config|
2000
+ # config.timeout = 10.0
2001
+ # config.rpcs.create_session.timeout = 20.0
2002
+ # end
2003
+ #
2004
+ # # Apply the above configuration only to a new client.
2005
+ # client = ::Google::Cloud::Spanner::V1::Spanner::Client.new do |config|
2006
+ # config.timeout = 10.0
2007
+ # config.rpcs.create_session.timeout = 20.0
2008
+ # end
1758
2009
  #
1759
2010
  # @!attribute [rw] endpoint
1760
2011
  # The hostname or hostname:port of the service endpoint.