google-cloud-spanner 1.14.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +1 -1
- data/CHANGELOG.md +51 -0
- data/CONTRIBUTING.md +5 -5
- data/TROUBLESHOOTING.md +0 -6
- data/lib/google-cloud-spanner.rb +23 -13
- data/lib/google/cloud/spanner.rb +8 -9
- data/lib/google/cloud/spanner/admin/database/credentials.rb +2 -2
- data/lib/google/cloud/spanner/admin/instance/credentials.rb +2 -2
- data/lib/google/cloud/spanner/backup.rb +315 -0
- data/lib/google/cloud/spanner/backup/job.rb +274 -0
- data/lib/google/cloud/spanner/backup/job/list.rb +177 -0
- data/lib/google/cloud/spanner/backup/list.rb +169 -0
- data/lib/google/cloud/spanner/backup/restore/job.rb +246 -0
- data/lib/google/cloud/spanner/batch_client.rb +7 -5
- data/lib/google/cloud/spanner/batch_snapshot.rb +49 -16
- data/lib/google/cloud/spanner/batch_update.rb +1 -1
- data/lib/google/cloud/spanner/client.rb +65 -16
- data/lib/google/cloud/spanner/commit.rb +14 -14
- data/lib/google/cloud/spanner/convert.rb +7 -7
- data/lib/google/cloud/spanner/credentials.rb +2 -2
- data/lib/google/cloud/spanner/data.rb +2 -2
- data/lib/google/cloud/spanner/database.rb +275 -15
- data/lib/google/cloud/spanner/database/backup_info.rb +105 -0
- data/lib/google/cloud/spanner/database/job.rb +5 -2
- data/lib/google/cloud/spanner/database/job/list.rb +177 -0
- data/lib/google/cloud/spanner/database/list.rb +1 -1
- data/lib/google/cloud/spanner/database/restore_info.rb +63 -0
- data/lib/google/cloud/spanner/fields.rb +8 -8
- data/lib/google/cloud/spanner/instance.rb +401 -8
- data/lib/google/cloud/spanner/instance/config.rb +1 -1
- data/lib/google/cloud/spanner/instance/config/list.rb +1 -1
- data/lib/google/cloud/spanner/instance/job.rb +2 -2
- data/lib/google/cloud/spanner/instance/list.rb +1 -1
- data/lib/google/cloud/spanner/partition.rb +4 -4
- data/lib/google/cloud/spanner/policy.rb +2 -2
- data/lib/google/cloud/spanner/project.rb +31 -6
- data/lib/google/cloud/spanner/results.rb +4 -2
- data/lib/google/cloud/spanner/service.rb +231 -240
- data/lib/google/cloud/spanner/session.rb +46 -15
- data/lib/google/cloud/spanner/snapshot.rb +28 -5
- data/lib/google/cloud/spanner/transaction.rb +51 -7
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +28 -104
- data/lib/google/cloud/spanner/admin/database.rb +0 -148
- data/lib/google/cloud/spanner/admin/database/v1.rb +0 -146
- data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +0 -46
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +0 -791
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +0 -71
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +0 -64
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/options.rb +0 -33
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +0 -151
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +0 -201
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/type/expr.rb +0 -45
- data/lib/google/cloud/spanner/admin/instance.rb +0 -164
- data/lib/google/cloud/spanner/admin/instance/v1.rb +0 -162
- data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +0 -46
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +0 -64
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/options.rb +0 -33
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +0 -151
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +0 -341
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/type/expr.rb +0 -45
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +0 -972
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +0 -76
- data/lib/google/cloud/spanner/v1.rb +0 -16
- data/lib/google/cloud/spanner/v1/credentials.rb +0 -42
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +0 -74
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/spanner/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +0 -150
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +0 -88
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +0 -121
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +0 -190
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +0 -581
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +0 -432
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +0 -112
- data/lib/google/cloud/spanner/v1/spanner_client.rb +0 -1509
- data/lib/google/cloud/spanner/v1/spanner_client_config.json +0 -121
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +0 -88
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +0 -99
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +0 -125
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +0 -182
- data/lib/google/spanner/v1/keys_pb.rb +0 -34
- data/lib/google/spanner/v1/mutation_pb.rb +0 -39
- data/lib/google/spanner/v1/query_plan_pb.rb +0 -48
- data/lib/google/spanner/v1/result_set_pb.rb +0 -48
- data/lib/google/spanner/v1/spanner_pb.rb +0 -174
- data/lib/google/spanner/v1/spanner_services_pb.rb +0 -188
- data/lib/google/spanner/v1/transaction_pb.rb +0 -56
- data/lib/google/spanner/v1/type_pb.rb +0 -44
|
@@ -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
|
-
|
|
219
|
+
V1::Type.new(
|
|
220
220
|
code: :STRUCT,
|
|
221
|
-
struct_type:
|
|
221
|
+
struct_type: V1::StructType.new(
|
|
222
222
|
fields: @grpc_fields
|
|
223
223
|
)
|
|
224
224
|
)
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
require "google/cloud/spanner/database/job"
|
|
17
17
|
require "google/cloud/spanner/database/list"
|
|
18
|
+
require "google/cloud/spanner/database/restore_info"
|
|
19
|
+
require "google/cloud/spanner/backup"
|
|
18
20
|
require "google/cloud/spanner/policy"
|
|
19
21
|
|
|
20
22
|
module Google
|
|
@@ -114,6 +116,13 @@ module Google
|
|
|
114
116
|
state == :READY
|
|
115
117
|
end
|
|
116
118
|
|
|
119
|
+
##
|
|
120
|
+
# The database is fully created from backup and optimizing.
|
|
121
|
+
# @return [Boolean]
|
|
122
|
+
def ready_optimizing?
|
|
123
|
+
state == :READY_OPTIMIZING
|
|
124
|
+
end
|
|
125
|
+
|
|
117
126
|
##
|
|
118
127
|
# Retrieve the Data Definition Language (DDL) statements that define
|
|
119
128
|
# database structures. DDL statements are used to create, update,
|
|
@@ -220,6 +229,255 @@ module Google
|
|
|
220
229
|
true
|
|
221
230
|
end
|
|
222
231
|
|
|
232
|
+
# @private
|
|
233
|
+
DATBASE_OPERATION_METADAT_FILTER_TEMPLATE = [
|
|
234
|
+
"(metadata.@type:CreateDatabaseMetadata AND " \
|
|
235
|
+
"metadata.database:%<database_id>s)",
|
|
236
|
+
"(metadata.@type:RestoreDatabaseMetadata AND "\
|
|
237
|
+
"metadata.name:%<database_id>s)",
|
|
238
|
+
"(metadata.@type:UpdateDatabaseDdl AND "\
|
|
239
|
+
"metadata.database:%<database_id>s)"
|
|
240
|
+
].join(" OR ")
|
|
241
|
+
|
|
242
|
+
##
|
|
243
|
+
# Retrieves the list of database operations for the given database.
|
|
244
|
+
#
|
|
245
|
+
# @param filter [String]
|
|
246
|
+
# A filter expression that filters what operations are returned in the
|
|
247
|
+
# response.
|
|
248
|
+
#
|
|
249
|
+
# The response returns a list of
|
|
250
|
+
# `Google::Longrunning::Operation` long-running operations whose names
|
|
251
|
+
# are prefixed by a database name within the specified instance.
|
|
252
|
+
# The long-running operation
|
|
253
|
+
# `Google::Longrunning::Operation#metadata` metadata field type
|
|
254
|
+
# `metadata.type_url` describes the type of the metadata.
|
|
255
|
+
#
|
|
256
|
+
# The filter expression must specify the field name,
|
|
257
|
+
# a comparison operator, and the value that you want to use for
|
|
258
|
+
# filtering. The value must be a string, a number, or a boolean.
|
|
259
|
+
# The comparison operator must be
|
|
260
|
+
# <, >, <=, >=, !=, =, or :. Colon ':' represents a HAS operator
|
|
261
|
+
# which is roughly synonymous with equality. Filter rules are case
|
|
262
|
+
# insensitive.
|
|
263
|
+
#
|
|
264
|
+
# The long-running operation fields eligible for filtering are:
|
|
265
|
+
# * `name` --> The name of the long-running operation
|
|
266
|
+
# * `done` --> False if the operation is in progress, else true.
|
|
267
|
+
# * `metadata.type_url` (using filter string `metadata.@type`) and
|
|
268
|
+
# fields in `metadata.value` (using filter string
|
|
269
|
+
# `metadata.<field_name>`, where <field_name> is a field in
|
|
270
|
+
# metadata.value) are eligible for filtering.
|
|
271
|
+
# * `error` --> Error associated with the long-running operation.
|
|
272
|
+
# * `response.type_url` (using filter string `response.@type`) and
|
|
273
|
+
# fields in `response.value` (using filter string
|
|
274
|
+
# `response.<field_name>`, where <field_name> is a field in
|
|
275
|
+
# response.value)are eligible for filtering.
|
|
276
|
+
#
|
|
277
|
+
# To filter on multiple expressions, provide each separate
|
|
278
|
+
# expression within parentheses. By default, each expression
|
|
279
|
+
# is an AND expression. However, you can include AND, OR, and NOT
|
|
280
|
+
# expressions explicitly.
|
|
281
|
+
#
|
|
282
|
+
# Some examples of using filters are:
|
|
283
|
+
#
|
|
284
|
+
# * `done:true` --> The operation is complete.
|
|
285
|
+
# * `(metadata.@type:type.googleapis.com/google.spanner.admin.\
|
|
286
|
+
# database.v1.RestoreDatabaseMetadata)
|
|
287
|
+
# AND (metadata.source_type:BACKUP)
|
|
288
|
+
# AND (metadata.backup_info.backup:backup_howl)
|
|
289
|
+
# AND (metadata.name:restored_howl)
|
|
290
|
+
# AND (metadata.progress.start_time < \"2018-03-28T14:50:00Z\")
|
|
291
|
+
# AND (error:*)`
|
|
292
|
+
# --> Return RestoreDatabase operations from backups whose name
|
|
293
|
+
# contains "backup_howl", where the created database name
|
|
294
|
+
# contains the string "restored_howl", the start_time of the
|
|
295
|
+
# restore operation is before 2018-03-28T14:50:00Z,
|
|
296
|
+
# and the operation returned an error.
|
|
297
|
+
# @param page_size [Integer]
|
|
298
|
+
# The maximum number of resources contained in the underlying API
|
|
299
|
+
# response. If page streaming is performed per-resource, this
|
|
300
|
+
# parameter does not affect the return value. If page streaming is
|
|
301
|
+
# performed per-page, this determines the maximum number of
|
|
302
|
+
# resources in a page.
|
|
303
|
+
#
|
|
304
|
+
# @return [Array<Google::Cloud::Spanner::Database::Job>] List
|
|
305
|
+
# representing the long-running, asynchronous processing
|
|
306
|
+
# of a database operations.
|
|
307
|
+
# (See {Google::Cloud::Spanner::Database::Job::List})
|
|
308
|
+
#
|
|
309
|
+
# @example
|
|
310
|
+
# require "google/cloud/spanner"
|
|
311
|
+
#
|
|
312
|
+
# spanner = Google::Cloud::Spanner.new
|
|
313
|
+
#
|
|
314
|
+
# database = spanner.database "my-instance", "my-database"
|
|
315
|
+
#
|
|
316
|
+
# jobs = database.database_operations
|
|
317
|
+
# jobs.each do |job|
|
|
318
|
+
# if job.error?
|
|
319
|
+
# p job.error
|
|
320
|
+
# else
|
|
321
|
+
# p job.database.database_id
|
|
322
|
+
# end
|
|
323
|
+
# end
|
|
324
|
+
#
|
|
325
|
+
# @example Retrieve all
|
|
326
|
+
# require "google/cloud/spanner"
|
|
327
|
+
#
|
|
328
|
+
# spanner = Google::Cloud::Spanner.new
|
|
329
|
+
#
|
|
330
|
+
# database = spanner.database "my-instance", "my-database"
|
|
331
|
+
#
|
|
332
|
+
# jobs = database.database_operations
|
|
333
|
+
# jobs.all do |job|
|
|
334
|
+
# if job.error?
|
|
335
|
+
# p job.error
|
|
336
|
+
# else
|
|
337
|
+
# puts job.database.database_id
|
|
338
|
+
# end
|
|
339
|
+
# end
|
|
340
|
+
#
|
|
341
|
+
# @example List by page size
|
|
342
|
+
# require "google/cloud/spanner"
|
|
343
|
+
#
|
|
344
|
+
# spanner = Google::Cloud::Spanner.new
|
|
345
|
+
#
|
|
346
|
+
# database = spanner.database "my-instance", "my-database"
|
|
347
|
+
#
|
|
348
|
+
# jobs = database.database_operations page_size: 10
|
|
349
|
+
# jobs.each do |job|
|
|
350
|
+
# if job.error?
|
|
351
|
+
# p job.error
|
|
352
|
+
# else
|
|
353
|
+
# puts job.database.database_id
|
|
354
|
+
# end
|
|
355
|
+
# end
|
|
356
|
+
#
|
|
357
|
+
# @example Filter and list
|
|
358
|
+
# require "google/cloud/spanner"
|
|
359
|
+
#
|
|
360
|
+
# spanner = Google::Cloud::Spanner.new
|
|
361
|
+
#
|
|
362
|
+
# database = spanner.database "my-instance", "my-database"
|
|
363
|
+
#
|
|
364
|
+
# jobs = database.database_operations filter: "done:true"
|
|
365
|
+
# jobs.each do |job|
|
|
366
|
+
# if job.error?
|
|
367
|
+
# p job.error
|
|
368
|
+
# else
|
|
369
|
+
# puts job.database.database_id
|
|
370
|
+
# end
|
|
371
|
+
# end
|
|
372
|
+
#
|
|
373
|
+
def database_operations filter: nil, page_size: nil
|
|
374
|
+
database_filter = format(
|
|
375
|
+
DATBASE_OPERATION_METADAT_FILTER_TEMPLATE,
|
|
376
|
+
database_id: database_id
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
if filter
|
|
380
|
+
database_filter = format(
|
|
381
|
+
"(%<filter>s) AND (%<database_filter>s)",
|
|
382
|
+
filter: filter, database_filter: database_filter
|
|
383
|
+
)
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
grpc = service.list_database_operations instance_id,
|
|
387
|
+
filter: database_filter,
|
|
388
|
+
page_size: page_size
|
|
389
|
+
Database::Job::List.from_grpc grpc, service
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
##
|
|
393
|
+
# Creates a database backup.
|
|
394
|
+
#
|
|
395
|
+
# @param [String] backup_id The unique identifier for the backup.
|
|
396
|
+
# Values are of the form `[a-z][a-z0-9_\-]*[a-z0-9]` and must be
|
|
397
|
+
# between 2 and 60 characters in length. Required.
|
|
398
|
+
# @param [Time] expire_time The expiration time of the backup, with
|
|
399
|
+
# microseconds granularity that must be at least 6 hours and at most
|
|
400
|
+
# 366 days from the time the request is received. Required.
|
|
401
|
+
# Once the `expire_time` has passed, Cloud Spanner will delete the
|
|
402
|
+
# backup and free the resources used by the backup. Required.
|
|
403
|
+
# @return [Google::Cloud::Spanner::Backup::Job] The job representing
|
|
404
|
+
# the long-running, asynchronous processing of a backup create
|
|
405
|
+
# operation.
|
|
406
|
+
#
|
|
407
|
+
# @example Create backup with expiration time
|
|
408
|
+
# require "google/cloud/spanner"
|
|
409
|
+
#
|
|
410
|
+
# spanner = Google::Cloud::Spanner.new
|
|
411
|
+
# database = spanner.database "my-instance", "my-database"
|
|
412
|
+
#
|
|
413
|
+
# job = database.create_backup "my-backup", Time.now + 36000
|
|
414
|
+
#
|
|
415
|
+
# job.done? #=> false
|
|
416
|
+
# job.reload! # API call
|
|
417
|
+
# job.done? #=> true
|
|
418
|
+
#
|
|
419
|
+
# if job.error?
|
|
420
|
+
# status = job.error
|
|
421
|
+
# else
|
|
422
|
+
# backup = job.backup
|
|
423
|
+
# end
|
|
424
|
+
#
|
|
425
|
+
def create_backup backup_id, expire_time
|
|
426
|
+
ensure_service!
|
|
427
|
+
grpc = service.create_backup \
|
|
428
|
+
instance_id,
|
|
429
|
+
database_id,
|
|
430
|
+
backup_id,
|
|
431
|
+
expire_time
|
|
432
|
+
Backup::Job.from_grpc grpc, service
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
##
|
|
436
|
+
# Retrieves backups belonging to the database.
|
|
437
|
+
#
|
|
438
|
+
# @param [Integer] page_size Optional. Number of backups to be returned
|
|
439
|
+
# in the response. If 0 or less, defaults to the server's maximum
|
|
440
|
+
# allowed page size.
|
|
441
|
+
# @return [Array<Google::Cloud::Spanner::Backup>] Enumerable list of
|
|
442
|
+
# backups. (See {Google::Cloud::Spanner::Backup::List})
|
|
443
|
+
#
|
|
444
|
+
# @example
|
|
445
|
+
# require "google/cloud/spanner"
|
|
446
|
+
#
|
|
447
|
+
# spanner = Google::Cloud::Spanner.new
|
|
448
|
+
# database = spanner.database "my-instance", "my-database"
|
|
449
|
+
#
|
|
450
|
+
# database.backups.all.each do |backup|
|
|
451
|
+
# puts backup.backup_id
|
|
452
|
+
# end
|
|
453
|
+
#
|
|
454
|
+
# @example List backups by page size
|
|
455
|
+
# require "google/cloud/spanner"
|
|
456
|
+
#
|
|
457
|
+
# spanner = Google::Cloud::Spanner.new
|
|
458
|
+
# database = spanner.database "my-instance", "my-database"
|
|
459
|
+
#
|
|
460
|
+
# database.backups(page_size: 5).all.each do |backup|
|
|
461
|
+
# puts backup.backup_id
|
|
462
|
+
# end
|
|
463
|
+
#
|
|
464
|
+
def backups page_size: nil
|
|
465
|
+
ensure_service!
|
|
466
|
+
grpc = service.list_backups \
|
|
467
|
+
instance_id,
|
|
468
|
+
filter: "database:#{database_id}",
|
|
469
|
+
page_size: page_size
|
|
470
|
+
Backup::List.from_grpc grpc, service
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
# Information about the source used to restore the database.
|
|
474
|
+
#
|
|
475
|
+
# @return [Google::Cloud::Spanner::Database::RestoreInfo, nil]
|
|
476
|
+
def restore_info
|
|
477
|
+
return nil unless @grpc.restore_info
|
|
478
|
+
RestoreInfo.from_grpc @grpc.restore_info
|
|
479
|
+
end
|
|
480
|
+
|
|
223
481
|
##
|
|
224
482
|
# Gets the [Cloud IAM](https://cloud.google.com/iam/) access control
|
|
225
483
|
# policy for this database.
|
|
@@ -313,20 +571,22 @@ module Google
|
|
|
313
571
|
#
|
|
314
572
|
# The permissions that can be checked on a database are:
|
|
315
573
|
#
|
|
316
|
-
#
|
|
317
|
-
#
|
|
318
|
-
#
|
|
319
|
-
#
|
|
320
|
-
#
|
|
321
|
-
#
|
|
322
|
-
#
|
|
323
|
-
#
|
|
324
|
-
#
|
|
325
|
-
#
|
|
326
|
-
#
|
|
327
|
-
#
|
|
328
|
-
#
|
|
329
|
-
#
|
|
574
|
+
# * spanner.databases.beginPartitionedDmlTransaction
|
|
575
|
+
# * spanner.databases.create
|
|
576
|
+
# * spanner.databases.createBackup
|
|
577
|
+
# * spanner.databases.list
|
|
578
|
+
# * spanner.databases.update
|
|
579
|
+
# * spanner.databases.updateDdl
|
|
580
|
+
# * spanner.databases.get
|
|
581
|
+
# * spanner.databases.getDdl
|
|
582
|
+
# * spanner.databases.getIamPolicy
|
|
583
|
+
# * spanner.databases.setIamPolicy
|
|
584
|
+
# * spanner.databases.beginReadOnlyTransaction
|
|
585
|
+
# * spanner.databases.beginOrRollbackReadWriteTransaction
|
|
586
|
+
# * spanner.databases.read
|
|
587
|
+
# * spanner.databases.select
|
|
588
|
+
# * spanner.databases.write
|
|
589
|
+
# * spanner.databases.drop
|
|
330
590
|
#
|
|
331
591
|
# @return [Array<Strings>] The permissions that have access.
|
|
332
592
|
#
|
|
@@ -351,7 +611,7 @@ module Google
|
|
|
351
611
|
|
|
352
612
|
##
|
|
353
613
|
# @private Creates a new Database instance from a
|
|
354
|
-
# Google::Spanner::Admin::Database::V1::Database
|
|
614
|
+
# `Google::Cloud::Spanner::Admin::Database::V1::Database`.
|
|
355
615
|
def self.from_grpc grpc, service
|
|
356
616
|
new grpc, service
|
|
357
617
|
end
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
module Google
|
|
17
|
+
module Cloud
|
|
18
|
+
module Spanner
|
|
19
|
+
class Database
|
|
20
|
+
class BackupInfo
|
|
21
|
+
##
|
|
22
|
+
# @private Creates a new Database::BackupInfo instance.
|
|
23
|
+
def initialize grpc
|
|
24
|
+
@grpc = grpc
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# The unique identifier for the project.
|
|
29
|
+
# @return [String]
|
|
30
|
+
def project_id
|
|
31
|
+
@grpc.backup.split("/")[1]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# The unique identifier for the instance.
|
|
36
|
+
# @return [String]
|
|
37
|
+
def instance_id
|
|
38
|
+
@grpc.backup.split("/")[3]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
##
|
|
42
|
+
# The unique identifier for the backup.
|
|
43
|
+
# @return [String]
|
|
44
|
+
def backup_id
|
|
45
|
+
@grpc.backup.split("/")[5]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
##
|
|
49
|
+
# The full path for the backup. Values are of the form
|
|
50
|
+
# `projects/<project>/instances/<instance>/backups/<backup_id>`.
|
|
51
|
+
# @return [String]
|
|
52
|
+
def path
|
|
53
|
+
@grpc.backup
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# Name of the database the backup was created from.
|
|
58
|
+
# @return [String]
|
|
59
|
+
def source_database_id
|
|
60
|
+
@grpc.source_database.split("/")[5]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
##
|
|
64
|
+
# The unique identifier for the source database project.
|
|
65
|
+
# @return [String]
|
|
66
|
+
def source_database_project_id
|
|
67
|
+
@grpc.backup.split("/")[1]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# The unique identifier for the source database instance.
|
|
72
|
+
# @return [String]
|
|
73
|
+
def source_database_instance_id
|
|
74
|
+
@grpc.backup.split("/")[3]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
##
|
|
78
|
+
# The full path for the source database the backup was created from.
|
|
79
|
+
# Values are of the form
|
|
80
|
+
# `projects/<project>/instances/<instance>/database/<database_id>`.
|
|
81
|
+
# @return [String]
|
|
82
|
+
def source_database_path
|
|
83
|
+
@grpc.source_database
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
##
|
|
87
|
+
# The backup contains an externally consistent copy of
|
|
88
|
+
# `source_database` at the timestamp specified by `create_time`.
|
|
89
|
+
# received.
|
|
90
|
+
# @return [Time]
|
|
91
|
+
def create_time
|
|
92
|
+
Convert.timestamp_to_time @grpc.create_time
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
##
|
|
96
|
+
# @private Creates a new Database::BackupInfo instance from a
|
|
97
|
+
# `Google::Cloud::Spanner::Admin::Database::V1::BackupInfo`.
|
|
98
|
+
def self.from_grpc grpc
|
|
99
|
+
new grpc
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|