google-cloud-spanner 1.16.2 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +66 -0
  4. data/CONTRIBUTING.md +1 -1
  5. data/lib/google-cloud-spanner.rb +11 -13
  6. data/lib/google/cloud/spanner.rb +13 -13
  7. data/lib/google/cloud/spanner/admin/database/credentials.rb +2 -2
  8. data/lib/google/cloud/spanner/admin/instance/credentials.rb +2 -2
  9. data/lib/google/cloud/spanner/backup.rb +9 -1
  10. data/lib/google/cloud/spanner/backup/job.rb +2 -2
  11. data/lib/google/cloud/spanner/backup/job/list.rb +2 -2
  12. data/lib/google/cloud/spanner/backup/list.rb +1 -2
  13. data/lib/google/cloud/spanner/backup/restore/job.rb +2 -2
  14. data/lib/google/cloud/spanner/batch_client.rb +2 -2
  15. data/lib/google/cloud/spanner/batch_snapshot.rb +120 -23
  16. data/lib/google/cloud/spanner/batch_update.rb +1 -1
  17. data/lib/google/cloud/spanner/client.rb +388 -47
  18. data/lib/google/cloud/spanner/commit.rb +14 -14
  19. data/lib/google/cloud/spanner/commit_response.rb +87 -0
  20. data/lib/google/cloud/spanner/commit_response/commit_stats.rb +51 -0
  21. data/lib/google/cloud/spanner/convert.rb +16 -7
  22. data/lib/google/cloud/spanner/credentials.rb +2 -2
  23. data/lib/google/cloud/spanner/data.rb +2 -2
  24. data/lib/google/cloud/spanner/database.rb +47 -25
  25. data/lib/google/cloud/spanner/database/backup_info.rb +13 -4
  26. data/lib/google/cloud/spanner/database/job.rb +3 -3
  27. data/lib/google/cloud/spanner/database/job/list.rb +2 -2
  28. data/lib/google/cloud/spanner/database/list.rb +1 -1
  29. data/lib/google/cloud/spanner/database/restore_info.rb +1 -1
  30. data/lib/google/cloud/spanner/fields.rb +8 -8
  31. data/lib/google/cloud/spanner/instance.rb +5 -12
  32. data/lib/google/cloud/spanner/instance/config.rb +1 -1
  33. data/lib/google/cloud/spanner/instance/config/list.rb +1 -1
  34. data/lib/google/cloud/spanner/instance/job.rb +2 -2
  35. data/lib/google/cloud/spanner/instance/list.rb +1 -1
  36. data/lib/google/cloud/spanner/partition.rb +4 -4
  37. data/lib/google/cloud/spanner/policy.rb +2 -2
  38. data/lib/google/cloud/spanner/results.rb +103 -24
  39. data/lib/google/cloud/spanner/service.rb +369 -350
  40. data/lib/google/cloud/spanner/session.rb +370 -39
  41. data/lib/google/cloud/spanner/snapshot.rb +60 -6
  42. data/lib/google/cloud/spanner/transaction.rb +116 -10
  43. data/lib/google/cloud/spanner/version.rb +1 -1
  44. metadata +20 -107
  45. data/lib/google/cloud/spanner/admin/database.rb +0 -149
  46. data/lib/google/cloud/spanner/admin/database/v1.rb +0 -147
  47. data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +0 -46
  48. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +0 -1513
  49. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +0 -111
  50. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  51. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/options.rb +0 -33
  52. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +0 -151
  53. data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +0 -51
  54. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +0 -131
  55. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +0 -29
  56. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/field_mask.rb +0 -222
  57. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/timestamp.rb +0 -113
  58. data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +0 -39
  59. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/backup.rb +0 -325
  60. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +0 -368
  61. data/lib/google/cloud/spanner/admin/database/v1/doc/google/type/expr.rb +0 -45
  62. data/lib/google/cloud/spanner/admin/instance.rb +0 -164
  63. data/lib/google/cloud/spanner/admin/instance/v1.rb +0 -162
  64. data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +0 -46
  65. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  66. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/options.rb +0 -33
  67. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +0 -151
  68. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +0 -51
  69. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +0 -131
  70. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +0 -29
  71. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +0 -222
  72. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +0 -39
  73. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +0 -334
  74. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/type/expr.rb +0 -45
  75. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +0 -975
  76. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +0 -76
  77. data/lib/google/cloud/spanner/v1.rb +0 -16
  78. data/lib/google/cloud/spanner/v1/credentials.rb +0 -42
  79. data/lib/google/cloud/spanner/v1/doc/google/protobuf/any.rb +0 -131
  80. data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +0 -91
  81. data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +0 -29
  82. data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +0 -74
  83. data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +0 -113
  84. data/lib/google/cloud/spanner/v1/doc/google/rpc/status.rb +0 -39
  85. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +0 -150
  86. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +0 -95
  87. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +0 -121
  88. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +0 -190
  89. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +0 -570
  90. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +0 -432
  91. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +0 -112
  92. data/lib/google/cloud/spanner/v1/spanner_client.rb +0 -1485
  93. data/lib/google/cloud/spanner/v1/spanner_client_config.json +0 -121
  94. data/lib/google/spanner/admin/database/v1/backup_pb.rb +0 -98
  95. data/lib/google/spanner/admin/database/v1/common_pb.rb +0 -28
  96. data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +0 -141
  97. data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +0 -169
  98. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +0 -125
  99. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +0 -181
  100. data/lib/google/spanner/v1/keys_pb.rb +0 -34
  101. data/lib/google/spanner/v1/mutation_pb.rb +0 -39
  102. data/lib/google/spanner/v1/query_plan_pb.rb +0 -48
  103. data/lib/google/spanner/v1/result_set_pb.rb +0 -48
  104. data/lib/google/spanner/v1/spanner_pb.rb +0 -179
  105. data/lib/google/spanner/v1/spanner_services_pb.rb +0 -179
  106. data/lib/google/spanner/v1/transaction_pb.rb +0 -56
  107. data/lib/google/spanner/v1/type_pb.rb +0 -44
