google-cloud-spanner 1.14.0 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/google-cloud-spanner.rb +13 -0
- data/lib/google/cloud/spanner.rb +2 -1
- data/lib/google/cloud/spanner/admin/database.rb +3 -2
- data/lib/google/cloud/spanner/admin/database/v1.rb +3 -2
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +742 -20
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +40 -0
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/field_mask.rb +222 -0
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/timestamp.rb +113 -0
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/backup.rb +325 -0
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +197 -30
- data/lib/google/cloud/spanner/admin/instance.rb +1 -1
- data/lib/google/cloud/spanner/admin/instance/v1.rb +1 -1
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +6 -13
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +8 -5
- data/lib/google/cloud/spanner/batch_client.rb +5 -3
- data/lib/google/cloud/spanner/batch_snapshot.rb +43 -8
- data/lib/google/cloud/spanner/client.rb +57 -8
- 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 +3 -1
- data/lib/google/cloud/spanner/session.rb +37 -6
- data/lib/google/cloud/spanner/snapshot.rb +26 -3
- data/lib/google/cloud/spanner/transaction.rb +49 -5
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +8 -1
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +91 -102
- data/lib/google/cloud/spanner/v1/spanner_client.rb +112 -136
- data/lib/google/cloud/spanner/version.rb +1 -1
- data/lib/google/spanner/admin/database/v1/backup_pb.rb +98 -0
- data/lib/google/spanner/admin/database/v1/common_pb.rb +28 -0
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +53 -0
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +82 -12
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +1 -2
- data/lib/google/spanner/v1/spanner_pb.rb +5 -0
- data/lib/google/spanner/v1/spanner_services_pb.rb +31 -40
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31f7875bf6e782a6e02f78fc4c56059b6a7a33aad2aea8e5bb8ddb93932749e6
|
4
|
+
data.tar.gz: 2d0babe313899246327cdc92fe537a94e5b2a8d58d2e300913bc79bfac4ced84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73fd57fd66a11124e0e987f9dedde6bc1435a5ada931fab6eec310ecc219c977c977eef845eeb134f184dd41903a8f60a630573ba455f597ddbbcd768c00a593
|
7
|
+
data.tar.gz: 39c0e508c9f06534fa6ea0ba9ecf91fff841b6d4709ccdfd2cbcafefa879b47a2c96d9678a96de109098962f4a31b462eea1893f2a00d0025a76f1c6fb2cb1b0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.15.0 / 2020-03-15
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Added support for query options ([#4907](https://www.github.com/googleapis/google-cloud-ruby/issues/4907))
|
8
|
+
* Added support for specifying the query optimizer version.
|
9
|
+
* Support separate project setting for quota/billing
|
10
|
+
|
3
11
|
### 1.14.0 / 2020-02-18
|
4
12
|
|
5
13
|
#### Features
|
data/lib/google-cloud-spanner.rb
CHANGED
@@ -144,6 +144,8 @@ module Google
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
+
# rubocop:disable Metrics/BlockLength
|
148
|
+
|
147
149
|
# Set the default spanner configuration
|
148
150
|
Google::Cloud.configure.add_config! :spanner do |config|
|
149
151
|
default_project = Google::Cloud::Config.deferred do
|
@@ -159,6 +161,14 @@ Google::Cloud.configure.add_config! :spanner do |config|
|
|
159
161
|
ENV["SPANNER_EMULATOR_HOST"]
|
160
162
|
end
|
161
163
|
|
164
|
+
default_query_options = Google::Cloud::Config.deferred do
|
165
|
+
query_options = {}
|
166
|
+
optimizer_version = ENV["SPANNER_OPTIMIZER_VERSION"]
|
167
|
+
query_options[:optimizer_version] = optimizer_version if optimizer_version
|
168
|
+
query_options = nil if query_options.empty?
|
169
|
+
query_options
|
170
|
+
end
|
171
|
+
|
162
172
|
config.add_field! :project_id, default_project, match: String, allow_nil: true
|
163
173
|
config.add_alias! :project, :project_id
|
164
174
|
config.add_field! :credentials, default_creds,
|
@@ -172,4 +182,7 @@ Google::Cloud.configure.add_config! :spanner do |config|
|
|
172
182
|
config.add_field! :emulator_host, default_emulator, match: String, allow_nil: true
|
173
183
|
config.add_field! :lib_name, nil, match: String, allow_nil: true
|
174
184
|
config.add_field! :lib_version, nil, match: String, allow_nil: true
|
185
|
+
config.add_field! :query_options, default_query_options, match: Hash, allow_nil: true
|
175
186
|
end
|
187
|
+
|
188
|
+
# rubocop:enable Metrics/BlockLength
|
data/lib/google/cloud/spanner.rb
CHANGED
@@ -23,7 +23,7 @@ module Google
|
|
23
23
|
# rubocop:disable LineLength
|
24
24
|
|
25
25
|
##
|
26
|
-
# # Ruby Client for Cloud Spanner Database Admin API
|
26
|
+
# # Ruby Client for Cloud Spanner Database Admin API
|
27
27
|
#
|
28
28
|
# [Cloud Spanner Database Admin API][Product Documentation]:
|
29
29
|
#
|
@@ -93,7 +93,8 @@ module Google
|
|
93
93
|
#
|
94
94
|
# The Cloud Spanner Database Admin API can be used to create, drop, and
|
95
95
|
# list databases. It also enables updating the schema of pre-existing
|
96
|
-
# databases.
|
96
|
+
# databases. It can be also used to create, delete and list backups for a
|
97
|
+
# database and to restore from an existing backup.
|
97
98
|
#
|
98
99
|
# @param version [Symbol, String]
|
99
100
|
# The major version of the service to be used. By default :v1
|
@@ -24,7 +24,7 @@ module Google
|
|
24
24
|
# rubocop:disable LineLength
|
25
25
|
|
26
26
|
##
|
27
|
-
# # Ruby Client for Cloud Spanner Database Admin API
|
27
|
+
# # Ruby Client for Cloud Spanner Database Admin API
|
28
28
|
#
|
29
29
|
# [Cloud Spanner Database Admin API][Product Documentation]:
|
30
30
|
#
|
@@ -86,7 +86,8 @@ module Google
|
|
86
86
|
#
|
87
87
|
# The Cloud Spanner Database Admin API can be used to create, drop, and
|
88
88
|
# list databases. It also enables updating the schema of pre-existing
|
89
|
-
# databases.
|
89
|
+
# databases. It can be also used to create, delete and list backups for a
|
90
|
+
# database and to restore from an existing backup.
|
90
91
|
#
|
91
92
|
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
92
93
|
# Provides the means for authenticating requests made by the client. This parameter can
|
@@ -41,7 +41,8 @@ module Google
|
|
41
41
|
#
|
42
42
|
# The Cloud Spanner Database Admin API can be used to create, drop, and
|
43
43
|
# list databases. It also enables updating the schema of pre-existing
|
44
|
-
# databases.
|
44
|
+
# databases. It can be also used to create, delete and list backups for a
|
45
|
+
# database and to restore from an existing backup.
|
45
46
|
#
|
46
47
|
# @!attribute [r] database_admin_stub
|
47
48
|
# @return [Google::Spanner::Admin::Database::V1::DatabaseAdmin::Stub]
|
@@ -64,7 +65,19 @@ module Google
|
|
64
65
|
"list_databases" => Google::Gax::PageDescriptor.new(
|
65
66
|
"page_token",
|
66
67
|
"next_page_token",
|
67
|
-
"databases")
|
68
|
+
"databases"),
|
69
|
+
"list_backups" => Google::Gax::PageDescriptor.new(
|
70
|
+
"page_token",
|
71
|
+
"next_page_token",
|
72
|
+
"backups"),
|
73
|
+
"list_database_operations" => Google::Gax::PageDescriptor.new(
|
74
|
+
"page_token",
|
75
|
+
"next_page_token",
|
76
|
+
"operations"),
|
77
|
+
"list_backup_operations" => Google::Gax::PageDescriptor.new(
|
78
|
+
"page_token",
|
79
|
+
"next_page_token",
|
80
|
+
"operations")
|
68
81
|
}.freeze
|
69
82
|
|
70
83
|
private_constant :PAGE_DESCRIPTORS
|
@@ -82,6 +95,12 @@ module Google
|
|
82
95
|
self::GRPC_INTERCEPTORS = DatabaseAdminClient::GRPC_INTERCEPTORS
|
83
96
|
end
|
84
97
|
|
98
|
+
BACKUP_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
99
|
+
"projects/{project}/instances/{instance}/backups/{backup}"
|
100
|
+
)
|
101
|
+
|
102
|
+
private_constant :BACKUP_PATH_TEMPLATE
|
103
|
+
|
85
104
|
DATABASE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
86
105
|
"projects/{project}/instances/{instance}/databases/{database}"
|
87
106
|
)
|
@@ -94,6 +113,19 @@ module Google
|
|
94
113
|
|
95
114
|
private_constant :INSTANCE_PATH_TEMPLATE
|
96
115
|
|
116
|
+
# Returns a fully-qualified backup resource name string.
|
117
|
+
# @param project [String]
|
118
|
+
# @param instance [String]
|
119
|
+
# @param backup [String]
|
120
|
+
# @return [String]
|
121
|
+
def self.backup_path project, instance, backup
|
122
|
+
BACKUP_PATH_TEMPLATE.render(
|
123
|
+
:"project" => project,
|
124
|
+
:"instance" => instance,
|
125
|
+
:"backup" => backup
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
97
129
|
# Returns a fully-qualified database resource name string.
|
98
130
|
# @param project [String]
|
99
131
|
# @param instance [String]
|
@@ -207,6 +239,9 @@ module Google
|
|
207
239
|
google_api_client.freeze
|
208
240
|
|
209
241
|
headers = { :"x-goog-api-client" => google_api_client }
|
242
|
+
if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
|
243
|
+
headers[:"x-goog-user-project"] = credentials.quota_project_id
|
244
|
+
end
|
210
245
|
headers.merge!(metadata) unless metadata.nil?
|
211
246
|
client_config_file = Pathname.new(__dir__).join(
|
212
247
|
"database_admin_client_config.json"
|
@@ -311,6 +346,70 @@ module Google
|
|
311
346
|
{'resource' => request.resource}
|
312
347
|
end
|
313
348
|
)
|
349
|
+
@create_backup = Google::Gax.create_api_call(
|
350
|
+
@database_admin_stub.method(:create_backup),
|
351
|
+
defaults["create_backup"],
|
352
|
+
exception_transformer: exception_transformer,
|
353
|
+
params_extractor: proc do |request|
|
354
|
+
{'parent' => request.parent}
|
355
|
+
end
|
356
|
+
)
|
357
|
+
@get_backup = Google::Gax.create_api_call(
|
358
|
+
@database_admin_stub.method(:get_backup),
|
359
|
+
defaults["get_backup"],
|
360
|
+
exception_transformer: exception_transformer,
|
361
|
+
params_extractor: proc do |request|
|
362
|
+
{'name' => request.name}
|
363
|
+
end
|
364
|
+
)
|
365
|
+
@update_backup = Google::Gax.create_api_call(
|
366
|
+
@database_admin_stub.method(:update_backup),
|
367
|
+
defaults["update_backup"],
|
368
|
+
exception_transformer: exception_transformer,
|
369
|
+
params_extractor: proc do |request|
|
370
|
+
{'backup.name' => request.backup.name}
|
371
|
+
end
|
372
|
+
)
|
373
|
+
@delete_backup = Google::Gax.create_api_call(
|
374
|
+
@database_admin_stub.method(:delete_backup),
|
375
|
+
defaults["delete_backup"],
|
376
|
+
exception_transformer: exception_transformer,
|
377
|
+
params_extractor: proc do |request|
|
378
|
+
{'name' => request.name}
|
379
|
+
end
|
380
|
+
)
|
381
|
+
@list_backups = Google::Gax.create_api_call(
|
382
|
+
@database_admin_stub.method(:list_backups),
|
383
|
+
defaults["list_backups"],
|
384
|
+
exception_transformer: exception_transformer,
|
385
|
+
params_extractor: proc do |request|
|
386
|
+
{'parent' => request.parent}
|
387
|
+
end
|
388
|
+
)
|
389
|
+
@restore_database = Google::Gax.create_api_call(
|
390
|
+
@database_admin_stub.method(:restore_database),
|
391
|
+
defaults["restore_database"],
|
392
|
+
exception_transformer: exception_transformer,
|
393
|
+
params_extractor: proc do |request|
|
394
|
+
{'parent' => request.parent}
|
395
|
+
end
|
396
|
+
)
|
397
|
+
@list_database_operations = Google::Gax.create_api_call(
|
398
|
+
@database_admin_stub.method(:list_database_operations),
|
399
|
+
defaults["list_database_operations"],
|
400
|
+
exception_transformer: exception_transformer,
|
401
|
+
params_extractor: proc do |request|
|
402
|
+
{'parent' => request.parent}
|
403
|
+
end
|
404
|
+
)
|
405
|
+
@list_backup_operations = Google::Gax.create_api_call(
|
406
|
+
@database_admin_stub.method(:list_backup_operations),
|
407
|
+
defaults["list_backup_operations"],
|
408
|
+
exception_transformer: exception_transformer,
|
409
|
+
params_extractor: proc do |request|
|
410
|
+
{'parent' => request.parent}
|
411
|
+
end
|
412
|
+
)
|
314
413
|
end
|
315
414
|
|
316
415
|
# Service calls
|
@@ -375,8 +474,8 @@ module Google
|
|
375
474
|
# have a name of the format `<database_name>/operations/<operation_id>` and
|
376
475
|
# can be used to track preparation of the database. The
|
377
476
|
# {Google::Longrunning::Operation#metadata metadata} field type is
|
378
|
-
# {Google::Spanner::Admin::Database::V1::CreateDatabaseMetadata CreateDatabaseMetadata}.
|
379
|
-
#
|
477
|
+
# {Google::Spanner::Admin::Database::V1::CreateDatabaseMetadata CreateDatabaseMetadata}. The
|
478
|
+
# {Google::Longrunning::Operation#response response} field type is
|
380
479
|
# {Google::Spanner::Admin::Database::V1::Database Database}, if successful.
|
381
480
|
#
|
382
481
|
# @param parent [String]
|
@@ -389,7 +488,7 @@ module Google
|
|
389
488
|
# If the database ID is a reserved word or if it contains a hyphen, the
|
390
489
|
# database ID must be enclosed in backticks (`` ` ``).
|
391
490
|
# @param extra_statements [Array<String>]
|
392
|
-
#
|
491
|
+
# Optional. A list of DDL statements to run inside the newly created
|
393
492
|
# database. Statements can create tables, indexes, etc. These
|
394
493
|
# statements execute atomically with the creation of the database:
|
395
494
|
# if there is an error in any statement, the database is not created.
|
@@ -493,8 +592,7 @@ module Google
|
|
493
592
|
# the format `<database_name>/operations/<operation_id>` and can be used to
|
494
593
|
# track execution of the schema change(s). The
|
495
594
|
# {Google::Longrunning::Operation#metadata metadata} field type is
|
496
|
-
# {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlMetadata UpdateDatabaseDdlMetadata}.
|
497
|
-
# The operation has no response.
|
595
|
+
# {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlMetadata UpdateDatabaseDdlMetadata}. The operation has no response.
|
498
596
|
#
|
499
597
|
# @param database [String]
|
500
598
|
# Required. The database to update.
|
@@ -508,20 +606,18 @@ module Google
|
|
508
606
|
#
|
509
607
|
# Specifying an explicit operation ID simplifies determining
|
510
608
|
# whether the statements were executed in the event that the
|
511
|
-
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl}
|
512
|
-
#
|
513
|
-
#
|
514
|
-
# and `operation_id` fields can be combined to form the
|
609
|
+
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl} call is replayed,
|
610
|
+
# or the return value is otherwise lost: the {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest#database database} and
|
611
|
+
# `operation_id` fields can be combined to form the
|
515
612
|
# {Google::Longrunning::Operation#name name} of the resulting
|
516
|
-
# {Google::Longrunning::Operation longrunning::Operation}:
|
517
|
-
# `<database>/operations/<operation_id>`.
|
613
|
+
# {Google::Longrunning::Operation longrunning::Operation}: `<database>/operations/<operation_id>`.
|
518
614
|
#
|
519
615
|
# `operation_id` should be unique within the database, and must be
|
520
616
|
# a valid identifier: `[a-z][a-z0-9_]*`. Note that
|
521
617
|
# automatically-generated operation IDs always begin with an
|
522
618
|
# underscore. If the named operation already exists,
|
523
|
-
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl}
|
524
|
-
#
|
619
|
+
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl} returns
|
620
|
+
# `ALREADY_EXISTS`.
|
525
621
|
# @param options [Google::Gax::CallOptions]
|
526
622
|
# Overrides the default settings for this call, e.g, timeout,
|
527
623
|
# retries, etc.
|
@@ -586,6 +682,8 @@ module Google
|
|
586
682
|
end
|
587
683
|
|
588
684
|
# Drops (aka deletes) a Cloud Spanner database.
|
685
|
+
# Completed backups for the database will be retained according to their
|
686
|
+
# `expire_time`.
|
589
687
|
#
|
590
688
|
# @param database [String]
|
591
689
|
# Required. The database to be dropped.
|
@@ -647,11 +745,13 @@ module Google
|
|
647
745
|
@get_database_ddl.call(req, options, &block)
|
648
746
|
end
|
649
747
|
|
650
|
-
# Sets the access control policy on a database resource.
|
748
|
+
# Sets the access control policy on a database or backup resource.
|
651
749
|
# Replaces any existing policy.
|
652
750
|
#
|
653
751
|
# Authorization requires `spanner.databases.setIamPolicy`
|
654
752
|
# permission on {Google::Iam::V1::SetIamPolicyRequest#resource resource}.
|
753
|
+
# For backups, authorization requires `spanner.backups.setIamPolicy`
|
754
|
+
# permission on {Google::Iam::V1::SetIamPolicyRequest#resource resource}.
|
655
755
|
#
|
656
756
|
# @param resource [String]
|
657
757
|
# REQUIRED: The resource for which the policy is being specified.
|
@@ -694,12 +794,14 @@ module Google
|
|
694
794
|
@set_iam_policy.call(req, options, &block)
|
695
795
|
end
|
696
796
|
|
697
|
-
# Gets the access control policy for a database resource.
|
698
|
-
# Returns an empty policy if a database exists but does
|
699
|
-
#
|
797
|
+
# Gets the access control policy for a database or backup resource.
|
798
|
+
# Returns an empty policy if a database or backup exists but does not have a
|
799
|
+
# policy set.
|
700
800
|
#
|
701
801
|
# Authorization requires `spanner.databases.getIamPolicy` permission on
|
702
802
|
# {Google::Iam::V1::GetIamPolicyRequest#resource resource}.
|
803
|
+
# For backups, authorization requires `spanner.backups.getIamPolicy`
|
804
|
+
# permission on {Google::Iam::V1::GetIamPolicyRequest#resource resource}.
|
703
805
|
#
|
704
806
|
# @param resource [String]
|
705
807
|
# REQUIRED: The resource for which the policy is being requested.
|
@@ -737,12 +839,16 @@ module Google
|
|
737
839
|
@get_iam_policy.call(req, options, &block)
|
738
840
|
end
|
739
841
|
|
740
|
-
# Returns permissions that the caller has on the specified database
|
842
|
+
# Returns permissions that the caller has on the specified database or backup
|
843
|
+
# resource.
|
741
844
|
#
|
742
845
|
# Attempting this RPC on a non-existent Cloud Spanner database will
|
743
846
|
# result in a NOT_FOUND error if the user has
|
744
847
|
# `spanner.databases.list` permission on the containing Cloud
|
745
848
|
# Spanner instance. Otherwise returns an empty set of permissions.
|
849
|
+
# Calling this method on a backup that does not exist will
|
850
|
+
# result in a NOT_FOUND error if the user has
|
851
|
+
# `spanner.backups.list` permission on the containing instance.
|
746
852
|
#
|
747
853
|
# @param resource [String]
|
748
854
|
# REQUIRED: The resource for which the policy detail is being requested.
|
@@ -782,6 +888,622 @@ module Google
|
|
782
888
|
req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
|
783
889
|
@test_iam_permissions.call(req, options, &block)
|
784
890
|
end
|
891
|
+
|
892
|
+
# Starts creating a new Cloud Spanner Backup.
|
893
|
+
# The returned backup {Google::Longrunning::Operation long-running operation}
|
894
|
+
# will have a name of the format
|
895
|
+
# `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>`
|
896
|
+
# and can be used to track creation of the backup. The
|
897
|
+
# {Google::Longrunning::Operation#metadata metadata} field type is
|
898
|
+
# {Google::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata}. The
|
899
|
+
# {Google::Longrunning::Operation#response response} field type is
|
900
|
+
# {Google::Spanner::Admin::Database::V1::Backup Backup}, if successful. Cancelling the returned operation will stop the
|
901
|
+
# creation and delete the backup.
|
902
|
+
# There can be only one pending backup creation per database. Backup creation
|
903
|
+
# of different databases can run concurrently.
|
904
|
+
#
|
905
|
+
# @param parent [String]
|
906
|
+
# Required. The name of the instance in which the backup will be
|
907
|
+
# created. This must be the same instance that contains the database the
|
908
|
+
# backup will be created from. The backup will be stored in the
|
909
|
+
# location(s) specified in the instance configuration of this
|
910
|
+
# instance. Values are of the form
|
911
|
+
# `projects/<project>/instances/<instance>`.
|
912
|
+
# @param backup_id [String]
|
913
|
+
# Required. The id of the backup to be created. The `backup_id` appended to
|
914
|
+
# `parent` forms the full backup name of the form
|
915
|
+
# `projects/<project>/instances/<instance>/backups/<backup_id>`.
|
916
|
+
# @param backup [Google::Spanner::Admin::Database::V1::Backup | Hash]
|
917
|
+
# Required. The backup to create.
|
918
|
+
# A hash of the same form as `Google::Spanner::Admin::Database::V1::Backup`
|
919
|
+
# can also be provided.
|
920
|
+
# @param options [Google::Gax::CallOptions]
|
921
|
+
# Overrides the default settings for this call, e.g, timeout,
|
922
|
+
# retries, etc.
|
923
|
+
# @return [Google::Gax::Operation]
|
924
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
925
|
+
# @example
|
926
|
+
# require "google/cloud/spanner/admin/database"
|
927
|
+
#
|
928
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
929
|
+
# formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
930
|
+
#
|
931
|
+
# # TODO: Initialize `backup_id`:
|
932
|
+
# backup_id = ''
|
933
|
+
#
|
934
|
+
# # TODO: Initialize `backup`:
|
935
|
+
# backup = {}
|
936
|
+
#
|
937
|
+
# # Register a callback during the method call.
|
938
|
+
# operation = database_admin_client.create_backup(formatted_parent, backup_id, backup) do |op|
|
939
|
+
# raise op.results.message if op.error?
|
940
|
+
# op_results = op.results
|
941
|
+
# # Process the results.
|
942
|
+
#
|
943
|
+
# metadata = op.metadata
|
944
|
+
# # Process the metadata.
|
945
|
+
# end
|
946
|
+
#
|
947
|
+
# # Or use the return value to register a callback.
|
948
|
+
# operation.on_done do |op|
|
949
|
+
# raise op.results.message if op.error?
|
950
|
+
# op_results = op.results
|
951
|
+
# # Process the results.
|
952
|
+
#
|
953
|
+
# metadata = op.metadata
|
954
|
+
# # Process the metadata.
|
955
|
+
# end
|
956
|
+
#
|
957
|
+
# # Manually reload the operation.
|
958
|
+
# operation.reload!
|
959
|
+
#
|
960
|
+
# # Or block until the operation completes, triggering callbacks on
|
961
|
+
# # completion.
|
962
|
+
# operation.wait_until_done!
|
963
|
+
|
964
|
+
def create_backup \
|
965
|
+
parent,
|
966
|
+
backup_id,
|
967
|
+
backup,
|
968
|
+
options: nil
|
969
|
+
req = {
|
970
|
+
parent: parent,
|
971
|
+
backup_id: backup_id,
|
972
|
+
backup: backup
|
973
|
+
}.delete_if { |_, v| v.nil? }
|
974
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::CreateBackupRequest)
|
975
|
+
operation = Google::Gax::Operation.new(
|
976
|
+
@create_backup.call(req, options),
|
977
|
+
@operations_client,
|
978
|
+
Google::Spanner::Admin::Database::V1::Backup,
|
979
|
+
Google::Spanner::Admin::Database::V1::CreateBackupMetadata,
|
980
|
+
call_options: options
|
981
|
+
)
|
982
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
983
|
+
operation
|
984
|
+
end
|
985
|
+
|
986
|
+
# Gets metadata on a pending or completed {Google::Spanner::Admin::Database::V1::Backup Backup}.
|
987
|
+
#
|
988
|
+
# @param name [String]
|
989
|
+
# Required. Name of the backup.
|
990
|
+
# Values are of the form
|
991
|
+
# `projects/<project>/instances/<instance>/backups/<backup>`.
|
992
|
+
# @param options [Google::Gax::CallOptions]
|
993
|
+
# Overrides the default settings for this call, e.g, timeout,
|
994
|
+
# retries, etc.
|
995
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
996
|
+
# @yieldparam result [Google::Spanner::Admin::Database::V1::Backup]
|
997
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
998
|
+
# @return [Google::Spanner::Admin::Database::V1::Backup]
|
999
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1000
|
+
# @example
|
1001
|
+
# require "google/cloud/spanner/admin/database"
|
1002
|
+
#
|
1003
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
1004
|
+
# formatted_name = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.backup_path("[PROJECT]", "[INSTANCE]", "[BACKUP]")
|
1005
|
+
# response = database_admin_client.get_backup(formatted_name)
|
1006
|
+
|
1007
|
+
def get_backup \
|
1008
|
+
name,
|
1009
|
+
options: nil,
|
1010
|
+
&block
|
1011
|
+
req = {
|
1012
|
+
name: name
|
1013
|
+
}.delete_if { |_, v| v.nil? }
|
1014
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::GetBackupRequest)
|
1015
|
+
@get_backup.call(req, options, &block)
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
# Updates a pending or completed {Google::Spanner::Admin::Database::V1::Backup Backup}.
|
1019
|
+
#
|
1020
|
+
# @param backup [Google::Spanner::Admin::Database::V1::Backup | Hash]
|
1021
|
+
# Required. The backup to update. `backup.name`, and the fields to be updated
|
1022
|
+
# as specified by `update_mask` are required. Other fields are ignored.
|
1023
|
+
# Update is only supported for the following fields:
|
1024
|
+
# * `backup.expire_time`.
|
1025
|
+
# A hash of the same form as `Google::Spanner::Admin::Database::V1::Backup`
|
1026
|
+
# can also be provided.
|
1027
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
1028
|
+
# Required. A mask specifying which fields (e.g. `expire_time`) in the
|
1029
|
+
# Backup resource should be updated. This mask is relative to the Backup
|
1030
|
+
# resource, not to the request message. The field mask must always be
|
1031
|
+
# specified; this prevents any future fields from being erased accidentally
|
1032
|
+
# by clients that do not know about them.
|
1033
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
1034
|
+
# can also be provided.
|
1035
|
+
# @param options [Google::Gax::CallOptions]
|
1036
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1037
|
+
# retries, etc.
|
1038
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
1039
|
+
# @yieldparam result [Google::Spanner::Admin::Database::V1::Backup]
|
1040
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1041
|
+
# @return [Google::Spanner::Admin::Database::V1::Backup]
|
1042
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1043
|
+
# @example
|
1044
|
+
# require "google/cloud/spanner/admin/database"
|
1045
|
+
#
|
1046
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
1047
|
+
#
|
1048
|
+
# # TODO: Initialize `backup`:
|
1049
|
+
# backup = {}
|
1050
|
+
#
|
1051
|
+
# # TODO: Initialize `update_mask`:
|
1052
|
+
# update_mask = {}
|
1053
|
+
# response = database_admin_client.update_backup(backup, update_mask)
|
1054
|
+
|
1055
|
+
def update_backup \
|
1056
|
+
backup,
|
1057
|
+
update_mask,
|
1058
|
+
options: nil,
|
1059
|
+
&block
|
1060
|
+
req = {
|
1061
|
+
backup: backup,
|
1062
|
+
update_mask: update_mask
|
1063
|
+
}.delete_if { |_, v| v.nil? }
|
1064
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::UpdateBackupRequest)
|
1065
|
+
@update_backup.call(req, options, &block)
|
1066
|
+
end
|
1067
|
+
|
1068
|
+
# Deletes a pending or completed {Google::Spanner::Admin::Database::V1::Backup Backup}.
|
1069
|
+
#
|
1070
|
+
# @param name [String]
|
1071
|
+
# Required. Name of the backup to delete.
|
1072
|
+
# Values are of the form
|
1073
|
+
# `projects/<project>/instances/<instance>/backups/<backup>`.
|
1074
|
+
# @param options [Google::Gax::CallOptions]
|
1075
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1076
|
+
# retries, etc.
|
1077
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
1078
|
+
# @yieldparam result []
|
1079
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1080
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1081
|
+
# @example
|
1082
|
+
# require "google/cloud/spanner/admin/database"
|
1083
|
+
#
|
1084
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
1085
|
+
# formatted_name = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.backup_path("[PROJECT]", "[INSTANCE]", "[BACKUP]")
|
1086
|
+
# database_admin_client.delete_backup(formatted_name)
|
1087
|
+
|
1088
|
+
def delete_backup \
|
1089
|
+
name,
|
1090
|
+
options: nil,
|
1091
|
+
&block
|
1092
|
+
req = {
|
1093
|
+
name: name
|
1094
|
+
}.delete_if { |_, v| v.nil? }
|
1095
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::DeleteBackupRequest)
|
1096
|
+
@delete_backup.call(req, options, &block)
|
1097
|
+
nil
|
1098
|
+
end
|
1099
|
+
|
1100
|
+
# Lists completed and pending backups.
|
1101
|
+
# Backups returned are ordered by `create_time` in descending order,
|
1102
|
+
# starting from the most recent `create_time`.
|
1103
|
+
#
|
1104
|
+
# @param parent [String]
|
1105
|
+
# Required. The instance to list backups from. Values are of the
|
1106
|
+
# form `projects/<project>/instances/<instance>`.
|
1107
|
+
# @param filter [String]
|
1108
|
+
# An expression that filters the list of returned backups.
|
1109
|
+
#
|
1110
|
+
# A filter expression consists of a field name, a comparison operator, and a
|
1111
|
+
# value for filtering.
|
1112
|
+
# The value must be a string, a number, or a boolean. The comparison operator
|
1113
|
+
# must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
|
1114
|
+
# Colon `:` is the contains operator. Filter rules are not case sensitive.
|
1115
|
+
#
|
1116
|
+
# The following fields in the {Google::Spanner::Admin::Database::V1::Backup Backup} are eligible for filtering:
|
1117
|
+
#
|
1118
|
+
# * `name`
|
1119
|
+
# * `database`
|
1120
|
+
# * `state`
|
1121
|
+
# * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
|
1122
|
+
# * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
|
1123
|
+
# * `size_bytes`
|
1124
|
+
#
|
1125
|
+
# You can combine multiple expressions by enclosing each expression in
|
1126
|
+
# parentheses. By default, expressions are combined with AND logic, but
|
1127
|
+
# you can specify AND, OR, and NOT logic explicitly.
|
1128
|
+
#
|
1129
|
+
# Here are a few examples:
|
1130
|
+
#
|
1131
|
+
# * `name:Howl` - The backup's name contains the string "howl".
|
1132
|
+
# * `database:prod`
|
1133
|
+
# * The database's name contains the string "prod".
|
1134
|
+
# * `state:CREATING` - The backup is pending creation.
|
1135
|
+
# * `state:READY` - The backup is fully created and ready for use.
|
1136
|
+
# * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")`
|
1137
|
+
# * The backup name contains the string "howl" and `create_time`
|
1138
|
+
# of the backup is before 2018-03-28T14:50:00Z.
|
1139
|
+
# * `expire_time < \"2018-03-28T14:50:00Z\"`
|
1140
|
+
# * The backup `expire_time` is before 2018-03-28T14:50:00Z.
|
1141
|
+
# * `size_bytes > 10000000000` - The backup's size is greater than 10GB
|
1142
|
+
# @param page_size [Integer]
|
1143
|
+
# The maximum number of resources contained in the underlying API
|
1144
|
+
# response. If page streaming is performed per-resource, this
|
1145
|
+
# parameter does not affect the return value. If page streaming is
|
1146
|
+
# performed per-page, this determines the maximum number of
|
1147
|
+
# resources in a page.
|
1148
|
+
# @param options [Google::Gax::CallOptions]
|
1149
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1150
|
+
# retries, etc.
|
1151
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
1152
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Database::V1::Backup>]
|
1153
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1154
|
+
# @return [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Database::V1::Backup>]
|
1155
|
+
# An enumerable of Google::Spanner::Admin::Database::V1::Backup instances.
|
1156
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
1157
|
+
# operations such as per-page iteration or access to the response
|
1158
|
+
# object.
|
1159
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1160
|
+
# @example
|
1161
|
+
# require "google/cloud/spanner/admin/database"
|
1162
|
+
#
|
1163
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
1164
|
+
# formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
1165
|
+
#
|
1166
|
+
# # TODO: Initialize `filter`:
|
1167
|
+
# filter = ''
|
1168
|
+
#
|
1169
|
+
# # Iterate over all results.
|
1170
|
+
# database_admin_client.list_backups(formatted_parent, filter).each do |element|
|
1171
|
+
# # Process element.
|
1172
|
+
# end
|
1173
|
+
#
|
1174
|
+
# # Or iterate over results one page at a time.
|
1175
|
+
# database_admin_client.list_backups(formatted_parent, filter).each_page do |page|
|
1176
|
+
# # Process each page at a time.
|
1177
|
+
# page.each do |element|
|
1178
|
+
# # Process element.
|
1179
|
+
# end
|
1180
|
+
# end
|
1181
|
+
|
1182
|
+
def list_backups \
|
1183
|
+
parent,
|
1184
|
+
filter,
|
1185
|
+
page_size: nil,
|
1186
|
+
options: nil,
|
1187
|
+
&block
|
1188
|
+
req = {
|
1189
|
+
parent: parent,
|
1190
|
+
filter: filter,
|
1191
|
+
page_size: page_size
|
1192
|
+
}.delete_if { |_, v| v.nil? }
|
1193
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::ListBackupsRequest)
|
1194
|
+
@list_backups.call(req, options, &block)
|
1195
|
+
end
|
1196
|
+
|
1197
|
+
# Create a new database by restoring from a completed backup. The new
|
1198
|
+
# database must be in the same project and in an instance with the same
|
1199
|
+
# instance configuration as the instance containing
|
1200
|
+
# the backup. The returned database [long-running
|
1201
|
+
# operation][google.longrunning.Operation] has a name of the format
|
1202
|
+
# `projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>`,
|
1203
|
+
# and can be used to track the progress of the operation, and to cancel it.
|
1204
|
+
# The {Google::Longrunning::Operation#metadata metadata} field type is
|
1205
|
+
# {Google::Spanner::Admin::Database::V1::RestoreDatabaseMetadata RestoreDatabaseMetadata}.
|
1206
|
+
# The {Google::Longrunning::Operation#response response} type
|
1207
|
+
# is {Google::Spanner::Admin::Database::V1::Database Database}, if
|
1208
|
+
# successful. Cancelling the returned operation will stop the restore and
|
1209
|
+
# delete the database.
|
1210
|
+
# There can be only one database being restored into an instance at a time.
|
1211
|
+
# Once the restore operation completes, a new restore operation can be
|
1212
|
+
# initiated, without waiting for the optimize operation associated with the
|
1213
|
+
# first restore to complete.
|
1214
|
+
#
|
1215
|
+
# @param parent [String]
|
1216
|
+
# Required. The name of the instance in which to create the
|
1217
|
+
# restored database. This instance must be in the same project and
|
1218
|
+
# have the same instance configuration as the instance containing
|
1219
|
+
# the source backup. Values are of the form
|
1220
|
+
# `projects/<project>/instances/<instance>`.
|
1221
|
+
# @param database_id [String]
|
1222
|
+
# Required. The id of the database to create and restore to. This
|
1223
|
+
# database must not already exist. The `database_id` appended to
|
1224
|
+
# `parent` forms the full database name of the form
|
1225
|
+
# `projects/<project>/instances/<instance>/databases/<database_id>`.
|
1226
|
+
# @param backup [String]
|
1227
|
+
# Name of the backup from which to restore. Values are of the form
|
1228
|
+
# `projects/<project>/instances/<instance>/backups/<backup>`.
|
1229
|
+
# @param options [Google::Gax::CallOptions]
|
1230
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1231
|
+
# retries, etc.
|
1232
|
+
# @return [Google::Gax::Operation]
|
1233
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1234
|
+
# @example
|
1235
|
+
# require "google/cloud/spanner/admin/database"
|
1236
|
+
#
|
1237
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
1238
|
+
# formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
1239
|
+
#
|
1240
|
+
# # TODO: Initialize `database_id`:
|
1241
|
+
# database_id = ''
|
1242
|
+
#
|
1243
|
+
# # Register a callback during the method call.
|
1244
|
+
# operation = database_admin_client.restore_database(formatted_parent, database_id) do |op|
|
1245
|
+
# raise op.results.message if op.error?
|
1246
|
+
# op_results = op.results
|
1247
|
+
# # Process the results.
|
1248
|
+
#
|
1249
|
+
# metadata = op.metadata
|
1250
|
+
# # Process the metadata.
|
1251
|
+
# end
|
1252
|
+
#
|
1253
|
+
# # Or use the return value to register a callback.
|
1254
|
+
# operation.on_done do |op|
|
1255
|
+
# raise op.results.message if op.error?
|
1256
|
+
# op_results = op.results
|
1257
|
+
# # Process the results.
|
1258
|
+
#
|
1259
|
+
# metadata = op.metadata
|
1260
|
+
# # Process the metadata.
|
1261
|
+
# end
|
1262
|
+
#
|
1263
|
+
# # Manually reload the operation.
|
1264
|
+
# operation.reload!
|
1265
|
+
#
|
1266
|
+
# # Or block until the operation completes, triggering callbacks on
|
1267
|
+
# # completion.
|
1268
|
+
# operation.wait_until_done!
|
1269
|
+
|
1270
|
+
def restore_database \
|
1271
|
+
parent,
|
1272
|
+
database_id,
|
1273
|
+
backup: nil,
|
1274
|
+
options: nil
|
1275
|
+
req = {
|
1276
|
+
parent: parent,
|
1277
|
+
database_id: database_id,
|
1278
|
+
backup: backup
|
1279
|
+
}.delete_if { |_, v| v.nil? }
|
1280
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::RestoreDatabaseRequest)
|
1281
|
+
operation = Google::Gax::Operation.new(
|
1282
|
+
@restore_database.call(req, options),
|
1283
|
+
@operations_client,
|
1284
|
+
Google::Spanner::Admin::Database::V1::Database,
|
1285
|
+
Google::Spanner::Admin::Database::V1::RestoreDatabaseMetadata,
|
1286
|
+
call_options: options
|
1287
|
+
)
|
1288
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
1289
|
+
operation
|
1290
|
+
end
|
1291
|
+
|
1292
|
+
# Lists database {Google::Longrunning::Operation longrunning-operations}.
|
1293
|
+
# A database operation has a name of the form
|
1294
|
+
# `projects/<project>/instances/<instance>/databases/<database>/operations/<operation>`.
|
1295
|
+
# The long-running operation
|
1296
|
+
# {Google::Longrunning::Operation#metadata metadata} field type
|
1297
|
+
# `metadata.type_url` describes the type of the metadata. Operations returned
|
1298
|
+
# include those that have completed/failed/canceled within the last 7 days,
|
1299
|
+
# and pending operations.
|
1300
|
+
#
|
1301
|
+
# @param parent [String]
|
1302
|
+
# Required. The instance of the database operations.
|
1303
|
+
# Values are of the form `projects/<project>/instances/<instance>`.
|
1304
|
+
# @param filter [String]
|
1305
|
+
# An expression that filters the list of returned operations.
|
1306
|
+
#
|
1307
|
+
# A filter expression consists of a field name, a
|
1308
|
+
# comparison operator, and a value for filtering.
|
1309
|
+
# The value must be a string, a number, or a boolean. The comparison operator
|
1310
|
+
# must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
|
1311
|
+
# Colon `:` is the contains operator. Filter rules are not case sensitive.
|
1312
|
+
#
|
1313
|
+
# The following fields in the {Google::Longrunning::Operation Operation}
|
1314
|
+
# are eligible for filtering:
|
1315
|
+
#
|
1316
|
+
# * `name` - The name of the long-running operation
|
1317
|
+
# * `done` - False if the operation is in progress, else true.
|
1318
|
+
# * `metadata.@type` - the type of metadata. For example, the type string
|
1319
|
+
# for {Google::Spanner::Admin::Database::V1::RestoreDatabaseMetadata RestoreDatabaseMetadata} is
|
1320
|
+
# `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`.
|
1321
|
+
# * `metadata.<field_name>` - any field in metadata.value.
|
1322
|
+
# * `error` - Error associated with the long-running operation.
|
1323
|
+
# * `response.@type` - the type of response.
|
1324
|
+
# * `response.<field_name>` - any field in response.value.
|
1325
|
+
#
|
1326
|
+
# You can combine multiple expressions by enclosing each expression in
|
1327
|
+
# parentheses. By default, expressions are combined with AND logic. However,
|
1328
|
+
# you can specify AND, OR, and NOT logic explicitly.
|
1329
|
+
#
|
1330
|
+
# Here are a few examples:
|
1331
|
+
#
|
1332
|
+
# * `done:true` - The operation is complete.
|
1333
|
+
# * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` <br/>
|
1334
|
+
# `(metadata.source_type:BACKUP) AND` <br/>
|
1335
|
+
# `(metadata.backup_info.backup:backup_howl) AND` <br/>
|
1336
|
+
# `(metadata.name:restored_howl) AND` <br/>
|
1337
|
+
# `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
|
1338
|
+
# `(error:*)` - Return operations where:
|
1339
|
+
# * The operation's metadata type is {Google::Spanner::Admin::Database::V1::RestoreDatabaseMetadata RestoreDatabaseMetadata}.
|
1340
|
+
# * The database is restored from a backup.
|
1341
|
+
# * The backup name contains "backup_howl".
|
1342
|
+
# * The restored database's name contains "restored_howl".
|
1343
|
+
# * The operation started before 2018-03-28T14:50:00Z.
|
1344
|
+
# * The operation resulted in an error.
|
1345
|
+
# @param page_size [Integer]
|
1346
|
+
# The maximum number of resources contained in the underlying API
|
1347
|
+
# response. If page streaming is performed per-resource, this
|
1348
|
+
# parameter does not affect the return value. If page streaming is
|
1349
|
+
# performed per-page, this determines the maximum number of
|
1350
|
+
# resources in a page.
|
1351
|
+
# @param options [Google::Gax::CallOptions]
|
1352
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1353
|
+
# retries, etc.
|
1354
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
1355
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Longrunning::Operation>]
|
1356
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1357
|
+
# @return [Google::Gax::PagedEnumerable<Google::Longrunning::Operation>]
|
1358
|
+
# An enumerable of Google::Longrunning::Operation instances.
|
1359
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
1360
|
+
# operations such as per-page iteration or access to the response
|
1361
|
+
# object.
|
1362
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1363
|
+
# @example
|
1364
|
+
# require "google/cloud/spanner/admin/database"
|
1365
|
+
#
|
1366
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
1367
|
+
# formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
1368
|
+
#
|
1369
|
+
# # TODO: Initialize `filter`:
|
1370
|
+
# filter = ''
|
1371
|
+
#
|
1372
|
+
# # Iterate over all results.
|
1373
|
+
# database_admin_client.list_database_operations(formatted_parent, filter).each do |element|
|
1374
|
+
# # Process element.
|
1375
|
+
# end
|
1376
|
+
#
|
1377
|
+
# # Or iterate over results one page at a time.
|
1378
|
+
# database_admin_client.list_database_operations(formatted_parent, filter).each_page do |page|
|
1379
|
+
# # Process each page at a time.
|
1380
|
+
# page.each do |element|
|
1381
|
+
# # Process element.
|
1382
|
+
# end
|
1383
|
+
# end
|
1384
|
+
|
1385
|
+
def list_database_operations \
|
1386
|
+
parent,
|
1387
|
+
filter,
|
1388
|
+
page_size: nil,
|
1389
|
+
options: nil,
|
1390
|
+
&block
|
1391
|
+
req = {
|
1392
|
+
parent: parent,
|
1393
|
+
filter: filter,
|
1394
|
+
page_size: page_size
|
1395
|
+
}.delete_if { |_, v| v.nil? }
|
1396
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::ListDatabaseOperationsRequest)
|
1397
|
+
@list_database_operations.call(req, options, &block)
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
# Lists the backup {Google::Longrunning::Operation long-running operations} in
|
1401
|
+
# the given instance. A backup operation has a name of the form
|
1402
|
+
# `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>`.
|
1403
|
+
# The long-running operation
|
1404
|
+
# {Google::Longrunning::Operation#metadata metadata} field type
|
1405
|
+
# `metadata.type_url` describes the type of the metadata. Operations returned
|
1406
|
+
# include those that have completed/failed/canceled within the last 7 days,
|
1407
|
+
# and pending operations. Operations returned are ordered by
|
1408
|
+
# `operation.metadata.value.progress.start_time` in descending order starting
|
1409
|
+
# from the most recently started operation.
|
1410
|
+
#
|
1411
|
+
# @param parent [String]
|
1412
|
+
# Required. The instance of the backup operations. Values are of
|
1413
|
+
# the form `projects/<project>/instances/<instance>`.
|
1414
|
+
# @param filter [String]
|
1415
|
+
# An expression that filters the list of returned backup operations.
|
1416
|
+
#
|
1417
|
+
# A filter expression consists of a field name, a
|
1418
|
+
# comparison operator, and a value for filtering.
|
1419
|
+
# The value must be a string, a number, or a boolean. The comparison operator
|
1420
|
+
# must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
|
1421
|
+
# Colon `:` is the contains operator. Filter rules are not case sensitive.
|
1422
|
+
#
|
1423
|
+
# The following fields in the {Google::Longrunning::Operation operation}
|
1424
|
+
# are eligible for filtering:
|
1425
|
+
#
|
1426
|
+
# * `name` - The name of the long-running operation
|
1427
|
+
# * `done` - False if the operation is in progress, else true.
|
1428
|
+
# * `metadata.@type` - the type of metadata. For example, the type string
|
1429
|
+
# for {Google::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata} is
|
1430
|
+
# `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`.
|
1431
|
+
# * `metadata.<field_name>` - any field in metadata.value.
|
1432
|
+
# * `error` - Error associated with the long-running operation.
|
1433
|
+
# * `response.@type` - the type of response.
|
1434
|
+
# * `response.<field_name>` - any field in response.value.
|
1435
|
+
#
|
1436
|
+
# You can combine multiple expressions by enclosing each expression in
|
1437
|
+
# parentheses. By default, expressions are combined with AND logic, but
|
1438
|
+
# you can specify AND, OR, and NOT logic explicitly.
|
1439
|
+
#
|
1440
|
+
# Here are a few examples:
|
1441
|
+
#
|
1442
|
+
# * `done:true` - The operation is complete.
|
1443
|
+
# * `metadata.database:prod` - The database the backup was taken from has
|
1444
|
+
# a name containing the string "prod".
|
1445
|
+
# * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` <br/>
|
1446
|
+
# `(metadata.name:howl) AND` <br/>
|
1447
|
+
# `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
|
1448
|
+
# `(error:*)` - Returns operations where:
|
1449
|
+
# * The operation's metadata type is {Google::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata}.
|
1450
|
+
# * The backup name contains the string "howl".
|
1451
|
+
# * The operation started before 2018-03-28T14:50:00Z.
|
1452
|
+
# * The operation resulted in an error.
|
1453
|
+
# @param page_size [Integer]
|
1454
|
+
# The maximum number of resources contained in the underlying API
|
1455
|
+
# response. If page streaming is performed per-resource, this
|
1456
|
+
# parameter does not affect the return value. If page streaming is
|
1457
|
+
# performed per-page, this determines the maximum number of
|
1458
|
+
# resources in a page.
|
1459
|
+
# @param options [Google::Gax::CallOptions]
|
1460
|
+
# Overrides the default settings for this call, e.g, timeout,
|
1461
|
+
# retries, etc.
|
1462
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
1463
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Longrunning::Operation>]
|
1464
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1465
|
+
# @return [Google::Gax::PagedEnumerable<Google::Longrunning::Operation>]
|
1466
|
+
# An enumerable of Google::Longrunning::Operation instances.
|
1467
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
1468
|
+
# operations such as per-page iteration or access to the response
|
1469
|
+
# object.
|
1470
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1471
|
+
# @example
|
1472
|
+
# require "google/cloud/spanner/admin/database"
|
1473
|
+
#
|
1474
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
1475
|
+
# formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
1476
|
+
#
|
1477
|
+
# # TODO: Initialize `filter`:
|
1478
|
+
# filter = ''
|
1479
|
+
#
|
1480
|
+
# # Iterate over all results.
|
1481
|
+
# database_admin_client.list_backup_operations(formatted_parent, filter).each do |element|
|
1482
|
+
# # Process element.
|
1483
|
+
# end
|
1484
|
+
#
|
1485
|
+
# # Or iterate over results one page at a time.
|
1486
|
+
# database_admin_client.list_backup_operations(formatted_parent, filter).each_page do |page|
|
1487
|
+
# # Process each page at a time.
|
1488
|
+
# page.each do |element|
|
1489
|
+
# # Process element.
|
1490
|
+
# end
|
1491
|
+
# end
|
1492
|
+
|
1493
|
+
def list_backup_operations \
|
1494
|
+
parent,
|
1495
|
+
filter,
|
1496
|
+
page_size: nil,
|
1497
|
+
options: nil,
|
1498
|
+
&block
|
1499
|
+
req = {
|
1500
|
+
parent: parent,
|
1501
|
+
filter: filter,
|
1502
|
+
page_size: page_size
|
1503
|
+
}.delete_if { |_, v| v.nil? }
|
1504
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::ListBackupOperationsRequest)
|
1505
|
+
@list_backup_operations.call(req, options, &block)
|
1506
|
+
end
|
785
1507
|
end
|
786
1508
|
end
|
787
1509
|
end
|