google-cloud-spanner 1.16.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +23 -0
  4. data/lib/google-cloud-spanner.rb +10 -13
  5. data/lib/google/cloud/spanner.rb +6 -8
  6. data/lib/google/cloud/spanner/admin/database/credentials.rb +2 -2
  7. data/lib/google/cloud/spanner/admin/instance/credentials.rb +2 -2
  8. data/lib/google/cloud/spanner/backup.rb +1 -1
  9. data/lib/google/cloud/spanner/backup/job.rb +2 -2
  10. data/lib/google/cloud/spanner/backup/job/list.rb +2 -2
  11. data/lib/google/cloud/spanner/backup/list.rb +1 -2
  12. data/lib/google/cloud/spanner/backup/restore/job.rb +2 -2
  13. data/lib/google/cloud/spanner/batch_client.rb +2 -2
  14. data/lib/google/cloud/spanner/batch_snapshot.rb +6 -8
  15. data/lib/google/cloud/spanner/batch_update.rb +1 -1
  16. data/lib/google/cloud/spanner/client.rb +8 -8
  17. data/lib/google/cloud/spanner/commit.rb +14 -14
  18. data/lib/google/cloud/spanner/convert.rb +7 -7
  19. data/lib/google/cloud/spanner/credentials.rb +2 -2
  20. data/lib/google/cloud/spanner/data.rb +2 -2
  21. data/lib/google/cloud/spanner/database.rb +22 -22
  22. data/lib/google/cloud/spanner/database/backup_info.rb +1 -1
  23. data/lib/google/cloud/spanner/database/job.rb +3 -3
  24. data/lib/google/cloud/spanner/database/job/list.rb +2 -2
  25. data/lib/google/cloud/spanner/database/list.rb +1 -1
  26. data/lib/google/cloud/spanner/database/restore_info.rb +1 -1
  27. data/lib/google/cloud/spanner/fields.rb +8 -8
  28. data/lib/google/cloud/spanner/instance.rb +5 -12
  29. data/lib/google/cloud/spanner/instance/config.rb +1 -1
  30. data/lib/google/cloud/spanner/instance/config/list.rb +1 -1
  31. data/lib/google/cloud/spanner/instance/job.rb +2 -2
  32. data/lib/google/cloud/spanner/instance/list.rb +1 -1
  33. data/lib/google/cloud/spanner/partition.rb +4 -4
  34. data/lib/google/cloud/spanner/policy.rb +2 -2
  35. data/lib/google/cloud/spanner/service.rb +209 -297
  36. data/lib/google/cloud/spanner/session.rb +9 -9
  37. data/lib/google/cloud/spanner/snapshot.rb +2 -2
  38. data/lib/google/cloud/spanner/transaction.rb +2 -2
  39. data/lib/google/cloud/spanner/version.rb +1 -1
  40. metadata +18 -107
  41. data/lib/google/cloud/spanner/admin/database.rb +0 -149
  42. data/lib/google/cloud/spanner/admin/database/v1.rb +0 -147
  43. data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +0 -46
  44. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +0 -1513
  45. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +0 -111
  46. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  47. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/options.rb +0 -33
  48. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +0 -151
  49. data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +0 -51
  50. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +0 -131
  51. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +0 -29
  52. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/field_mask.rb +0 -222
  53. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/timestamp.rb +0 -113
  54. data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +0 -39
  55. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/backup.rb +0 -325
  56. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +0 -368
  57. data/lib/google/cloud/spanner/admin/database/v1/doc/google/type/expr.rb +0 -45
  58. data/lib/google/cloud/spanner/admin/instance.rb +0 -164
  59. data/lib/google/cloud/spanner/admin/instance/v1.rb +0 -162
  60. data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +0 -46
  61. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  62. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/options.rb +0 -33
  63. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +0 -151
  64. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +0 -51
  65. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +0 -131
  66. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +0 -29
  67. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +0 -222
  68. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +0 -39
  69. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +0 -334
  70. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/type/expr.rb +0 -45
  71. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +0 -975
  72. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +0 -76
  73. data/lib/google/cloud/spanner/v1.rb +0 -16
  74. data/lib/google/cloud/spanner/v1/credentials.rb +0 -42
  75. data/lib/google/cloud/spanner/v1/doc/google/protobuf/any.rb +0 -131
  76. data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +0 -91
  77. data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +0 -29
  78. data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +0 -74
  79. data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +0 -113
  80. data/lib/google/cloud/spanner/v1/doc/google/rpc/status.rb +0 -39
  81. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +0 -150
  82. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +0 -95
  83. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +0 -121
  84. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +0 -190
  85. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +0 -570
  86. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +0 -432
  87. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +0 -112
  88. data/lib/google/cloud/spanner/v1/spanner_client.rb +0 -1485
  89. data/lib/google/cloud/spanner/v1/spanner_client_config.json +0 -121
  90. data/lib/google/spanner/admin/database/v1/backup_pb.rb +0 -98
  91. data/lib/google/spanner/admin/database/v1/common_pb.rb +0 -28
  92. data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +0 -141
  93. data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +0 -169
  94. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +0 -125
  95. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +0 -181
  96. data/lib/google/spanner/v1/keys_pb.rb +0 -34
  97. data/lib/google/spanner/v1/mutation_pb.rb +0 -39
  98. data/lib/google/spanner/v1/query_plan_pb.rb +0 -48
  99. data/lib/google/spanner/v1/result_set_pb.rb +0 -48
  100. data/lib/google/spanner/v1/spanner_pb.rb +0 -179
  101. data/lib/google/spanner/v1/spanner_services_pb.rb +0 -179
  102. data/lib/google/spanner/v1/transaction_pb.rb +0 -56
  103. data/lib/google/spanner/v1/type_pb.rb +0 -44