@@ -96,8 +96,8 @@ module Google
96
96
  rows.delete_if(&:nil?)
97
97
  rows.delete_if(&:empty?)
98
98
  @mutations += rows.map do |row|
99
- Google::Spanner::V1::Mutation.new(
100
- insert_or_update: Google::Spanner::V1::Mutation::Write.new(
99
+ V1::Mutation.new(
100
+ insert_or_update: V1::Mutation::Write.new(
101
101
  table: table, columns: row.keys.map(&:to_s),
102
102
  values: [Convert.object_to_grpc_value(row.values).list_value]
103
103
  )
@@ -154,8 +154,8 @@ module Google
154
154
  rows.delete_if(&:nil?)
155
155
  rows.delete_if(&:empty?)
156
156
  @mutations += rows.map do |row|
157
- Google::Spanner::V1::Mutation.new(
158
- insert: Google::Spanner::V1::Mutation::Write.new(
157
+ V1::Mutation.new(
158
+ insert: V1::Mutation::Write.new(
159
159
  table: table, columns: row.keys.map(&:to_s),
160
160
  values: [Convert.object_to_grpc_value(row.values).list_value]
161
161
  )
@@ -211,8 +211,8 @@ module Google
211
211
  rows.delete_if(&:nil?)
212
212
  rows.delete_if(&:empty?)
213
213
  @mutations += rows.map do |row|
214
- Google::Spanner::V1::Mutation.new(
215
- update: Google::Spanner::V1::Mutation::Write.new(
214
+ V1::Mutation.new(
215
+ update: V1::Mutation::Write.new(
216
216
  table: table, columns: row.keys.map(&:to_s),
217
217
  values: [Convert.object_to_grpc_value(row.values).list_value]
218
218
  )
@@ -270,8 +270,8 @@ module Google
270
270
  rows.delete_if(&:nil?)
271
271
  rows.delete_if(&:empty?)
272
272
  @mutations += rows.map do |row|
273
- Google::Spanner::V1::Mutation.new(
274
- replace: Google::Spanner::V1::Mutation::Write.new(
273
+ V1::Mutation.new(
274
+ replace: V1::Mutation::Write.new(
275
275
  table: table, columns: row.keys.map(&:to_s),
276
276
  values: [Convert.object_to_grpc_value(row.values).list_value]
277
277
  )
@@ -306,8 +306,8 @@ module Google
306
306
  #
307
307
  def delete table, keys = []
308
308
  @mutations += [
309
- Google::Spanner::V1::Mutation.new(
310
- delete: Google::Spanner::V1::Mutation::Delete.new(
309
+ V1::Mutation.new(
310
+ delete: V1::Mutation::Delete.new(
311
311
  table: table, key_set: key_set(keys)
312
312
  )
313
313
  )
@@ -323,20 +323,20 @@ module Google
323
323
  protected
324
324
 
325
325
  def key_set keys
326
- return Google::Spanner::V1::KeySet.new all: true if keys.nil?
326
+ return V1::KeySet.new all: true if keys.nil?
327
327
  keys = [keys] unless keys.is_a? Array
328
- return Google::Spanner::V1::KeySet.new all: true if keys.empty?
328
+ return V1::KeySet.new all: true if keys.empty?
329
329
  if keys_are_ranges? keys
330
330
  key_ranges = keys.map do |r|
331
331
  Convert.to_key_range r
332
332
  end
333
- return Google::Spanner::V1::KeySet.new ranges: key_ranges
333
+ return V1::KeySet.new ranges: key_ranges
334
334
  end
335
335
  key_list = keys.map do |key|
336
336
  key = [key] unless key.is_a? Array
337
337
  Convert.object_to_grpc_value(key).list_value
338
338
  end
339
- Google::Spanner::V1::KeySet.new keys: key_list
339
+ V1::KeySet.new keys: key_list
340
340
  end
341
341
 
342
342
  def keys_are_ranges? keys
@@ -0,0 +1,87 @@
1
+ # Copyright 2020 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ require "google/cloud/spanner/commit_response/commit_stats"
17
+
18
+ module Google
19
+ module Cloud
20
+ module Spanner
21
+ ##
22
+ # CommitResponse is a timestamp at which the transaction committed
23
+ # with additional attributes of commit stats.
24
+ #
25
+ # @example
26
+ # require "google/cloud/spanner"
27
+ #
28
+ # spanner = Google::Cloud::Spanner.new
29
+ #
30
+ # db = spanner.client "my-instance", "my-database"
31
+ #
32
+ # timestamp = db.commit do |c|
33
+ # c.update "users", [{ id: 1, name: "Charlie", active: false }]
34
+ # c.insert "users", [{ id: 2, name: "Harvey", active: true }]
35
+ # end
36
+ #
37
+ # puts timestamp
38
+ #
39
+ # @example With commit stats.
40
+ # require "google/cloud/spanner"
41
+ #
42
+ # spanner = Google::Cloud::Spanner.new
43
+ #
44
+ # db = spanner.client "my-instance", "my-database"
45
+ #
46
+ # commit_options = { return_commit_stats: true }
47
+ # commit_resp = db.commit commit_options: commit_options do |c|
48
+ # c.update "users", [{ id: 1, name: "Charlie", active: false }]
49
+ # c.insert "users", [{ id: 2, name: "Harvey", active: true }]
50
+ # end
51
+ #
52
+ # puts commit_resp.timestamp
53
+ # puts commit_resp.stats.mutation_count
54
+ #
55
+ class CommitResponse
56
+ ##
57
+ # @private Creates a new CommitResponse instance.
58
+ def initialize grpc
59
+ @grpc = grpc
60
+ end
61
+
62
+ ##
63
+ # The timestamp at which the transaction committed.
64
+ # @return [Time]
65
+ def timestamp
66
+ Convert.timestamp_to_time @grpc.commit_timestamp
67
+ end
68
+
69
+ ##
70
+ # Additional statistics about a commit.
71
+ # @return [CommitStats, nil] Commit stats or nil if not stats not
72
+ # present.
73
+ def stats
74
+ CommitStats.from_grpc @grpc.commit_stats if @grpc.commit_stats
75
+ end
76
+
77
+ ##
78
+ # @private
79
+ # Creates a new Commit responsee instance from a
80
+ # `Google::Cloud::Spanner::V1::CommitResponse`.
81
+ def self.from_grpc grpc
82
+ new grpc
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,51 @@
1
+ # Copyright 2020 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ require "google/cloud/spanner/convert"
17
+
18
+ module Google
19
+ module Cloud
20
+ module Spanner
21
+ class CommitResponse
22
+ ##
23
+ # # CommitStats
24
+ #
25
+ # Statistical information of a transaction commit.
26
+ #
27
+ class CommitStats
28
+ ##
29
+ # @private Creates a new CommitStats instance.
30
+ def initialize grpc
31
+ @grpc = grpc
32
+ end
33
+
34
+ # The total number of the mutations for the transaction.
35
+ # @return [Integer]
36
+ def mutation_count
37
+ @grpc.mutation_count
38
+ end
39
+
40
+ ##
41
+ # @private
42
+ # Creates a new CommitStats instance from a
43
+ # `Google::Cloud::Spanner::V1::CommitResponse::CommitStats`.
44
+ def self.from_grpc grpc
45
+ new grpc
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -17,6 +17,7 @@ require "time"
17
17
  require "date"
18
18
  require "stringio"
19
19
  require "base64"
20
+ require "bigdecimal"
20
21
  require "google/cloud/spanner/data"
21
22
 
22
23
  module Google
@@ -67,6 +68,9 @@ module Google
67
68
  Google::Protobuf::Value.new bool_value: false
68
69
  when Integer
69
70
  Google::Protobuf::Value.new string_value: obj.to_s
71
+ # BigDecimal must be put before Numeric.
72
+ when BigDecimal
73
+ Google::Protobuf::Value.new string_value: obj.to_s("F")
70
74
  when Numeric
71
75
  if obj == Float::INFINITY
72
76
  Google::Protobuf::Value.new string_value: "Infinity"
@@ -125,6 +129,9 @@ module Google
125
129
  :BOOL
126
130
  when Integer
127
131
  :INT64
132
+ # BigDecimal must be put before Numeric.
133
+ when BigDecimal
134
+ :NUMERIC
128
135
  when Numeric
129
136
  :FLOAT64
130
137
  when Time
@@ -169,12 +176,12 @@ module Google
169
176
  return field.to_grpc_type if field.respond_to? :to_grpc_type
170
177
 
171
178
  if Array === field
172
- Google::Spanner::V1::Type.new(
179
+ V1::Type.new(
173
180
  code: :ARRAY,
174
181
  array_element_type: grpc_type_for_field(field.first)
175
182
  )
176
183
  else
177
- Google::Spanner::V1::Type.new(code: field)
184
+ V1::Type.new(code: field)
178
185
  end
179
186
  end
180
187
 
@@ -214,6 +221,8 @@ module Google
214
221
  end
215
222
  when :STRUCT
216
223
  Data.from_grpc value.list_value.values, type.struct_type.fields
224
+ when :NUMERIC
225
+ BigDecimal value.string_value
217
226
  end
218
227
  end
219
228
 
@@ -274,24 +283,24 @@ module Google
274
283
  range_opts.delete :end_closed
275
284
  end
276
285
 
277
- Google::Spanner::V1::KeyRange.new range_opts
286
+ V1::KeyRange.new range_opts
278
287
  end
279
288
 
280
289
  def to_key_set keys
281
- return Google::Spanner::V1::KeySet.new(all: true) if keys.nil?
290
+ return V1::KeySet.new(all: true) if keys.nil?
282
291
  keys = [keys] unless keys.is_a? Array
283
- return Google::Spanner::V1::KeySet.new(all: true) if keys.empty?
292
+ return V1::KeySet.new(all: true) if keys.empty?
284
293
 
285
294
  if keys_are_ranges? keys
286
295
  key_ranges = keys.map { |r| to_key_range(r) }
287
- return Google::Spanner::V1::KeySet.new(ranges: key_ranges)
296
+ return V1::KeySet.new(ranges: key_ranges)
288
297
  end
289
298
 
290
299
  key_list = keys.map do |key|
291
300
  key = [key] unless key.is_a? Array
292
301
  object_to_grpc_value(key).list_value
293
302
  end
294
- Google::Spanner::V1::KeySet.new keys: key_list
303
+ V1::KeySet.new keys: key_list
295
304
  end
296
305
 
297
306
  def keys_are_ranges? keys
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- require "google/cloud/spanner/v1/credentials"
16
+ require "google/cloud/spanner/v1/spanner/credentials"
17
17
 
18
18
  module Google
19
19
  module Cloud
@@ -37,7 +37,7 @@ module Google
37
37
  #
38
38
  # spanner.project_id #=> "my-project"
39
39
  #
40
- class Credentials < Google::Cloud::Spanner::V1::Credentials
40
+ class Credentials < Google::Cloud::Spanner::V1::Spanner::Credentials
41
41
  end
42
42
  end
43
43
  end
@@ -216,9 +216,9 @@ module Google
216
216
  ##
217
217
  # @private
218
218
  def to_grpc_type
219
- Google::Spanner::V1::Type.new(
219
+ V1::Type.new(
220
220
  code: :STRUCT,
221
- struct_type: Google::Spanner::V1::StructType.new(
221
+ struct_type: V1::StructType.new(
222
222
  fields: @grpc_fields
223
223
  )
224
224
  )
@@ -85,6 +85,18 @@ module Google
85
85
  @grpc.name.split("/")[5]
86
86
  end
87
87
 
88
+ # The version retention period for a database.
89
+ # @return [String]
90
+ def version_retention_period
91
+ @grpc.version_retention_period
92
+ end
93
+
94
+ # The earliest available version time for a database.
95
+ # @return [Time]
96
+ def earliest_version_time
97
+ Convert.timestamp_to_time @grpc.earliest_version_time
98
+ end
99
+
88
100
  ##
89
101
  # The full path for the database resource. Values are of the form
90
102
  # `projects/<project_id>/instances/<instance_id>/databases/<database_id>`.
@@ -229,7 +241,6 @@ module Google
229
241
  true
230
242
  end
231
243
 
232
-
233
244
  # @private
234
245
  DATBASE_OPERATION_METADAT_FILTER_TEMPLATE = [
235
246
  "(metadata.@type:CreateDatabaseMetadata AND " \
@@ -248,10 +259,10 @@ module Google
248
259
  # response.
249
260
  #
250
261
  # The response returns a list of
251
- # {Google::Longrunning::Operation long-running operations} whose names
262
+ # `Google::Longrunning::Operation` long-running operations whose names
252
263
  # are prefixed by a database name within the specified instance.
253
264
  # The long-running operation
254
- # {Google::Longrunning::Operation#metadata metadata} field type
265
+ # `Google::Longrunning::Operation#metadata` metadata field type
255
266
  # `metadata.type_url` describes the type of the metadata.
256
267
  #
257
268
  # The filter expression must specify the field name,
@@ -384,10 +395,9 @@ module Google
384
395
  )
385
396
  end
386
397
 
387
- grpc = service.list_database_operations \
388
- instance_id,
389
- filter: database_filter,
390
- page_size: page_size
398
+ grpc = service.list_database_operations instance_id,
399
+ filter: database_filter,
400
+ page_size: page_size
391
401
  Database::Job::List.from_grpc grpc, service
392
402
  end
393
403
 
@@ -402,6 +412,11 @@ module Google
402
412
  # 366 days from the time the request is received. Required.
403
413
  # Once the `expire_time` has passed, Cloud Spanner will delete the
404
414
  # backup and free the resources used by the backup. Required.
415
+ # @param [Time] version_time Specifies the time to have an externally
416
+ # consistent copy of the database. If no version time is specified,
417
+ # it will be automatically set to the backup create time. The version
418
+ # time can be as far in the past as specified by the database earliest
419
+ # version time. Optional.
405
420
  # @return [Google::Cloud::Spanner::Backup::Job] The job representing
406
421
  # the long-running, asynchronous processing of a backup create
407
422
  # operation.
@@ -412,7 +427,11 @@ module Google
412
427
  # spanner = Google::Cloud::Spanner.new
413
428
  # database = spanner.database "my-instance", "my-database"
414
429
  #
415
- # job = database.create_backup "my-backup", Time.now + 36000
430
+ # backup_id = "my-backup"
431
+ # expire_time = Time.now + (24 * 60 * 60) # 1 day from now
432
+ # version_time = Time.now - (24 * 60 * 60) # 1 day ago (optional)
433
+ #
434
+ # job = database.create_backup backup_id, expire_time, version_time: version_time
416
435
  #
417
436
  # job.done? #=> false
418
437
  # job.reload! # API call
@@ -424,13 +443,14 @@ module Google
424
443
  # backup = job.backup
425
444
  # end
426
445
  #
427
- def create_backup backup_id, expire_time
446
+ def create_backup backup_id, expire_time, version_time: nil
428
447
  ensure_service!
429
448
  grpc = service.create_backup \
430
449
  instance_id,
431
450
  database_id,
432
451
  backup_id,
433
- expire_time
452
+ expire_time,
453
+ version_time
434
454
  Backup::Job.from_grpc grpc, service
435
455
  end
436
456
 
@@ -573,20 +593,22 @@ module Google
573
593
  #
574
594
  # The permissions that can be checked on a database are:
575
595
  #
576
- # * pubsub.databases.create
577
- # * pubsub.databases.list
578
- # * pubsub.databases.update
579
- # * pubsub.databases.updateDdl
580
- # * pubsub.databases.get
581
- # * pubsub.databases.getDdl
582
- # * pubsub.databases.getIamPolicy
583
- # * pubsub.databases.setIamPolicy
584
- # * pubsub.databases.beginReadOnlyTransaction
585
- # * pubsub.databases.beginOrRollbackReadWriteTransaction
586
- # * pubsub.databases.read
587
- # * pubsub.databases.select
588
- # * pubsub.databases.write
589
- # * pubsub.databases.drop
596
+ # * spanner.databases.beginPartitionedDmlTransaction
597
+ # * spanner.databases.create
598
+ # * spanner.databases.createBackup
599
+ # * spanner.databases.list
600
+ # * spanner.databases.update
601
+ # * spanner.databases.updateDdl
602
+ # * spanner.databases.get
603
+ # * spanner.databases.getDdl
604
+ # * spanner.databases.getIamPolicy
605
+ # * spanner.databases.setIamPolicy
606
+ # * spanner.databases.beginReadOnlyTransaction
607
+ # * spanner.databases.beginOrRollbackReadWriteTransaction
608
+ # * spanner.databases.read
609
+ # * spanner.databases.select
610
+ # * spanner.databases.write
611
+ # * spanner.databases.drop
590
612
  #
591
613
  # @return [Array<Strings>] The permissions that have access.
592
614
  #
@@ -611,7 +633,7 @@ module Google
611
633
 
612
634
  ##
613
635
  # @private Creates a new Database instance from a
614
- # Google::Spanner::Admin::Database::V1::Database.
636
+ # `Google::Cloud::Spanner::Admin::Database::V1::Database`.
615
637
  def self.from_grpc grpc, service
616
638
  new grpc, service
617
639
  end