@@ -1,147 +0,0 @@
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/admin/database/v1/database_admin_client"
17
- require "google/spanner/admin/database/v1/spanner_database_admin_pb"
18
-
19
- module Google
20
- module Cloud
21
- module Spanner
22
- module Admin
23
- module Database
24
- # rubocop:disable LineLength
25
-
26
- ##
27
- # # Ruby Client for Cloud Spanner Database Admin API
28
- #
29
- # [Cloud Spanner Database Admin API][Product Documentation]:
30
- #
31
- # - [Product Documentation][]
32
- #
33
- # ## Quick Start
34
- # In order to use this library, you first need to go through the following
35
- # steps:
36
- #
37
- # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
38
- # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
39
- # 3. [Enable the Cloud Spanner Database Admin API.](https://console.cloud.google.com/apis/library/spanner.googleapis.com)
40
- # 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-spanner/latest/file.AUTHENTICATION.html)
41
- #
42
- # ### Installation
43
- # ```
44
- # $ gem install google-cloud-spanner
45
- # ```
46
- #
47
- # ### Next Steps
48
- # - Read the [Cloud Spanner Database Admin API Product documentation][Product Documentation]
49
- # to learn more about the product and see How-to Guides.
50
- # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
51
- # to see the full list of Cloud APIs that we cover.
52
- #
53
- # [Product Documentation]: https://cloud.google.com/spanner
54
- #
55
- # ## Enabling Logging
56
- #
57
- # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
58
- # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
59
- # or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
60
- # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
61
- # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
62
- #
63
- # Configuring a Ruby stdlib logger:
64
- #
65
- # ```ruby
66
- # require "logger"
67
- #
68
- # module MyLogger
69
- # LOGGER = Logger.new $stderr, level: Logger::WARN
70
- # def logger
71
- # LOGGER
72
- # end
73
- # end
74
- #
75
- # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
76
- # module GRPC
77
- # extend MyLogger
78
- # end
79
- # ```
80
- #
81
- module V1
82
- # rubocop:enable LineLength
83
-
84
- ##
85
- # Cloud Spanner Database Admin API
86
- #
87
- # The Cloud Spanner Database Admin API can be used to create, drop, and
88
- # list databases. It also enables updating the schema of pre-existing
89
- # databases. It can be also used to create, delete and list backups for a
90
- # database and to restore from an existing backup.
91
- #
92
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
93
- # Provides the means for authenticating requests made by the client. This parameter can
94
- # be many types.
95
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
96
- # authenticating requests made by this client.
97
- # A `String` will be treated as the path to the keyfile to be used for the construction of
98
- # credentials for this client.
99
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
100
- # credentials for this client.
101
- # A `GRPC::Core::Channel` will be used to make calls through.
102
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
103
- # should already be composed with a `GRPC::Core::CallCredentials` object.
104
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
105
- # metadata for requests, generally, to give OAuth credentials.
106
- # @param scopes [Array<String>]
107
- # The OAuth scopes for this service. This parameter is ignored if
108
- # an updater_proc is supplied.
109
- # @param client_config [Hash]
110
- # A Hash for call options for each method. See
111
- # Google::Gax#construct_settings for the structure of
112
- # this data. Falls back to the default config if not specified
113
- # or the specified config is missing data points.
114
- # @param timeout [Numeric]
115
- # The default timeout, in seconds, for calls made through this client.
116
- # @param metadata [Hash]
117
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
118
- # @param exception_transformer [Proc]
119
- # An optional proc that intercepts any exceptions raised during an API call to inject
120
- # custom error handling.
121
- def self.new \
122
- credentials: nil,
123
- scopes: nil,
124
- client_config: nil,
125
- timeout: nil,
126
- metadata: nil,
127
- exception_transformer: nil,
128
- lib_name: nil,
129
- lib_version: nil
130
- kwargs = {
131
- credentials: credentials,
132
- scopes: scopes,
133
- client_config: client_config,
134
- timeout: timeout,
135
- metadata: metadata,
136
- exception_transformer: exception_transformer,
137
- lib_name: lib_name,
138
- lib_version: lib_version
139
- }.select { |_, v| v != nil }
140
- Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.new(**kwargs)
141
- end
142
- end
143
- end
144
- end
145
- end
146
- end
147
- end
@@ -1,46 +0,0 @@
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 "googleauth"
17
-
18
- module Google
19
- module Cloud
20
- module Spanner
21
- module Admin
22
- module Database
23
- module V1
24
- class Credentials < Google::Auth::Credentials
25
- SCOPE = [
26
- "https://www.googleapis.com/auth/cloud-platform",
27
- "https://www.googleapis.com/auth/spanner.admin"
28
- ].freeze
29
- PATH_ENV_VARS = %w(SPANNER_ADMIN_DATABASE_CREDENTIALS
30
- SPANNER_ADMIN_DATABASE_KEYFILE
31
- GOOGLE_CLOUD_CREDENTIALS
32
- GOOGLE_CLOUD_KEYFILE
33
- GCLOUD_KEYFILE)
34
- JSON_ENV_VARS = %w(SPANNER_ADMIN_DATABASE_CREDENTIALS_JSON
35
- SPANNER_ADMIN_DATABASE_KEYFILE_JSON
36
- GOOGLE_CLOUD_CREDENTIALS_JSON
37
- GOOGLE_CLOUD_KEYFILE_JSON
38
- GCLOUD_KEYFILE_JSON)
39
- DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,1513 +0,0 @@
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
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/spanner/admin/database/v1/spanner_database_admin.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
- require "google/gax/operation"
28
- require "google/longrunning/operations_client"
29
-
30
- require "google/spanner/admin/database/v1/spanner_database_admin_pb"
31
- require "google/cloud/spanner/admin/database/v1/credentials"
32
- require "google/cloud/spanner/version"
33
-
34
- module Google
35
- module Cloud
36
- module Spanner
37
- module Admin
38
- module Database
39
- module V1
40
- # Cloud Spanner Database Admin API
41
- #
42
- # The Cloud Spanner Database Admin API can be used to create, drop, and
43
- # list databases. It also enables updating the schema of pre-existing
44
- # databases. It can be also used to create, delete and list backups for a
45
- # database and to restore from an existing backup.
46
- #
47
- # @!attribute [r] database_admin_stub
48
- # @return [Google::Spanner::Admin::Database::V1::DatabaseAdmin::Stub]
49
- class DatabaseAdminClient
50
- # @private
51
- attr_reader :database_admin_stub
52
-
53
- # The default address of the service.
54
- SERVICE_ADDRESS = "spanner.googleapis.com".freeze
55
-
56
- # The default port of the service.
57
- DEFAULT_SERVICE_PORT = 443
58
-
59
- # The default set of gRPC interceptors.
60
- GRPC_INTERCEPTORS = []
61
-
62
- DEFAULT_TIMEOUT = 30
63
-
64
- PAGE_DESCRIPTORS = {
65
- "list_databases" => Google::Gax::PageDescriptor.new(
66
- "page_token",
67
- "next_page_token",
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")
81
- }.freeze
82
-
83
- private_constant :PAGE_DESCRIPTORS
84
-
85
- # The scopes needed to make gRPC calls to all of the methods defined in
86
- # this service.
87
- ALL_SCOPES = [
88
- "https://www.googleapis.com/auth/cloud-platform",
89
- "https://www.googleapis.com/auth/spanner.admin"
90
- ].freeze
91
-
92
- # @private
93
- class OperationsClient < Google::Longrunning::OperationsClient
94
- self::SERVICE_ADDRESS = DatabaseAdminClient::SERVICE_ADDRESS
95
- self::GRPC_INTERCEPTORS = DatabaseAdminClient::GRPC_INTERCEPTORS
96
- end
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
-
104
- DATABASE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
105
- "projects/{project}/instances/{instance}/databases/{database}"
106
- )
107
-
108
- private_constant :DATABASE_PATH_TEMPLATE
109
-
110
- INSTANCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
111
- "projects/{project}/instances/{instance}"
112
- )
113
-
114
- private_constant :INSTANCE_PATH_TEMPLATE
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
-
129
- # Returns a fully-qualified database resource name string.
130
- # @param project [String]
131
- # @param instance [String]
132
- # @param database [String]
133
- # @return [String]
134
- def self.database_path project, instance, database
135
- DATABASE_PATH_TEMPLATE.render(
136
- :"project" => project,
137
- :"instance" => instance,
138
- :"database" => database
139
- )
140
- end
141
-
142
- # Returns a fully-qualified instance resource name string.
143
- # @param project [String]
144
- # @param instance [String]
145
- # @return [String]
146
- def self.instance_path project, instance
147
- INSTANCE_PATH_TEMPLATE.render(
148
- :"project" => project,
149
- :"instance" => instance
150
- )
151
- end
152
-
153
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
154
- # Provides the means for authenticating requests made by the client. This parameter can
155
- # be many types.
156
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
157
- # authenticating requests made by this client.
158
- # A `String` will be treated as the path to the keyfile to be used for the construction of
159
- # credentials for this client.
160
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
161
- # credentials for this client.
162
- # A `GRPC::Core::Channel` will be used to make calls through.
163
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
164
- # should already be composed with a `GRPC::Core::CallCredentials` object.
165
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
166
- # metadata for requests, generally, to give OAuth credentials.
167
- # @param scopes [Array<String>]
168
- # The OAuth scopes for this service. This parameter is ignored if
169
- # an updater_proc is supplied.
170
- # @param client_config [Hash]
171
- # A Hash for call options for each method. See
172
- # Google::Gax#construct_settings for the structure of
173
- # this data. Falls back to the default config if not specified
174
- # or the specified config is missing data points.
175
- # @param timeout [Numeric]
176
- # The default timeout, in seconds, for calls made through this client.
177
- # @param metadata [Hash]
178
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
179
- # @param service_address [String]
180
- # Override for the service hostname, or `nil` to leave as the default.
181
- # @param service_port [Integer]
182
- # Override for the service port, or `nil` to leave as the default.
183
- # @param exception_transformer [Proc]
184
- # An optional proc that intercepts any exceptions raised during an API call to inject
185
- # custom error handling.
186
- def initialize \
187
- credentials: nil,
188
- scopes: ALL_SCOPES,
189
- client_config: {},
190
- timeout: DEFAULT_TIMEOUT,
191
- metadata: nil,
192
- service_address: nil,
193
- service_port: nil,
194
- exception_transformer: nil,
195
- lib_name: nil,
196
- lib_version: ""
197
- # These require statements are intentionally placed here to initialize
198
- # the gRPC module only when it's required.
199
- # See https://github.com/googleapis/toolkit/issues/446
200
- require "google/gax/grpc"
201
- require "google/spanner/admin/database/v1/spanner_database_admin_services_pb"
202
-
203
- credentials ||= Google::Cloud::Spanner::Admin::Database::V1::Credentials.default
204
-
205
- @operations_client = OperationsClient.new(
206
- credentials: credentials,
207
- scopes: scopes,
208
- client_config: client_config,
209
- timeout: timeout,
210
- service_address: service_address,
211
- service_port: service_port,
212
- lib_name: lib_name,
213
- lib_version: lib_version,
214
- metadata: metadata,
215
- )
216
-
217
- if credentials.is_a?(String) || credentials.is_a?(Hash)
218
- updater_proc = Google::Cloud::Spanner::Admin::Database::V1::Credentials.new(credentials).updater_proc
219
- end
220
- if credentials.is_a?(GRPC::Core::Channel)
221
- channel = credentials
222
- end
223
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
224
- chan_creds = credentials
225
- end
226
- if credentials.is_a?(Proc)
227
- updater_proc = credentials
228
- end
229
- if credentials.is_a?(Google::Auth::Credentials)
230
- updater_proc = credentials.updater_proc
231
- end
232
-
233
- package_version = Google::Cloud::Spanner::VERSION
234
-
235
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
236
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
237
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
238
- google_api_client << " grpc/#{GRPC::VERSION}"
239
- google_api_client.freeze
240
-
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
245
- headers.merge!(metadata) unless metadata.nil?
246
- client_config_file = Pathname.new(__dir__).join(
247
- "database_admin_client_config.json"
248
- )
249
- defaults = client_config_file.open do |f|
250
- Google::Gax.construct_settings(
251
- "google.spanner.admin.database.v1.DatabaseAdmin",
252
- JSON.parse(f.read),
253
- client_config,
254
- Google::Gax::Grpc::STATUS_CODE_NAMES,
255
- timeout,
256
- page_descriptors: PAGE_DESCRIPTORS,
257
- errors: Google::Gax::Grpc::API_ERRORS,
258
- metadata: headers
259
- )
260
- end
261
-
262
- # Allow overriding the service path/port in subclasses.
263
- service_path = service_address || self.class::SERVICE_ADDRESS
264
- port = service_port || self.class::DEFAULT_SERVICE_PORT
265
- interceptors = self.class::GRPC_INTERCEPTORS
266
- @database_admin_stub = Google::Gax::Grpc.create_stub(
267
- service_path,
268
- port,
269
- chan_creds: chan_creds,
270
- channel: channel,
271
- updater_proc: updater_proc,
272
- scopes: scopes,
273
- interceptors: interceptors,
274
- &Google::Spanner::Admin::Database::V1::DatabaseAdmin::Stub.method(:new)
275
- )
276
-
277
- @list_databases = Google::Gax.create_api_call(
278
- @database_admin_stub.method(:list_databases),
279
- defaults["list_databases"],
280
- exception_transformer: exception_transformer,
281
- params_extractor: proc do |request|
282
- {'parent' => request.parent}
283
- end
284
- )
285
- @create_database = Google::Gax.create_api_call(
286
- @database_admin_stub.method(:create_database),
287
- defaults["create_database"],
288
- exception_transformer: exception_transformer,
289
- params_extractor: proc do |request|
290
- {'parent' => request.parent}
291
- end
292
- )
293
- @get_database = Google::Gax.create_api_call(
294
- @database_admin_stub.method(:get_database),
295
- defaults["get_database"],
296
- exception_transformer: exception_transformer,
297
- params_extractor: proc do |request|
298
- {'name' => request.name}
299
- end
300
- )
301
- @update_database_ddl = Google::Gax.create_api_call(
302
- @database_admin_stub.method(:update_database_ddl),
303
- defaults["update_database_ddl"],
304
- exception_transformer: exception_transformer,
305
- params_extractor: proc do |request|
306
- {'database' => request.database}
307
- end
308
- )
309
- @drop_database = Google::Gax.create_api_call(
310
- @database_admin_stub.method(:drop_database),
311
- defaults["drop_database"],
312
- exception_transformer: exception_transformer,
313
- params_extractor: proc do |request|
314
- {'database' => request.database}
315
- end
316
- )
317
- @get_database_ddl = Google::Gax.create_api_call(
318
- @database_admin_stub.method(:get_database_ddl),
319
- defaults["get_database_ddl"],
320
- exception_transformer: exception_transformer,
321
- params_extractor: proc do |request|
322
- {'database' => request.database}
323
- end
324
- )
325
- @set_iam_policy = Google::Gax.create_api_call(
326
- @database_admin_stub.method(:set_iam_policy),
327
- defaults["set_iam_policy"],
328
- exception_transformer: exception_transformer,
329
- params_extractor: proc do |request|
330
- {'resource' => request.resource}
331
- end
332
- )
333
- @get_iam_policy = Google::Gax.create_api_call(
334
- @database_admin_stub.method(:get_iam_policy),
335
- defaults["get_iam_policy"],
336
- exception_transformer: exception_transformer,
337
- params_extractor: proc do |request|
338
- {'resource' => request.resource}
339
- end
340
- )
341
- @test_iam_permissions = Google::Gax.create_api_call(
342
- @database_admin_stub.method(:test_iam_permissions),
343
- defaults["test_iam_permissions"],
344
- exception_transformer: exception_transformer,
345
- params_extractor: proc do |request|
346
- {'resource' => request.resource}
347
- end
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
- )
413
- end
414
-
415
- # Service calls
416
-
417
- # Lists Cloud Spanner databases.
418
- #
419
- # @param parent [String]
420
- # Required. The instance whose databases should be listed.
421
- # Values are of the form `projects/<project>/instances/<instance>`.
422
- # @param page_size [Integer]
423
- # The maximum number of resources contained in the underlying API
424
- # response. If page streaming is performed per-resource, this
425
- # parameter does not affect the return value. If page streaming is
426
- # performed per-page, this determines the maximum number of
427
- # resources in a page.
428
- # @param options [Google::Gax::CallOptions]
429
- # Overrides the default settings for this call, e.g, timeout,
430
- # retries, etc.
431
- # @yield [result, operation] Access the result along with the RPC operation
432
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Database::V1::Database>]
433
- # @yieldparam operation [GRPC::ActiveCall::Operation]
434
- # @return [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Database::V1::Database>]
435
- # An enumerable of Google::Spanner::Admin::Database::V1::Database instances.
436
- # See Google::Gax::PagedEnumerable documentation for other
437
- # operations such as per-page iteration or access to the response
438
- # object.
439
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
440
- # @example
441
- # require "google/cloud/spanner/admin/database"
442
- #
443
- # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
444
- # formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
445
- #
446
- # # Iterate over all results.
447
- # database_admin_client.list_databases(formatted_parent).each do |element|
448
- # # Process element.
449
- # end
450
- #
451
- # # Or iterate over results one page at a time.
452
- # database_admin_client.list_databases(formatted_parent).each_page do |page|
453
- # # Process each page at a time.
454
- # page.each do |element|
455
- # # Process element.
456
- # end
457
- # end
458
-
459
- def list_databases \
460
- parent,
461
- page_size: nil,
462
- options: nil,
463
- &block
464
- req = {
465
- parent: parent,
466
- page_size: page_size
467
- }.delete_if { |_, v| v.nil? }
468
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::ListDatabasesRequest)
469
- @list_databases.call(req, options, &block)
470
- end
471
-
472
- # Creates a new Cloud Spanner database and starts to prepare it for serving.
473
- # The returned {Google::Longrunning::Operation long-running operation} will
474
- # have a name of the format `<database_name>/operations/<operation_id>` and
475
- # can be used to track preparation of the database. The
476
- # {Google::Longrunning::Operation#metadata metadata} field type is
477
- # {Google::Spanner::Admin::Database::V1::CreateDatabaseMetadata CreateDatabaseMetadata}. The
478
- # {Google::Longrunning::Operation#response response} field type is
479
- # {Google::Spanner::Admin::Database::V1::Database Database}, if successful.
480
- #
481
- # @param parent [String]
482
- # Required. The name of the instance that will serve the new database.
483
- # Values are of the form `projects/<project>/instances/<instance>`.
484
- # @param create_statement [String]
485
- # Required. A `CREATE DATABASE` statement, which specifies the ID of the
486
- # new database. The database ID must conform to the regular expression
487
- # `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length.
488
- # If the database ID is a reserved word or if it contains a hyphen, the
489
- # database ID must be enclosed in backticks (`` ` ``).
490
- # @param extra_statements [Array<String>]
491
- # Optional. A list of DDL statements to run inside the newly created
492
- # database. Statements can create tables, indexes, etc. These
493
- # statements execute atomically with the creation of the database:
494
- # if there is an error in any statement, the database is not created.
495
- # @param options [Google::Gax::CallOptions]
496
- # Overrides the default settings for this call, e.g, timeout,
497
- # retries, etc.
498
- # @return [Google::Gax::Operation]
499
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
500
- # @example
501
- # require "google/cloud/spanner/admin/database"
502
- #
503
- # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
504
- # formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
505
- #
506
- # # TODO: Initialize `create_statement`:
507
- # create_statement = ''
508
- #
509
- # # Register a callback during the method call.
510
- # operation = database_admin_client.create_database(formatted_parent, create_statement) do |op|
511
- # raise op.results.message if op.error?
512
- # op_results = op.results
513
- # # Process the results.
514
- #
515
- # metadata = op.metadata
516
- # # Process the metadata.
517
- # end
518
- #
519
- # # Or use the return value to register a callback.
520
- # operation.on_done do |op|
521
- # raise op.results.message if op.error?
522
- # op_results = op.results
523
- # # Process the results.
524
- #
525
- # metadata = op.metadata
526
- # # Process the metadata.
527
- # end
528
- #
529
- # # Manually reload the operation.
530
- # operation.reload!
531
- #
532
- # # Or block until the operation completes, triggering callbacks on
533
- # # completion.
534
- # operation.wait_until_done!
535
-
536
- def create_database \
537
- parent,
538
- create_statement,
539
- extra_statements: nil,
540
- options: nil
541
- req = {
542
- parent: parent,
543
- create_statement: create_statement,
544
- extra_statements: extra_statements
545
- }.delete_if { |_, v| v.nil? }
546
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::CreateDatabaseRequest)
547
- operation = Google::Gax::Operation.new(
548
- @create_database.call(req, options),
549
- @operations_client,
550
- Google::Spanner::Admin::Database::V1::Database,
551
- Google::Spanner::Admin::Database::V1::CreateDatabaseMetadata,
552
- call_options: options
553
- )
554
- operation.on_done { |operation| yield(operation) } if block_given?
555
- operation
556
- end
557
-
558
- # Gets the state of a Cloud Spanner database.
559
- #
560
- # @param name [String]
561
- # Required. The name of the requested database. Values are of the form
562
- # `projects/<project>/instances/<instance>/databases/<database>`.
563
- # @param options [Google::Gax::CallOptions]
564
- # Overrides the default settings for this call, e.g, timeout,
565
- # retries, etc.
566
- # @yield [result, operation] Access the result along with the RPC operation
567
- # @yieldparam result [Google::Spanner::Admin::Database::V1::Database]
568
- # @yieldparam operation [GRPC::ActiveCall::Operation]
569
- # @return [Google::Spanner::Admin::Database::V1::Database]
570
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
571
- # @example
572
- # require "google/cloud/spanner/admin/database"
573
- #
574
- # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
575
- # formatted_name = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
576
- # response = database_admin_client.get_database(formatted_name)
577
-
578
- def get_database \
579
- name,
580
- options: nil,
581
- &block
582
- req = {
583
- name: name
584
- }.delete_if { |_, v| v.nil? }
585
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::GetDatabaseRequest)
586
- @get_database.call(req, options, &block)
587
- end
588
-
589
- # Updates the schema of a Cloud Spanner database by
590
- # creating/altering/dropping tables, columns, indexes, etc. The returned
591
- # {Google::Longrunning::Operation long-running operation} will have a name of
592
- # the format `<database_name>/operations/<operation_id>` and can be used to
593
- # track execution of the schema change(s). The
594
- # {Google::Longrunning::Operation#metadata metadata} field type is
595
- # {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlMetadata UpdateDatabaseDdlMetadata}. The operation has no response.
596
- #
597
- # @param database [String]
598
- # Required. The database to update.
599
- # @param statements [Array<String>]
600
- # Required. DDL statements to be applied to the database.
601
- # @param operation_id [String]
602
- # If empty, the new update request is assigned an
603
- # automatically-generated operation ID. Otherwise, `operation_id`
604
- # is used to construct the name of the resulting
605
- # {Google::Longrunning::Operation Operation}.
606
- #
607
- # Specifying an explicit operation ID simplifies determining
608
- # whether the statements were executed in the event that 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
612
- # {Google::Longrunning::Operation#name name} of the resulting
613
- # {Google::Longrunning::Operation longrunning::Operation}: `<database>/operations/<operation_id>`.
614
- #
615
- # `operation_id` should be unique within the database, and must be
616
- # a valid identifier: `[a-z][a-z0-9_]*`. Note that
617
- # automatically-generated operation IDs always begin with an
618
- # underscore. If the named operation already exists,
619
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl} returns
620
- # `ALREADY_EXISTS`.
621
- # @param options [Google::Gax::CallOptions]
622
- # Overrides the default settings for this call, e.g, timeout,
623
- # retries, etc.
624
- # @return [Google::Gax::Operation]
625
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
626
- # @example
627
- # require "google/cloud/spanner/admin/database"
628
- #
629
- # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
630
- # formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
631
- #
632
- # # TODO: Initialize `statements`:
633
- # statements = []
634
- #
635
- # # Register a callback during the method call.
636
- # operation = database_admin_client.update_database_ddl(formatted_database, statements) do |op|
637
- # raise op.results.message if op.error?
638
- # op_results = op.results
639
- # # Process the results.
640
- #
641
- # metadata = op.metadata
642
- # # Process the metadata.
643
- # end
644
- #
645
- # # Or use the return value to register a callback.
646
- # operation.on_done do |op|
647
- # raise op.results.message if op.error?
648
- # op_results = op.results
649
- # # Process the results.
650
- #
651
- # metadata = op.metadata
652
- # # Process the metadata.
653
- # end
654
- #
655
- # # Manually reload the operation.
656
- # operation.reload!
657
- #
658
- # # Or block until the operation completes, triggering callbacks on
659
- # # completion.
660
- # operation.wait_until_done!
661
-
662
- def update_database_ddl \
663
- database,
664
- statements,
665
- operation_id: nil,
666
- options: nil
667
- req = {
668
- database: database,
669
- statements: statements,
670
- operation_id: operation_id
671
- }.delete_if { |_, v| v.nil? }
672
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest)
673
- operation = Google::Gax::Operation.new(
674
- @update_database_ddl.call(req, options),
675
- @operations_client,
676
- Google::Protobuf::Empty,
677
- Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlMetadata,
678
- call_options: options
679
- )
680
- operation.on_done { |operation| yield(operation) } if block_given?
681
- operation
682
- end
683
-
684
- # Drops (aka deletes) a Cloud Spanner database.
685
- # Completed backups for the database will be retained according to their
686
- # `expire_time`.
687
- #
688
- # @param database [String]
689
- # Required. The database to be dropped.
690
- # @param options [Google::Gax::CallOptions]
691
- # Overrides the default settings for this call, e.g, timeout,
692
- # retries, etc.
693
- # @yield [result, operation] Access the result along with the RPC operation
694
- # @yieldparam result []
695
- # @yieldparam operation [GRPC::ActiveCall::Operation]
696
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
697
- # @example
698
- # require "google/cloud/spanner/admin/database"
699
- #
700
- # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
701
- # formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
702
- # database_admin_client.drop_database(formatted_database)
703
-
704
- def drop_database \
705
- database,
706
- options: nil,
707
- &block
708
- req = {
709
- database: database
710
- }.delete_if { |_, v| v.nil? }
711
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::DropDatabaseRequest)
712
- @drop_database.call(req, options, &block)
713
- nil
714
- end
715
-
716
- # Returns the schema of a Cloud Spanner database as a list of formatted
717
- # DDL statements. This method does not show pending schema updates, those may
718
- # be queried using the {Google::Longrunning::Operations Operations} API.
719
- #
720
- # @param database [String]
721
- # Required. The database whose schema we wish to get.
722
- # @param options [Google::Gax::CallOptions]
723
- # Overrides the default settings for this call, e.g, timeout,
724
- # retries, etc.
725
- # @yield [result, operation] Access the result along with the RPC operation
726
- # @yieldparam result [Google::Spanner::Admin::Database::V1::GetDatabaseDdlResponse]
727
- # @yieldparam operation [GRPC::ActiveCall::Operation]
728
- # @return [Google::Spanner::Admin::Database::V1::GetDatabaseDdlResponse]
729
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
730
- # @example
731
- # require "google/cloud/spanner/admin/database"
732
- #
733
- # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
734
- # formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
735
- # response = database_admin_client.get_database_ddl(formatted_database)
736
-
737
- def get_database_ddl \
738
- database,
739
- options: nil,
740
- &block
741
- req = {
742
- database: database
743
- }.delete_if { |_, v| v.nil? }
744
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::GetDatabaseDdlRequest)
745
- @get_database_ddl.call(req, options, &block)
746
- end
747
-
748
- # Sets the access control policy on a database or backup resource.
749
- # Replaces any existing policy.
750
- #
751
- # Authorization requires `spanner.databases.setIamPolicy`
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}.
755
- #
756
- # @param resource [String]
757
- # REQUIRED: The resource for which the policy is being specified.
758
- # See the operation documentation for the appropriate value for this field.
759
- # @param policy [Google::Iam::V1::Policy | Hash]
760
- # REQUIRED: The complete policy to be applied to the `resource`. The size of
761
- # the policy is limited to a few 10s of KB. An empty policy is a
762
- # valid policy but certain Cloud Platform services (such as Projects)
763
- # might reject them.
764
- # A hash of the same form as `Google::Iam::V1::Policy`
765
- # can also be provided.
766
- # @param options [Google::Gax::CallOptions]
767
- # Overrides the default settings for this call, e.g, timeout,
768
- # retries, etc.
769
- # @yield [result, operation] Access the result along with the RPC operation
770
- # @yieldparam result [Google::Iam::V1::Policy]
771
- # @yieldparam operation [GRPC::ActiveCall::Operation]
772
- # @return [Google::Iam::V1::Policy]
773
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
774
- # @example
775
- # require "google/cloud/spanner/admin/database"
776
- #
777
- # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
778
- # formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
779
- #
780
- # # TODO: Initialize `policy`:
781
- # policy = {}
782
- # response = database_admin_client.set_iam_policy(formatted_resource, policy)
783
-
784
- def set_iam_policy \
785
- resource,
786
- policy,
787
- options: nil,
788
- &block
789
- req = {
790
- resource: resource,
791
- policy: policy
792
- }.delete_if { |_, v| v.nil? }
793
- req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
794
- @set_iam_policy.call(req, options, &block)
795
- end
796
-
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.
800
- #
801
- # Authorization requires `spanner.databases.getIamPolicy` permission on
802
- # {Google::Iam::V1::GetIamPolicyRequest#resource resource}.
803
- # For backups, authorization requires `spanner.backups.getIamPolicy`
804
- # permission on {Google::Iam::V1::GetIamPolicyRequest#resource resource}.
805
- #
806
- # @param resource [String]
807
- # REQUIRED: The resource for which the policy is being requested.
808
- # See the operation documentation for the appropriate value for this field.
809
- # @param options_ [Google::Iam::V1::GetPolicyOptions | Hash]
810
- # OPTIONAL: A `GetPolicyOptions` object for specifying options to
811
- # `GetIamPolicy`. This field is only used by Cloud IAM.
812
- # A hash of the same form as `Google::Iam::V1::GetPolicyOptions`
813
- # can also be provided.
814
- # @param options [Google::Gax::CallOptions]
815
- # Overrides the default settings for this call, e.g, timeout,
816
- # retries, etc.
817
- # @yield [result, operation] Access the result along with the RPC operation
818
- # @yieldparam result [Google::Iam::V1::Policy]
819
- # @yieldparam operation [GRPC::ActiveCall::Operation]
820
- # @return [Google::Iam::V1::Policy]
821
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
822
- # @example
823
- # require "google/cloud/spanner/admin/database"
824
- #
825
- # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
826
- # formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
827
- # response = database_admin_client.get_iam_policy(formatted_resource)
828
-
829
- def get_iam_policy \
830
- resource,
831
- options_: nil,
832
- options: nil,
833
- &block
834
- req = {
835
- resource: resource,
836
- options: options_
837
- }.delete_if { |_, v| v.nil? }
838
- req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
839
- @get_iam_policy.call(req, options, &block)
840
- end
841
-
842
- # Returns permissions that the caller has on the specified database or backup
843
- # resource.
844
- #
845
- # Attempting this RPC on a non-existent Cloud Spanner database will
846
- # result in a NOT_FOUND error if the user has
847
- # `spanner.databases.list` permission on the containing Cloud
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.
852
- #
853
- # @param resource [String]
854
- # REQUIRED: The resource for which the policy detail is being requested.
855
- # See the operation documentation for the appropriate value for this field.
856
- # @param permissions [Array<String>]
857
- # The set of permissions to check for the `resource`. Permissions with
858
- # wildcards (such as '*' or 'storage.*') are not allowed. For more
859
- # information see
860
- # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
861
- # @param options [Google::Gax::CallOptions]
862
- # Overrides the default settings for this call, e.g, timeout,
863
- # retries, etc.
864
- # @yield [result, operation] Access the result along with the RPC operation
865
- # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
866
- # @yieldparam operation [GRPC::ActiveCall::Operation]
867
- # @return [Google::Iam::V1::TestIamPermissionsResponse]
868
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
869
- # @example
870
- # require "google/cloud/spanner/admin/database"
871
- #
872
- # database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
873
- # formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
874
- #
875
- # # TODO: Initialize `permissions`:
876
- # permissions = []
877
- # response = database_admin_client.test_iam_permissions(formatted_resource, permissions)
878
-
879
- def test_iam_permissions \
880
- resource,
881
- permissions,
882
- options: nil,
883
- &block
884
- req = {
885
- resource: resource,
886
- permissions: permissions
887
- }.delete_if { |_, v| v.nil? }
888
- req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
889
- @test_iam_permissions.call(req, options, &block)
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
1507
- end
1508
- end
1509
- end
1510
- end
1511
- end
1512
- end
1513
- end