google-cloud-spanner-admin-database-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +203 -0
  5. data/README.md +75 -0
  6. data/lib/google-cloud-spanner-admin-database-v1.rb +21 -0
  7. data/lib/google/cloud/spanner/admin/database/v1.rb +39 -0
  8. data/lib/google/cloud/spanner/admin/database/v1/database_admin.rb +59 -0
  9. data/lib/google/cloud/spanner/admin/database/v1/database_admin/client.rb +1989 -0
  10. data/lib/google/cloud/spanner/admin/database/v1/database_admin/credentials.rb +56 -0
  11. data/lib/google/cloud/spanner/admin/database/v1/database_admin/operations.rb +574 -0
  12. data/lib/google/cloud/spanner/admin/database/v1/database_admin/paths.rb +92 -0
  13. data/lib/google/cloud/spanner/admin/database/v1/version.rb +32 -0
  14. data/lib/google/spanner/admin/database/v1/backup_pb.rb +101 -0
  15. data/lib/google/spanner/admin/database/v1/common_pb.rb +31 -0
  16. data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +144 -0
  17. data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +170 -0
  18. data/proto_docs/README.md +4 -0
  19. data/proto_docs/google/api/field_behavior.rb +59 -0
  20. data/proto_docs/google/api/resource.rb +247 -0
  21. data/proto_docs/google/iam/v1/iam_policy.rb +80 -0
  22. data/proto_docs/google/iam/v1/options.rb +40 -0
  23. data/proto_docs/google/iam/v1/policy.rb +248 -0
  24. data/proto_docs/google/longrunning/operations.rb +150 -0
  25. data/proto_docs/google/protobuf/any.rb +138 -0
  26. data/proto_docs/google/protobuf/empty.rb +36 -0
  27. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  28. data/proto_docs/google/protobuf/timestamp.rb +120 -0
  29. data/proto_docs/google/rpc/status.rb +46 -0
  30. data/proto_docs/google/spanner/admin/database/v1/backup.rb +364 -0
  31. data/proto_docs/google/spanner/admin/database/v1/common.rb +48 -0
  32. data/proto_docs/google/spanner/admin/database/v1/spanner_database_admin.rb +437 -0
  33. data/proto_docs/google/type/expr.rb +52 -0
  34. metadata +235 -0
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/spanner/admin/database/v1"
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/spanner/admin/database/v1/database_admin"
20
+ require "google/cloud/spanner/admin/database/v1/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Spanner
25
+ module Admin
26
+ module Database
27
+ ##
28
+ # To load this package, including all its services, and instantiate a client:
29
+ #
30
+ # require "google/cloud/spanner/admin/database/v1"
31
+ # client = ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new
32
+ #
33
+ module V1
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/spanner/admin/database/v1/version"
24
+
25
+ require "google/cloud/spanner/admin/database/v1/database_admin/credentials"
26
+ require "google/cloud/spanner/admin/database/v1/database_admin/paths"
27
+ require "google/cloud/spanner/admin/database/v1/database_admin/operations"
28
+ require "google/cloud/spanner/admin/database/v1/database_admin/client"
29
+
30
+ module Google
31
+ module Cloud
32
+ module Spanner
33
+ module Admin
34
+ module Database
35
+ module V1
36
+ ##
37
+ # Cloud Spanner Database Admin API
38
+ #
39
+ # The Cloud Spanner Database Admin API can be used to create, drop, and
40
+ # list databases. It also enables updating the schema of pre-existing
41
+ # databases. It can be also used to create, delete and list backups for a
42
+ # database and to restore from an existing backup.
43
+ #
44
+ # To load this service and instantiate a client:
45
+ #
46
+ # require "google/cloud/spanner/admin/database/v1/database_admin"
47
+ # client = ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new
48
+ #
49
+ module DatabaseAdmin
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ helper_path = ::File.join __dir__, "database_admin", "helpers.rb"
59
+ require "google/cloud/spanner/admin/database/v1/database_admin/helpers" if ::File.file? helper_path
@@ -0,0 +1,1989 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/spanner/admin/database/v1/spanner_database_admin_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Spanner
25
+ module Admin
26
+ module Database
27
+ module V1
28
+ module DatabaseAdmin
29
+ ##
30
+ # Client for the DatabaseAdmin service.
31
+ #
32
+ # Cloud Spanner Database Admin API
33
+ #
34
+ # The Cloud Spanner Database Admin API can be used to create, drop, and
35
+ # list databases. It also enables updating the schema of pre-existing
36
+ # databases. It can be also used to create, delete and list backups for a
37
+ # database and to restore from an existing backup.
38
+ #
39
+ class Client
40
+ include Paths
41
+
42
+ # @private
43
+ attr_reader :database_admin_stub
44
+
45
+ ##
46
+ # Configure the DatabaseAdmin Client class.
47
+ #
48
+ # See {::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client::Configuration}
49
+ # for a description of the configuration fields.
50
+ #
51
+ # ## Example
52
+ #
53
+ # To modify the configuration for all DatabaseAdmin clients:
54
+ #
55
+ # ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.configure do |config|
56
+ # config.timeout = 10.0
57
+ # end
58
+ #
59
+ # @yield [config] Configure the Client client.
60
+ # @yieldparam config [Client::Configuration]
61
+ #
62
+ # @return [Client::Configuration]
63
+ #
64
+ def self.configure
65
+ @configure ||= begin
66
+ namespace = ["Google", "Cloud", "Spanner", "Admin", "Database", "V1"]
67
+ parent_config = while namespace.any?
68
+ parent_name = namespace.join "::"
69
+ parent_const = const_get parent_name
70
+ break parent_const.configure if parent_const&.respond_to? :configure
71
+ namespace.pop
72
+ end
73
+ default_config = Client::Configuration.new parent_config
74
+
75
+ default_config.rpcs.list_databases.timeout = 3600.0
76
+ default_config.rpcs.list_databases.retry_policy = {
77
+ initial_delay: 1.0,
78
+ max_delay: 32.0,
79
+ multiplier: 1.3,
80
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
81
+ }
82
+
83
+ default_config.rpcs.create_database.timeout = 3600.0
84
+
85
+ default_config.rpcs.get_database.timeout = 3600.0
86
+ default_config.rpcs.get_database.retry_policy = {
87
+ initial_delay: 1.0,
88
+ max_delay: 32.0,
89
+ multiplier: 1.3,
90
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
91
+ }
92
+
93
+ default_config.rpcs.update_database_ddl.timeout = 3600.0
94
+ default_config.rpcs.update_database_ddl.retry_policy = {
95
+ initial_delay: 1.0,
96
+ max_delay: 32.0,
97
+ multiplier: 1.3,
98
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
99
+ }
100
+
101
+ default_config.rpcs.drop_database.timeout = 3600.0
102
+ default_config.rpcs.drop_database.retry_policy = {
103
+ initial_delay: 1.0,
104
+ max_delay: 32.0,
105
+ multiplier: 1.3,
106
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
107
+ }
108
+
109
+ default_config.rpcs.get_database_ddl.timeout = 3600.0
110
+ default_config.rpcs.get_database_ddl.retry_policy = {
111
+ initial_delay: 1.0,
112
+ max_delay: 32.0,
113
+ multiplier: 1.3,
114
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
115
+ }
116
+
117
+ default_config.rpcs.set_iam_policy.timeout = 30.0
118
+
119
+ default_config.rpcs.get_iam_policy.timeout = 30.0
120
+ default_config.rpcs.get_iam_policy.retry_policy = {
121
+ initial_delay: 1.0,
122
+ max_delay: 32.0,
123
+ multiplier: 1.3,
124
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
125
+ }
126
+
127
+ default_config.rpcs.test_iam_permissions.timeout = 30.0
128
+
129
+ default_config.rpcs.create_backup.timeout = 3600.0
130
+
131
+ default_config.rpcs.get_backup.timeout = 3600.0
132
+ default_config.rpcs.get_backup.retry_policy = {
133
+ initial_delay: 1.0,
134
+ max_delay: 32.0,
135
+ multiplier: 1.3,
136
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
137
+ }
138
+
139
+ default_config.rpcs.update_backup.timeout = 3600.0
140
+
141
+ default_config.rpcs.delete_backup.timeout = 3600.0
142
+ default_config.rpcs.delete_backup.retry_policy = {
143
+ initial_delay: 1.0,
144
+ max_delay: 32.0,
145
+ multiplier: 1.3,
146
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
147
+ }
148
+
149
+ default_config.rpcs.list_backups.timeout = 3600.0
150
+ default_config.rpcs.list_backups.retry_policy = {
151
+ initial_delay: 1.0,
152
+ max_delay: 32.0,
153
+ multiplier: 1.3,
154
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
155
+ }
156
+
157
+ default_config.rpcs.restore_database.timeout = 3600.0
158
+
159
+ default_config.rpcs.list_database_operations.timeout = 3600.0
160
+ default_config.rpcs.list_database_operations.retry_policy = {
161
+ initial_delay: 1.0,
162
+ max_delay: 32.0,
163
+ multiplier: 1.3,
164
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
165
+ }
166
+
167
+ default_config.rpcs.list_backup_operations.timeout = 3600.0
168
+ default_config.rpcs.list_backup_operations.retry_policy = {
169
+ initial_delay: 1.0,
170
+ max_delay: 32.0,
171
+ multiplier: 1.3,
172
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
173
+ }
174
+
175
+ default_config
176
+ end
177
+ yield @configure if block_given?
178
+ @configure
179
+ end
180
+
181
+ ##
182
+ # Configure the DatabaseAdmin Client instance.
183
+ #
184
+ # The configuration is set to the derived mode, meaning that values can be changed,
185
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
186
+ # should be made on {Client.configure}.
187
+ #
188
+ # See {::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client::Configuration}
189
+ # for a description of the configuration fields.
190
+ #
191
+ # @yield [config] Configure the Client client.
192
+ # @yieldparam config [Client::Configuration]
193
+ #
194
+ # @return [Client::Configuration]
195
+ #
196
+ def configure
197
+ yield @config if block_given?
198
+ @config
199
+ end
200
+
201
+ ##
202
+ # Create a new DatabaseAdmin client object.
203
+ #
204
+ # ## Examples
205
+ #
206
+ # To create a new DatabaseAdmin client with the default
207
+ # configuration:
208
+ #
209
+ # client = ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new
210
+ #
211
+ # To create a new DatabaseAdmin client with a custom
212
+ # configuration:
213
+ #
214
+ # client = ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new do |config|
215
+ # config.timeout = 10.0
216
+ # end
217
+ #
218
+ # @yield [config] Configure the DatabaseAdmin client.
219
+ # @yieldparam config [Client::Configuration]
220
+ #
221
+ def initialize
222
+ # These require statements are intentionally placed here to initialize
223
+ # the gRPC module only when it's required.
224
+ # See https://github.com/googleapis/toolkit/issues/446
225
+ require "gapic/grpc"
226
+ require "google/spanner/admin/database/v1/spanner_database_admin_services_pb"
227
+
228
+ # Create the configuration object
229
+ @config = Configuration.new Client.configure
230
+
231
+ # Yield the configuration if needed
232
+ yield @config if block_given?
233
+
234
+ # Create credentials
235
+ credentials = @config.credentials
236
+ credentials ||= Credentials.default scope: @config.scope
237
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
238
+ credentials = Credentials.new credentials, scope: @config.scope
239
+ end
240
+ @quota_project_id = @config.quota_project
241
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
242
+
243
+ @operations_client = Operations.new do |config|
244
+ config.credentials = credentials
245
+ config.endpoint = @config.endpoint
246
+ end
247
+
248
+ @database_admin_stub = ::Gapic::ServiceStub.new(
249
+ ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Stub,
250
+ credentials: credentials,
251
+ endpoint: @config.endpoint,
252
+ channel_args: @config.channel_args,
253
+ interceptors: @config.interceptors
254
+ )
255
+ end
256
+
257
+ ##
258
+ # Get the associated client for long-running operations.
259
+ #
260
+ # @return [::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Operations]
261
+ #
262
+ attr_reader :operations_client
263
+
264
+ # Service calls
265
+
266
+ ##
267
+ # Lists Cloud Spanner databases.
268
+ #
269
+ # @overload list_databases(request, options = nil)
270
+ # Pass arguments to `list_databases` via a request object, either of type
271
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesRequest} or an equivalent Hash.
272
+ #
273
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesRequest, ::Hash]
274
+ # A request object representing the call parameters. Required. To specify no
275
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
276
+ # @param options [::Gapic::CallOptions, ::Hash]
277
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
278
+ #
279
+ # @overload list_databases(parent: nil, page_size: nil, page_token: nil)
280
+ # Pass arguments to `list_databases` via keyword arguments. Note that at
281
+ # least one keyword argument is required. To specify no parameters, or to keep all
282
+ # the default parameter values, pass an empty Hash as a request object (see above).
283
+ #
284
+ # @param parent [::String]
285
+ # Required. The instance whose databases should be listed.
286
+ # Values are of the form `projects/<project>/instances/<instance>`.
287
+ # @param page_size [::Integer]
288
+ # Number of databases to be returned in the response. If 0 or less,
289
+ # defaults to the server's maximum allowed page size.
290
+ # @param page_token [::String]
291
+ # If non-empty, `page_token` should contain a
292
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesResponse#next_page_token next_page_token} from a
293
+ # previous {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesResponse ListDatabasesResponse}.
294
+ #
295
+ # @yield [response, operation] Access the result along with the RPC operation
296
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Database>]
297
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
298
+ #
299
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Database>]
300
+ #
301
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
302
+ #
303
+ def list_databases request, options = nil
304
+ raise ::ArgumentError, "request must be provided" if request.nil?
305
+
306
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::ListDatabasesRequest
307
+
308
+ # Converts hash and nil to an options object
309
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
310
+
311
+ # Customize the options with defaults
312
+ metadata = @config.rpcs.list_databases.metadata.to_h
313
+
314
+ # Set x-goog-api-client and x-goog-user-project headers
315
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
316
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
317
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
318
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
319
+
320
+ header_params = {
321
+ "parent" => request.parent
322
+ }
323
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
324
+ metadata[:"x-goog-request-params"] ||= request_params_header
325
+
326
+ options.apply_defaults timeout: @config.rpcs.list_databases.timeout,
327
+ metadata: metadata,
328
+ retry_policy: @config.rpcs.list_databases.retry_policy
329
+ options.apply_defaults metadata: @config.metadata,
330
+ retry_policy: @config.retry_policy
331
+
332
+ @database_admin_stub.call_rpc :list_databases, request, options: options do |response, operation|
333
+ response = ::Gapic::PagedEnumerable.new @database_admin_stub, :list_databases, request, response, operation, options
334
+ yield response, operation if block_given?
335
+ return response
336
+ end
337
+ rescue ::GRPC::BadStatus => e
338
+ raise ::Google::Cloud::Error.from_error(e)
339
+ end
340
+
341
+ ##
342
+ # Creates a new Cloud Spanner database and starts to prepare it for serving.
343
+ # The returned {::Google::Longrunning::Operation long-running operation} will
344
+ # have a name of the format `<database_name>/operations/<operation_id>` and
345
+ # can be used to track preparation of the database. The
346
+ # {::Google::Longrunning::Operation#metadata metadata} field type is
347
+ # {::Google::Cloud::Spanner::Admin::Database::V1::CreateDatabaseMetadata CreateDatabaseMetadata}. The
348
+ # {::Google::Longrunning::Operation#response response} field type is
349
+ # {::Google::Cloud::Spanner::Admin::Database::V1::Database Database}, if successful.
350
+ #
351
+ # @overload create_database(request, options = nil)
352
+ # Pass arguments to `create_database` via a request object, either of type
353
+ # {::Google::Cloud::Spanner::Admin::Database::V1::CreateDatabaseRequest} or an equivalent Hash.
354
+ #
355
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::CreateDatabaseRequest, ::Hash]
356
+ # A request object representing the call parameters. Required. To specify no
357
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
358
+ # @param options [::Gapic::CallOptions, ::Hash]
359
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
360
+ #
361
+ # @overload create_database(parent: nil, create_statement: nil, extra_statements: nil)
362
+ # Pass arguments to `create_database` via keyword arguments. Note that at
363
+ # least one keyword argument is required. To specify no parameters, or to keep all
364
+ # the default parameter values, pass an empty Hash as a request object (see above).
365
+ #
366
+ # @param parent [::String]
367
+ # Required. The name of the instance that will serve the new database.
368
+ # Values are of the form `projects/<project>/instances/<instance>`.
369
+ # @param create_statement [::String]
370
+ # Required. A `CREATE DATABASE` statement, which specifies the ID of the
371
+ # new database. The database ID must conform to the regular expression
372
+ # `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length.
373
+ # If the database ID is a reserved word or if it contains a hyphen, the
374
+ # database ID must be enclosed in backticks (`` ` ``).
375
+ # @param extra_statements [::Array<::String>]
376
+ # Optional. A list of DDL statements to run inside the newly created
377
+ # database. Statements can create tables, indexes, etc. These
378
+ # statements execute atomically with the creation of the database:
379
+ # if there is an error in any statement, the database is not created.
380
+ #
381
+ # @yield [response, operation] Access the result along with the RPC operation
382
+ # @yieldparam response [::Gapic::Operation]
383
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
384
+ #
385
+ # @return [::Gapic::Operation]
386
+ #
387
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
388
+ #
389
+ def create_database request, options = nil
390
+ raise ::ArgumentError, "request must be provided" if request.nil?
391
+
392
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::CreateDatabaseRequest
393
+
394
+ # Converts hash and nil to an options object
395
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
396
+
397
+ # Customize the options with defaults
398
+ metadata = @config.rpcs.create_database.metadata.to_h
399
+
400
+ # Set x-goog-api-client and x-goog-user-project headers
401
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
402
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
403
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
404
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
405
+
406
+ header_params = {
407
+ "parent" => request.parent
408
+ }
409
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
410
+ metadata[:"x-goog-request-params"] ||= request_params_header
411
+
412
+ options.apply_defaults timeout: @config.rpcs.create_database.timeout,
413
+ metadata: metadata,
414
+ retry_policy: @config.rpcs.create_database.retry_policy
415
+ options.apply_defaults metadata: @config.metadata,
416
+ retry_policy: @config.retry_policy
417
+
418
+ @database_admin_stub.call_rpc :create_database, request, options: options do |response, operation|
419
+ response = ::Gapic::Operation.new response, @operations_client, options: options
420
+ yield response, operation if block_given?
421
+ return response
422
+ end
423
+ rescue ::GRPC::BadStatus => e
424
+ raise ::Google::Cloud::Error.from_error(e)
425
+ end
426
+
427
+ ##
428
+ # Gets the state of a Cloud Spanner database.
429
+ #
430
+ # @overload get_database(request, options = nil)
431
+ # Pass arguments to `get_database` via a request object, either of type
432
+ # {::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseRequest} or an equivalent Hash.
433
+ #
434
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseRequest, ::Hash]
435
+ # A request object representing the call parameters. Required. To specify no
436
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
437
+ # @param options [::Gapic::CallOptions, ::Hash]
438
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
439
+ #
440
+ # @overload get_database(name: nil)
441
+ # Pass arguments to `get_database` via keyword arguments. Note that at
442
+ # least one keyword argument is required. To specify no parameters, or to keep all
443
+ # the default parameter values, pass an empty Hash as a request object (see above).
444
+ #
445
+ # @param name [::String]
446
+ # Required. The name of the requested database. Values are of the form
447
+ # `projects/<project>/instances/<instance>/databases/<database>`.
448
+ #
449
+ # @yield [response, operation] Access the result along with the RPC operation
450
+ # @yieldparam response [::Google::Cloud::Spanner::Admin::Database::V1::Database]
451
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
452
+ #
453
+ # @return [::Google::Cloud::Spanner::Admin::Database::V1::Database]
454
+ #
455
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
456
+ #
457
+ def get_database request, options = nil
458
+ raise ::ArgumentError, "request must be provided" if request.nil?
459
+
460
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseRequest
461
+
462
+ # Converts hash and nil to an options object
463
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
464
+
465
+ # Customize the options with defaults
466
+ metadata = @config.rpcs.get_database.metadata.to_h
467
+
468
+ # Set x-goog-api-client and x-goog-user-project headers
469
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
470
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
471
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
472
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
473
+
474
+ header_params = {
475
+ "name" => request.name
476
+ }
477
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
478
+ metadata[:"x-goog-request-params"] ||= request_params_header
479
+
480
+ options.apply_defaults timeout: @config.rpcs.get_database.timeout,
481
+ metadata: metadata,
482
+ retry_policy: @config.rpcs.get_database.retry_policy
483
+ options.apply_defaults metadata: @config.metadata,
484
+ retry_policy: @config.retry_policy
485
+
486
+ @database_admin_stub.call_rpc :get_database, request, options: options do |response, operation|
487
+ yield response, operation if block_given?
488
+ return response
489
+ end
490
+ rescue ::GRPC::BadStatus => e
491
+ raise ::Google::Cloud::Error.from_error(e)
492
+ end
493
+
494
+ ##
495
+ # Updates the schema of a Cloud Spanner database by
496
+ # creating/altering/dropping tables, columns, indexes, etc. The returned
497
+ # {::Google::Longrunning::Operation long-running operation} will have a name of
498
+ # the format `<database_name>/operations/<operation_id>` and can be used to
499
+ # track execution of the schema change(s). The
500
+ # {::Google::Longrunning::Operation#metadata metadata} field type is
501
+ # {::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlMetadata UpdateDatabaseDdlMetadata}. The operation has no response.
502
+ #
503
+ # @overload update_database_ddl(request, options = nil)
504
+ # Pass arguments to `update_database_ddl` via a request object, either of type
505
+ # {::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest} or an equivalent Hash.
506
+ #
507
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest, ::Hash]
508
+ # A request object representing the call parameters. Required. To specify no
509
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
510
+ # @param options [::Gapic::CallOptions, ::Hash]
511
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
512
+ #
513
+ # @overload update_database_ddl(database: nil, statements: nil, operation_id: nil)
514
+ # Pass arguments to `update_database_ddl` via keyword arguments. Note that at
515
+ # least one keyword argument is required. To specify no parameters, or to keep all
516
+ # the default parameter values, pass an empty Hash as a request object (see above).
517
+ #
518
+ # @param database [::String]
519
+ # Required. The database to update.
520
+ # @param statements [::Array<::String>]
521
+ # Required. DDL statements to be applied to the database.
522
+ # @param operation_id [::String]
523
+ # If empty, the new update request is assigned an
524
+ # automatically-generated operation ID. Otherwise, `operation_id`
525
+ # is used to construct the name of the resulting
526
+ # {::Google::Longrunning::Operation Operation}.
527
+ #
528
+ # Specifying an explicit operation ID simplifies determining
529
+ # whether the statements were executed in the event that the
530
+ # {::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client#update_database_ddl UpdateDatabaseDdl} call is replayed,
531
+ # or the return value is otherwise lost: the {::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest#database database} and
532
+ # `operation_id` fields can be combined to form the
533
+ # {::Google::Longrunning::Operation#name name} of the resulting
534
+ # {::Google::Longrunning::Operation longrunning.Operation}: `<database>/operations/<operation_id>`.
535
+ #
536
+ # `operation_id` should be unique within the database, and must be
537
+ # a valid identifier: `[a-z][a-z0-9_]*`. Note that
538
+ # automatically-generated operation IDs always begin with an
539
+ # underscore. If the named operation already exists,
540
+ # {::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client#update_database_ddl UpdateDatabaseDdl} returns
541
+ # `ALREADY_EXISTS`.
542
+ #
543
+ # @yield [response, operation] Access the result along with the RPC operation
544
+ # @yieldparam response [::Gapic::Operation]
545
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
546
+ #
547
+ # @return [::Gapic::Operation]
548
+ #
549
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
550
+ #
551
+ def update_database_ddl request, options = nil
552
+ raise ::ArgumentError, "request must be provided" if request.nil?
553
+
554
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest
555
+
556
+ # Converts hash and nil to an options object
557
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
558
+
559
+ # Customize the options with defaults
560
+ metadata = @config.rpcs.update_database_ddl.metadata.to_h
561
+
562
+ # Set x-goog-api-client and x-goog-user-project headers
563
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
564
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
565
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
566
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
567
+
568
+ header_params = {
569
+ "database" => request.database
570
+ }
571
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
572
+ metadata[:"x-goog-request-params"] ||= request_params_header
573
+
574
+ options.apply_defaults timeout: @config.rpcs.update_database_ddl.timeout,
575
+ metadata: metadata,
576
+ retry_policy: @config.rpcs.update_database_ddl.retry_policy
577
+ options.apply_defaults metadata: @config.metadata,
578
+ retry_policy: @config.retry_policy
579
+
580
+ @database_admin_stub.call_rpc :update_database_ddl, request, options: options do |response, operation|
581
+ response = ::Gapic::Operation.new response, @operations_client, options: options
582
+ yield response, operation if block_given?
583
+ return response
584
+ end
585
+ rescue ::GRPC::BadStatus => e
586
+ raise ::Google::Cloud::Error.from_error(e)
587
+ end
588
+
589
+ ##
590
+ # Drops (aka deletes) a Cloud Spanner database.
591
+ # Completed backups for the database will be retained according to their
592
+ # `expire_time`.
593
+ #
594
+ # @overload drop_database(request, options = nil)
595
+ # Pass arguments to `drop_database` via a request object, either of type
596
+ # {::Google::Cloud::Spanner::Admin::Database::V1::DropDatabaseRequest} or an equivalent Hash.
597
+ #
598
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::DropDatabaseRequest, ::Hash]
599
+ # A request object representing the call parameters. Required. To specify no
600
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
601
+ # @param options [::Gapic::CallOptions, ::Hash]
602
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
603
+ #
604
+ # @overload drop_database(database: nil)
605
+ # Pass arguments to `drop_database` via keyword arguments. Note that at
606
+ # least one keyword argument is required. To specify no parameters, or to keep all
607
+ # the default parameter values, pass an empty Hash as a request object (see above).
608
+ #
609
+ # @param database [::String]
610
+ # Required. The database to be dropped.
611
+ #
612
+ # @yield [response, operation] Access the result along with the RPC operation
613
+ # @yieldparam response [::Google::Protobuf::Empty]
614
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
615
+ #
616
+ # @return [::Google::Protobuf::Empty]
617
+ #
618
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
619
+ #
620
+ def drop_database request, options = nil
621
+ raise ::ArgumentError, "request must be provided" if request.nil?
622
+
623
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::DropDatabaseRequest
624
+
625
+ # Converts hash and nil to an options object
626
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
627
+
628
+ # Customize the options with defaults
629
+ metadata = @config.rpcs.drop_database.metadata.to_h
630
+
631
+ # Set x-goog-api-client and x-goog-user-project headers
632
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
633
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
634
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
635
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
636
+
637
+ header_params = {
638
+ "database" => request.database
639
+ }
640
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
641
+ metadata[:"x-goog-request-params"] ||= request_params_header
642
+
643
+ options.apply_defaults timeout: @config.rpcs.drop_database.timeout,
644
+ metadata: metadata,
645
+ retry_policy: @config.rpcs.drop_database.retry_policy
646
+ options.apply_defaults metadata: @config.metadata,
647
+ retry_policy: @config.retry_policy
648
+
649
+ @database_admin_stub.call_rpc :drop_database, request, options: options do |response, operation|
650
+ yield response, operation if block_given?
651
+ return response
652
+ end
653
+ rescue ::GRPC::BadStatus => e
654
+ raise ::Google::Cloud::Error.from_error(e)
655
+ end
656
+
657
+ ##
658
+ # Returns the schema of a Cloud Spanner database as a list of formatted
659
+ # DDL statements. This method does not show pending schema updates, those may
660
+ # be queried using the Operations API.
661
+ #
662
+ # @overload get_database_ddl(request, options = nil)
663
+ # Pass arguments to `get_database_ddl` via a request object, either of type
664
+ # {::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlRequest} or an equivalent Hash.
665
+ #
666
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlRequest, ::Hash]
667
+ # A request object representing the call parameters. Required. To specify no
668
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
669
+ # @param options [::Gapic::CallOptions, ::Hash]
670
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
671
+ #
672
+ # @overload get_database_ddl(database: nil)
673
+ # Pass arguments to `get_database_ddl` via keyword arguments. Note that at
674
+ # least one keyword argument is required. To specify no parameters, or to keep all
675
+ # the default parameter values, pass an empty Hash as a request object (see above).
676
+ #
677
+ # @param database [::String]
678
+ # Required. The database whose schema we wish to get.
679
+ #
680
+ # @yield [response, operation] Access the result along with the RPC operation
681
+ # @yieldparam response [::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlResponse]
682
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
683
+ #
684
+ # @return [::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlResponse]
685
+ #
686
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
687
+ #
688
+ def get_database_ddl request, options = nil
689
+ raise ::ArgumentError, "request must be provided" if request.nil?
690
+
691
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::GetDatabaseDdlRequest
692
+
693
+ # Converts hash and nil to an options object
694
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
695
+
696
+ # Customize the options with defaults
697
+ metadata = @config.rpcs.get_database_ddl.metadata.to_h
698
+
699
+ # Set x-goog-api-client and x-goog-user-project headers
700
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
701
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
702
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
703
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
704
+
705
+ header_params = {
706
+ "database" => request.database
707
+ }
708
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
709
+ metadata[:"x-goog-request-params"] ||= request_params_header
710
+
711
+ options.apply_defaults timeout: @config.rpcs.get_database_ddl.timeout,
712
+ metadata: metadata,
713
+ retry_policy: @config.rpcs.get_database_ddl.retry_policy
714
+ options.apply_defaults metadata: @config.metadata,
715
+ retry_policy: @config.retry_policy
716
+
717
+ @database_admin_stub.call_rpc :get_database_ddl, request, options: options do |response, operation|
718
+ yield response, operation if block_given?
719
+ return response
720
+ end
721
+ rescue ::GRPC::BadStatus => e
722
+ raise ::Google::Cloud::Error.from_error(e)
723
+ end
724
+
725
+ ##
726
+ # Sets the access control policy on a database or backup resource.
727
+ # Replaces any existing policy.
728
+ #
729
+ # Authorization requires `spanner.databases.setIamPolicy`
730
+ # permission on {::Google::Iam::V1::SetIamPolicyRequest#resource resource}.
731
+ # For backups, authorization requires `spanner.backups.setIamPolicy`
732
+ # permission on {::Google::Iam::V1::SetIamPolicyRequest#resource resource}.
733
+ #
734
+ # @overload set_iam_policy(request, options = nil)
735
+ # Pass arguments to `set_iam_policy` via a request object, either of type
736
+ # {::Google::Iam::V1::SetIamPolicyRequest} or an equivalent Hash.
737
+ #
738
+ # @param request [::Google::Iam::V1::SetIamPolicyRequest, ::Hash]
739
+ # A request object representing the call parameters. Required. To specify no
740
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
741
+ # @param options [::Gapic::CallOptions, ::Hash]
742
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
743
+ #
744
+ # @overload set_iam_policy(resource: nil, policy: nil)
745
+ # Pass arguments to `set_iam_policy` via keyword arguments. Note that at
746
+ # least one keyword argument is required. To specify no parameters, or to keep all
747
+ # the default parameter values, pass an empty Hash as a request object (see above).
748
+ #
749
+ # @param resource [::String]
750
+ # REQUIRED: The resource for which the policy is being specified.
751
+ # See the operation documentation for the appropriate value for this field.
752
+ # @param policy [::Google::Iam::V1::Policy, ::Hash]
753
+ # REQUIRED: The complete policy to be applied to the `resource`. The size of
754
+ # the policy is limited to a few 10s of KB. An empty policy is a
755
+ # valid policy but certain Cloud Platform services (such as Projects)
756
+ # might reject them.
757
+ #
758
+ # @yield [response, operation] Access the result along with the RPC operation
759
+ # @yieldparam response [::Google::Iam::V1::Policy]
760
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
761
+ #
762
+ # @return [::Google::Iam::V1::Policy]
763
+ #
764
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
765
+ #
766
+ def set_iam_policy request, options = nil
767
+ raise ::ArgumentError, "request must be provided" if request.nil?
768
+
769
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest
770
+
771
+ # Converts hash and nil to an options object
772
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
773
+
774
+ # Customize the options with defaults
775
+ metadata = @config.rpcs.set_iam_policy.metadata.to_h
776
+
777
+ # Set x-goog-api-client and x-goog-user-project headers
778
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
779
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
780
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
781
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
782
+
783
+ header_params = {
784
+ "resource" => request.resource
785
+ }
786
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
787
+ metadata[:"x-goog-request-params"] ||= request_params_header
788
+
789
+ options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout,
790
+ metadata: metadata,
791
+ retry_policy: @config.rpcs.set_iam_policy.retry_policy
792
+ options.apply_defaults metadata: @config.metadata,
793
+ retry_policy: @config.retry_policy
794
+
795
+ @database_admin_stub.call_rpc :set_iam_policy, request, options: options do |response, operation|
796
+ yield response, operation if block_given?
797
+ return response
798
+ end
799
+ rescue ::GRPC::BadStatus => e
800
+ raise ::Google::Cloud::Error.from_error(e)
801
+ end
802
+
803
+ ##
804
+ # Gets the access control policy for a database or backup resource.
805
+ # Returns an empty policy if a database or backup exists but does not have a
806
+ # policy set.
807
+ #
808
+ # Authorization requires `spanner.databases.getIamPolicy` permission on
809
+ # {::Google::Iam::V1::GetIamPolicyRequest#resource resource}.
810
+ # For backups, authorization requires `spanner.backups.getIamPolicy`
811
+ # permission on {::Google::Iam::V1::GetIamPolicyRequest#resource resource}.
812
+ #
813
+ # @overload get_iam_policy(request, options = nil)
814
+ # Pass arguments to `get_iam_policy` via a request object, either of type
815
+ # {::Google::Iam::V1::GetIamPolicyRequest} or an equivalent Hash.
816
+ #
817
+ # @param request [::Google::Iam::V1::GetIamPolicyRequest, ::Hash]
818
+ # A request object representing the call parameters. Required. To specify no
819
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
820
+ # @param options [::Gapic::CallOptions, ::Hash]
821
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
822
+ #
823
+ # @overload get_iam_policy(resource: nil, options: nil)
824
+ # Pass arguments to `get_iam_policy` via keyword arguments. Note that at
825
+ # least one keyword argument is required. To specify no parameters, or to keep all
826
+ # the default parameter values, pass an empty Hash as a request object (see above).
827
+ #
828
+ # @param resource [::String]
829
+ # REQUIRED: The resource for which the policy is being requested.
830
+ # See the operation documentation for the appropriate value for this field.
831
+ # @param options [::Google::Iam::V1::GetPolicyOptions, ::Hash]
832
+ # OPTIONAL: A `GetPolicyOptions` object for specifying options to
833
+ # `GetIamPolicy`. This field is only used by Cloud IAM.
834
+ #
835
+ # @yield [response, operation] Access the result along with the RPC operation
836
+ # @yieldparam response [::Google::Iam::V1::Policy]
837
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
838
+ #
839
+ # @return [::Google::Iam::V1::Policy]
840
+ #
841
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
842
+ #
843
+ def get_iam_policy request, options = nil
844
+ raise ::ArgumentError, "request must be provided" if request.nil?
845
+
846
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest
847
+
848
+ # Converts hash and nil to an options object
849
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
850
+
851
+ # Customize the options with defaults
852
+ metadata = @config.rpcs.get_iam_policy.metadata.to_h
853
+
854
+ # Set x-goog-api-client and x-goog-user-project headers
855
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
856
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
857
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
858
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
859
+
860
+ header_params = {
861
+ "resource" => request.resource
862
+ }
863
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
864
+ metadata[:"x-goog-request-params"] ||= request_params_header
865
+
866
+ options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout,
867
+ metadata: metadata,
868
+ retry_policy: @config.rpcs.get_iam_policy.retry_policy
869
+ options.apply_defaults metadata: @config.metadata,
870
+ retry_policy: @config.retry_policy
871
+
872
+ @database_admin_stub.call_rpc :get_iam_policy, request, options: options do |response, operation|
873
+ yield response, operation if block_given?
874
+ return response
875
+ end
876
+ rescue ::GRPC::BadStatus => e
877
+ raise ::Google::Cloud::Error.from_error(e)
878
+ end
879
+
880
+ ##
881
+ # Returns permissions that the caller has on the specified database or backup
882
+ # resource.
883
+ #
884
+ # Attempting this RPC on a non-existent Cloud Spanner database will
885
+ # result in a NOT_FOUND error if the user has
886
+ # `spanner.databases.list` permission on the containing Cloud
887
+ # Spanner instance. Otherwise returns an empty set of permissions.
888
+ # Calling this method on a backup that does not exist will
889
+ # result in a NOT_FOUND error if the user has
890
+ # `spanner.backups.list` permission on the containing instance.
891
+ #
892
+ # @overload test_iam_permissions(request, options = nil)
893
+ # Pass arguments to `test_iam_permissions` via a request object, either of type
894
+ # {::Google::Iam::V1::TestIamPermissionsRequest} or an equivalent Hash.
895
+ #
896
+ # @param request [::Google::Iam::V1::TestIamPermissionsRequest, ::Hash]
897
+ # A request object representing the call parameters. Required. To specify no
898
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
899
+ # @param options [::Gapic::CallOptions, ::Hash]
900
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
901
+ #
902
+ # @overload test_iam_permissions(resource: nil, permissions: nil)
903
+ # Pass arguments to `test_iam_permissions` via keyword arguments. Note that at
904
+ # least one keyword argument is required. To specify no parameters, or to keep all
905
+ # the default parameter values, pass an empty Hash as a request object (see above).
906
+ #
907
+ # @param resource [::String]
908
+ # REQUIRED: The resource for which the policy detail is being requested.
909
+ # See the operation documentation for the appropriate value for this field.
910
+ # @param permissions [::Array<::String>]
911
+ # The set of permissions to check for the `resource`. Permissions with
912
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
913
+ # information see
914
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
915
+ #
916
+ # @yield [response, operation] Access the result along with the RPC operation
917
+ # @yieldparam response [::Google::Iam::V1::TestIamPermissionsResponse]
918
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
919
+ #
920
+ # @return [::Google::Iam::V1::TestIamPermissionsResponse]
921
+ #
922
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
923
+ #
924
+ def test_iam_permissions request, options = nil
925
+ raise ::ArgumentError, "request must be provided" if request.nil?
926
+
927
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest
928
+
929
+ # Converts hash and nil to an options object
930
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
931
+
932
+ # Customize the options with defaults
933
+ metadata = @config.rpcs.test_iam_permissions.metadata.to_h
934
+
935
+ # Set x-goog-api-client and x-goog-user-project headers
936
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
937
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
938
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
939
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
940
+
941
+ header_params = {
942
+ "resource" => request.resource
943
+ }
944
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
945
+ metadata[:"x-goog-request-params"] ||= request_params_header
946
+
947
+ options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout,
948
+ metadata: metadata,
949
+ retry_policy: @config.rpcs.test_iam_permissions.retry_policy
950
+ options.apply_defaults metadata: @config.metadata,
951
+ retry_policy: @config.retry_policy
952
+
953
+ @database_admin_stub.call_rpc :test_iam_permissions, request, options: options do |response, operation|
954
+ yield response, operation if block_given?
955
+ return response
956
+ end
957
+ rescue ::GRPC::BadStatus => e
958
+ raise ::Google::Cloud::Error.from_error(e)
959
+ end
960
+
961
+ ##
962
+ # Starts creating a new Cloud Spanner Backup.
963
+ # The returned backup {::Google::Longrunning::Operation long-running operation}
964
+ # will have a name of the format
965
+ # `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>`
966
+ # and can be used to track creation of the backup. The
967
+ # {::Google::Longrunning::Operation#metadata metadata} field type is
968
+ # {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata}. The
969
+ # {::Google::Longrunning::Operation#response response} field type is
970
+ # {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}, if successful. Cancelling the returned operation will stop the
971
+ # creation and delete the backup.
972
+ # There can be only one pending backup creation per database. Backup creation
973
+ # of different databases can run concurrently.
974
+ #
975
+ # @overload create_backup(request, options = nil)
976
+ # Pass arguments to `create_backup` via a request object, either of type
977
+ # {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupRequest} or an equivalent Hash.
978
+ #
979
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupRequest, ::Hash]
980
+ # A request object representing the call parameters. Required. To specify no
981
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
982
+ # @param options [::Gapic::CallOptions, ::Hash]
983
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
984
+ #
985
+ # @overload create_backup(parent: nil, backup_id: nil, backup: nil)
986
+ # Pass arguments to `create_backup` via keyword arguments. Note that at
987
+ # least one keyword argument is required. To specify no parameters, or to keep all
988
+ # the default parameter values, pass an empty Hash as a request object (see above).
989
+ #
990
+ # @param parent [::String]
991
+ # Required. The name of the instance in which the backup will be
992
+ # created. This must be the same instance that contains the database the
993
+ # backup will be created from. The backup will be stored in the
994
+ # location(s) specified in the instance configuration of this
995
+ # instance. Values are of the form
996
+ # `projects/<project>/instances/<instance>`.
997
+ # @param backup_id [::String]
998
+ # Required. The id of the backup to be created. The `backup_id` appended to
999
+ # `parent` forms the full backup name of the form
1000
+ # `projects/<project>/instances/<instance>/backups/<backup_id>`.
1001
+ # @param backup [::Google::Cloud::Spanner::Admin::Database::V1::Backup, ::Hash]
1002
+ # Required. The backup to create.
1003
+ #
1004
+ # @yield [response, operation] Access the result along with the RPC operation
1005
+ # @yieldparam response [::Gapic::Operation]
1006
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1007
+ #
1008
+ # @return [::Gapic::Operation]
1009
+ #
1010
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1011
+ #
1012
+ def create_backup request, options = nil
1013
+ raise ::ArgumentError, "request must be provided" if request.nil?
1014
+
1015
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupRequest
1016
+
1017
+ # Converts hash and nil to an options object
1018
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1019
+
1020
+ # Customize the options with defaults
1021
+ metadata = @config.rpcs.create_backup.metadata.to_h
1022
+
1023
+ # Set x-goog-api-client and x-goog-user-project headers
1024
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1025
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1026
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
1027
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1028
+
1029
+ header_params = {
1030
+ "parent" => request.parent
1031
+ }
1032
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1033
+ metadata[:"x-goog-request-params"] ||= request_params_header
1034
+
1035
+ options.apply_defaults timeout: @config.rpcs.create_backup.timeout,
1036
+ metadata: metadata,
1037
+ retry_policy: @config.rpcs.create_backup.retry_policy
1038
+ options.apply_defaults metadata: @config.metadata,
1039
+ retry_policy: @config.retry_policy
1040
+
1041
+ @database_admin_stub.call_rpc :create_backup, request, options: options do |response, operation|
1042
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1043
+ yield response, operation if block_given?
1044
+ return response
1045
+ end
1046
+ rescue ::GRPC::BadStatus => e
1047
+ raise ::Google::Cloud::Error.from_error(e)
1048
+ end
1049
+
1050
+ ##
1051
+ # Gets metadata on a pending or completed {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}.
1052
+ #
1053
+ # @overload get_backup(request, options = nil)
1054
+ # Pass arguments to `get_backup` via a request object, either of type
1055
+ # {::Google::Cloud::Spanner::Admin::Database::V1::GetBackupRequest} or an equivalent Hash.
1056
+ #
1057
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::GetBackupRequest, ::Hash]
1058
+ # A request object representing the call parameters. Required. To specify no
1059
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1060
+ # @param options [::Gapic::CallOptions, ::Hash]
1061
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1062
+ #
1063
+ # @overload get_backup(name: nil)
1064
+ # Pass arguments to `get_backup` via keyword arguments. Note that at
1065
+ # least one keyword argument is required. To specify no parameters, or to keep all
1066
+ # the default parameter values, pass an empty Hash as a request object (see above).
1067
+ #
1068
+ # @param name [::String]
1069
+ # Required. Name of the backup.
1070
+ # Values are of the form
1071
+ # `projects/<project>/instances/<instance>/backups/<backup>`.
1072
+ #
1073
+ # @yield [response, operation] Access the result along with the RPC operation
1074
+ # @yieldparam response [::Google::Cloud::Spanner::Admin::Database::V1::Backup]
1075
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1076
+ #
1077
+ # @return [::Google::Cloud::Spanner::Admin::Database::V1::Backup]
1078
+ #
1079
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1080
+ #
1081
+ def get_backup request, options = nil
1082
+ raise ::ArgumentError, "request must be provided" if request.nil?
1083
+
1084
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::GetBackupRequest
1085
+
1086
+ # Converts hash and nil to an options object
1087
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1088
+
1089
+ # Customize the options with defaults
1090
+ metadata = @config.rpcs.get_backup.metadata.to_h
1091
+
1092
+ # Set x-goog-api-client and x-goog-user-project headers
1093
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1094
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1095
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
1096
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1097
+
1098
+ header_params = {
1099
+ "name" => request.name
1100
+ }
1101
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1102
+ metadata[:"x-goog-request-params"] ||= request_params_header
1103
+
1104
+ options.apply_defaults timeout: @config.rpcs.get_backup.timeout,
1105
+ metadata: metadata,
1106
+ retry_policy: @config.rpcs.get_backup.retry_policy
1107
+ options.apply_defaults metadata: @config.metadata,
1108
+ retry_policy: @config.retry_policy
1109
+
1110
+ @database_admin_stub.call_rpc :get_backup, request, options: options do |response, operation|
1111
+ yield response, operation if block_given?
1112
+ return response
1113
+ end
1114
+ rescue ::GRPC::BadStatus => e
1115
+ raise ::Google::Cloud::Error.from_error(e)
1116
+ end
1117
+
1118
+ ##
1119
+ # Updates a pending or completed {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}.
1120
+ #
1121
+ # @overload update_backup(request, options = nil)
1122
+ # Pass arguments to `update_backup` via a request object, either of type
1123
+ # {::Google::Cloud::Spanner::Admin::Database::V1::UpdateBackupRequest} or an equivalent Hash.
1124
+ #
1125
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::UpdateBackupRequest, ::Hash]
1126
+ # A request object representing the call parameters. Required. To specify no
1127
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1128
+ # @param options [::Gapic::CallOptions, ::Hash]
1129
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1130
+ #
1131
+ # @overload update_backup(backup: nil, update_mask: nil)
1132
+ # Pass arguments to `update_backup` via keyword arguments. Note that at
1133
+ # least one keyword argument is required. To specify no parameters, or to keep all
1134
+ # the default parameter values, pass an empty Hash as a request object (see above).
1135
+ #
1136
+ # @param backup [::Google::Cloud::Spanner::Admin::Database::V1::Backup, ::Hash]
1137
+ # Required. The backup to update. `backup.name`, and the fields to be updated
1138
+ # as specified by `update_mask` are required. Other fields are ignored.
1139
+ # Update is only supported for the following fields:
1140
+ # * `backup.expire_time`.
1141
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
1142
+ # Required. A mask specifying which fields (e.g. `expire_time`) in the
1143
+ # Backup resource should be updated. This mask is relative to the Backup
1144
+ # resource, not to the request message. The field mask must always be
1145
+ # specified; this prevents any future fields from being erased accidentally
1146
+ # by clients that do not know about them.
1147
+ #
1148
+ # @yield [response, operation] Access the result along with the RPC operation
1149
+ # @yieldparam response [::Google::Cloud::Spanner::Admin::Database::V1::Backup]
1150
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1151
+ #
1152
+ # @return [::Google::Cloud::Spanner::Admin::Database::V1::Backup]
1153
+ #
1154
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1155
+ #
1156
+ def update_backup request, options = nil
1157
+ raise ::ArgumentError, "request must be provided" if request.nil?
1158
+
1159
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::UpdateBackupRequest
1160
+
1161
+ # Converts hash and nil to an options object
1162
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1163
+
1164
+ # Customize the options with defaults
1165
+ metadata = @config.rpcs.update_backup.metadata.to_h
1166
+
1167
+ # Set x-goog-api-client and x-goog-user-project headers
1168
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1169
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1170
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
1171
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1172
+
1173
+ header_params = {
1174
+ "backup.name" => request.backup.name
1175
+ }
1176
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1177
+ metadata[:"x-goog-request-params"] ||= request_params_header
1178
+
1179
+ options.apply_defaults timeout: @config.rpcs.update_backup.timeout,
1180
+ metadata: metadata,
1181
+ retry_policy: @config.rpcs.update_backup.retry_policy
1182
+ options.apply_defaults metadata: @config.metadata,
1183
+ retry_policy: @config.retry_policy
1184
+
1185
+ @database_admin_stub.call_rpc :update_backup, request, options: options do |response, operation|
1186
+ yield response, operation if block_given?
1187
+ return response
1188
+ end
1189
+ rescue ::GRPC::BadStatus => e
1190
+ raise ::Google::Cloud::Error.from_error(e)
1191
+ end
1192
+
1193
+ ##
1194
+ # Deletes a pending or completed {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup}.
1195
+ #
1196
+ # @overload delete_backup(request, options = nil)
1197
+ # Pass arguments to `delete_backup` via a request object, either of type
1198
+ # {::Google::Cloud::Spanner::Admin::Database::V1::DeleteBackupRequest} or an equivalent Hash.
1199
+ #
1200
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::DeleteBackupRequest, ::Hash]
1201
+ # A request object representing the call parameters. Required. To specify no
1202
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1203
+ # @param options [::Gapic::CallOptions, ::Hash]
1204
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1205
+ #
1206
+ # @overload delete_backup(name: nil)
1207
+ # Pass arguments to `delete_backup` via keyword arguments. Note that at
1208
+ # least one keyword argument is required. To specify no parameters, or to keep all
1209
+ # the default parameter values, pass an empty Hash as a request object (see above).
1210
+ #
1211
+ # @param name [::String]
1212
+ # Required. Name of the backup to delete.
1213
+ # Values are of the form
1214
+ # `projects/<project>/instances/<instance>/backups/<backup>`.
1215
+ #
1216
+ # @yield [response, operation] Access the result along with the RPC operation
1217
+ # @yieldparam response [::Google::Protobuf::Empty]
1218
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1219
+ #
1220
+ # @return [::Google::Protobuf::Empty]
1221
+ #
1222
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1223
+ #
1224
+ def delete_backup request, options = nil
1225
+ raise ::ArgumentError, "request must be provided" if request.nil?
1226
+
1227
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::DeleteBackupRequest
1228
+
1229
+ # Converts hash and nil to an options object
1230
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1231
+
1232
+ # Customize the options with defaults
1233
+ metadata = @config.rpcs.delete_backup.metadata.to_h
1234
+
1235
+ # Set x-goog-api-client and x-goog-user-project headers
1236
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1237
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1238
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
1239
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1240
+
1241
+ header_params = {
1242
+ "name" => request.name
1243
+ }
1244
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1245
+ metadata[:"x-goog-request-params"] ||= request_params_header
1246
+
1247
+ options.apply_defaults timeout: @config.rpcs.delete_backup.timeout,
1248
+ metadata: metadata,
1249
+ retry_policy: @config.rpcs.delete_backup.retry_policy
1250
+ options.apply_defaults metadata: @config.metadata,
1251
+ retry_policy: @config.retry_policy
1252
+
1253
+ @database_admin_stub.call_rpc :delete_backup, request, options: options do |response, operation|
1254
+ yield response, operation if block_given?
1255
+ return response
1256
+ end
1257
+ rescue ::GRPC::BadStatus => e
1258
+ raise ::Google::Cloud::Error.from_error(e)
1259
+ end
1260
+
1261
+ ##
1262
+ # Lists completed and pending backups.
1263
+ # Backups returned are ordered by `create_time` in descending order,
1264
+ # starting from the most recent `create_time`.
1265
+ #
1266
+ # @overload list_backups(request, options = nil)
1267
+ # Pass arguments to `list_backups` via a request object, either of type
1268
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupsRequest} or an equivalent Hash.
1269
+ #
1270
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::ListBackupsRequest, ::Hash]
1271
+ # A request object representing the call parameters. Required. To specify no
1272
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1273
+ # @param options [::Gapic::CallOptions, ::Hash]
1274
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1275
+ #
1276
+ # @overload list_backups(parent: nil, filter: nil, page_size: nil, page_token: nil)
1277
+ # Pass arguments to `list_backups` via keyword arguments. Note that at
1278
+ # least one keyword argument is required. To specify no parameters, or to keep all
1279
+ # the default parameter values, pass an empty Hash as a request object (see above).
1280
+ #
1281
+ # @param parent [::String]
1282
+ # Required. The instance to list backups from. Values are of the
1283
+ # form `projects/<project>/instances/<instance>`.
1284
+ # @param filter [::String]
1285
+ # An expression that filters the list of returned backups.
1286
+ #
1287
+ # A filter expression consists of a field name, a comparison operator, and a
1288
+ # value for filtering.
1289
+ # The value must be a string, a number, or a boolean. The comparison operator
1290
+ # must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
1291
+ # Colon `:` is the contains operator. Filter rules are not case sensitive.
1292
+ #
1293
+ # The following fields in the {::Google::Cloud::Spanner::Admin::Database::V1::Backup Backup} are eligible for filtering:
1294
+ #
1295
+ # * `name`
1296
+ # * `database`
1297
+ # * `state`
1298
+ # * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
1299
+ # * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
1300
+ # * `size_bytes`
1301
+ #
1302
+ # You can combine multiple expressions by enclosing each expression in
1303
+ # parentheses. By default, expressions are combined with AND logic, but
1304
+ # you can specify AND, OR, and NOT logic explicitly.
1305
+ #
1306
+ # Here are a few examples:
1307
+ #
1308
+ # * `name:Howl` - The backup's name contains the string "howl".
1309
+ # * `database:prod`
1310
+ # - The database's name contains the string "prod".
1311
+ # * `state:CREATING` - The backup is pending creation.
1312
+ # * `state:READY` - The backup is fully created and ready for use.
1313
+ # * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")`
1314
+ # - The backup name contains the string "howl" and `create_time`
1315
+ # of the backup is before 2018-03-28T14:50:00Z.
1316
+ # * `expire_time < \"2018-03-28T14:50:00Z\"`
1317
+ # - The backup `expire_time` is before 2018-03-28T14:50:00Z.
1318
+ # * `size_bytes > 10000000000` - The backup's size is greater than 10GB
1319
+ # @param page_size [::Integer]
1320
+ # Number of backups to be returned in the response. If 0 or
1321
+ # less, defaults to the server's maximum allowed page size.
1322
+ # @param page_token [::String]
1323
+ # If non-empty, `page_token` should contain a
1324
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupsResponse#next_page_token next_page_token} from a
1325
+ # previous {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupsResponse ListBackupsResponse} to the same `parent` and with the same
1326
+ # `filter`.
1327
+ #
1328
+ # @yield [response, operation] Access the result along with the RPC operation
1329
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Backup>]
1330
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1331
+ #
1332
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Database::V1::Backup>]
1333
+ #
1334
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1335
+ #
1336
+ def list_backups request, options = nil
1337
+ raise ::ArgumentError, "request must be provided" if request.nil?
1338
+
1339
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::ListBackupsRequest
1340
+
1341
+ # Converts hash and nil to an options object
1342
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1343
+
1344
+ # Customize the options with defaults
1345
+ metadata = @config.rpcs.list_backups.metadata.to_h
1346
+
1347
+ # Set x-goog-api-client and x-goog-user-project headers
1348
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1349
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1350
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
1351
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1352
+
1353
+ header_params = {
1354
+ "parent" => request.parent
1355
+ }
1356
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1357
+ metadata[:"x-goog-request-params"] ||= request_params_header
1358
+
1359
+ options.apply_defaults timeout: @config.rpcs.list_backups.timeout,
1360
+ metadata: metadata,
1361
+ retry_policy: @config.rpcs.list_backups.retry_policy
1362
+ options.apply_defaults metadata: @config.metadata,
1363
+ retry_policy: @config.retry_policy
1364
+
1365
+ @database_admin_stub.call_rpc :list_backups, request, options: options do |response, operation|
1366
+ response = ::Gapic::PagedEnumerable.new @database_admin_stub, :list_backups, request, response, operation, options
1367
+ yield response, operation if block_given?
1368
+ return response
1369
+ end
1370
+ rescue ::GRPC::BadStatus => e
1371
+ raise ::Google::Cloud::Error.from_error(e)
1372
+ end
1373
+
1374
+ ##
1375
+ # Create a new database by restoring from a completed backup. The new
1376
+ # database must be in the same project and in an instance with the same
1377
+ # instance configuration as the instance containing
1378
+ # the backup. The returned database [long-running
1379
+ # operation][google.longrunning.Operation] has a name of the format
1380
+ # `projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>`,
1381
+ # and can be used to track the progress of the operation, and to cancel it.
1382
+ # The {::Google::Longrunning::Operation#metadata metadata} field type is
1383
+ # {::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseMetadata RestoreDatabaseMetadata}.
1384
+ # The {::Google::Longrunning::Operation#response response} type
1385
+ # is {::Google::Cloud::Spanner::Admin::Database::V1::Database Database}, if
1386
+ # successful. Cancelling the returned operation will stop the restore and
1387
+ # delete the database.
1388
+ # There can be only one database being restored into an instance at a time.
1389
+ # Once the restore operation completes, a new restore operation can be
1390
+ # initiated, without waiting for the optimize operation associated with the
1391
+ # first restore to complete.
1392
+ #
1393
+ # @overload restore_database(request, options = nil)
1394
+ # Pass arguments to `restore_database` via a request object, either of type
1395
+ # {::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseRequest} or an equivalent Hash.
1396
+ #
1397
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseRequest, ::Hash]
1398
+ # A request object representing the call parameters. Required. To specify no
1399
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1400
+ # @param options [::Gapic::CallOptions, ::Hash]
1401
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1402
+ #
1403
+ # @overload restore_database(parent: nil, database_id: nil, backup: nil)
1404
+ # Pass arguments to `restore_database` via keyword arguments. Note that at
1405
+ # least one keyword argument is required. To specify no parameters, or to keep all
1406
+ # the default parameter values, pass an empty Hash as a request object (see above).
1407
+ #
1408
+ # @param parent [::String]
1409
+ # Required. The name of the instance in which to create the
1410
+ # restored database. This instance must be in the same project and
1411
+ # have the same instance configuration as the instance containing
1412
+ # the source backup. Values are of the form
1413
+ # `projects/<project>/instances/<instance>`.
1414
+ # @param database_id [::String]
1415
+ # Required. The id of the database to create and restore to. This
1416
+ # database must not already exist. The `database_id` appended to
1417
+ # `parent` forms the full database name of the form
1418
+ # `projects/<project>/instances/<instance>/databases/<database_id>`.
1419
+ # @param backup [::String]
1420
+ # Name of the backup from which to restore. Values are of the form
1421
+ # `projects/<project>/instances/<instance>/backups/<backup>`.
1422
+ #
1423
+ # @yield [response, operation] Access the result along with the RPC operation
1424
+ # @yieldparam response [::Gapic::Operation]
1425
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1426
+ #
1427
+ # @return [::Gapic::Operation]
1428
+ #
1429
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1430
+ #
1431
+ def restore_database request, options = nil
1432
+ raise ::ArgumentError, "request must be provided" if request.nil?
1433
+
1434
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseRequest
1435
+
1436
+ # Converts hash and nil to an options object
1437
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1438
+
1439
+ # Customize the options with defaults
1440
+ metadata = @config.rpcs.restore_database.metadata.to_h
1441
+
1442
+ # Set x-goog-api-client and x-goog-user-project headers
1443
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1444
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1445
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
1446
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1447
+
1448
+ header_params = {
1449
+ "parent" => request.parent
1450
+ }
1451
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1452
+ metadata[:"x-goog-request-params"] ||= request_params_header
1453
+
1454
+ options.apply_defaults timeout: @config.rpcs.restore_database.timeout,
1455
+ metadata: metadata,
1456
+ retry_policy: @config.rpcs.restore_database.retry_policy
1457
+ options.apply_defaults metadata: @config.metadata,
1458
+ retry_policy: @config.retry_policy
1459
+
1460
+ @database_admin_stub.call_rpc :restore_database, request, options: options do |response, operation|
1461
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1462
+ yield response, operation if block_given?
1463
+ return response
1464
+ end
1465
+ rescue ::GRPC::BadStatus => e
1466
+ raise ::Google::Cloud::Error.from_error(e)
1467
+ end
1468
+
1469
+ ##
1470
+ # Lists database {::Google::Longrunning::Operation longrunning-operations}.
1471
+ # A database operation has a name of the form
1472
+ # `projects/<project>/instances/<instance>/databases/<database>/operations/<operation>`.
1473
+ # The long-running operation
1474
+ # {::Google::Longrunning::Operation#metadata metadata} field type
1475
+ # `metadata.type_url` describes the type of the metadata. Operations returned
1476
+ # include those that have completed/failed/canceled within the last 7 days,
1477
+ # and pending operations.
1478
+ #
1479
+ # @overload list_database_operations(request, options = nil)
1480
+ # Pass arguments to `list_database_operations` via a request object, either of type
1481
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsRequest} or an equivalent Hash.
1482
+ #
1483
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsRequest, ::Hash]
1484
+ # A request object representing the call parameters. Required. To specify no
1485
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1486
+ # @param options [::Gapic::CallOptions, ::Hash]
1487
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1488
+ #
1489
+ # @overload list_database_operations(parent: nil, filter: nil, page_size: nil, page_token: nil)
1490
+ # Pass arguments to `list_database_operations` via keyword arguments. Note that at
1491
+ # least one keyword argument is required. To specify no parameters, or to keep all
1492
+ # the default parameter values, pass an empty Hash as a request object (see above).
1493
+ #
1494
+ # @param parent [::String]
1495
+ # Required. The instance of the database operations.
1496
+ # Values are of the form `projects/<project>/instances/<instance>`.
1497
+ # @param filter [::String]
1498
+ # An expression that filters the list of returned operations.
1499
+ #
1500
+ # A filter expression consists of a field name, a
1501
+ # comparison operator, and a value for filtering.
1502
+ # The value must be a string, a number, or a boolean. The comparison operator
1503
+ # must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
1504
+ # Colon `:` is the contains operator. Filter rules are not case sensitive.
1505
+ #
1506
+ # The following fields in the {::Google::Longrunning::Operation Operation}
1507
+ # are eligible for filtering:
1508
+ #
1509
+ # * `name` - The name of the long-running operation
1510
+ # * `done` - False if the operation is in progress, else true.
1511
+ # * `metadata.@type` - the type of metadata. For example, the type string
1512
+ # for {::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseMetadata RestoreDatabaseMetadata} is
1513
+ # `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`.
1514
+ # * `metadata.<field_name>` - any field in metadata.value.
1515
+ # * `error` - Error associated with the long-running operation.
1516
+ # * `response.@type` - the type of response.
1517
+ # * `response.<field_name>` - any field in response.value.
1518
+ #
1519
+ # You can combine multiple expressions by enclosing each expression in
1520
+ # parentheses. By default, expressions are combined with AND logic. However,
1521
+ # you can specify AND, OR, and NOT logic explicitly.
1522
+ #
1523
+ # Here are a few examples:
1524
+ #
1525
+ # * `done:true` - The operation is complete.
1526
+ # * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` <br/>
1527
+ # `(metadata.source_type:BACKUP) AND` <br/>
1528
+ # `(metadata.backup_info.backup:backup_howl) AND` <br/>
1529
+ # `(metadata.name:restored_howl) AND` <br/>
1530
+ # `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
1531
+ # `(error:*)` - Return operations where:
1532
+ # * The operation's metadata type is {::Google::Cloud::Spanner::Admin::Database::V1::RestoreDatabaseMetadata RestoreDatabaseMetadata}.
1533
+ # * The database is restored from a backup.
1534
+ # * The backup name contains "backup_howl".
1535
+ # * The restored database's name contains "restored_howl".
1536
+ # * The operation started before 2018-03-28T14:50:00Z.
1537
+ # * The operation resulted in an error.
1538
+ # @param page_size [::Integer]
1539
+ # Number of operations to be returned in the response. If 0 or
1540
+ # less, defaults to the server's maximum allowed page size.
1541
+ # @param page_token [::String]
1542
+ # If non-empty, `page_token` should contain a
1543
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsResponse#next_page_token next_page_token}
1544
+ # from a previous {::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsResponse ListDatabaseOperationsResponse} to the
1545
+ # same `parent` and with the same `filter`.
1546
+ #
1547
+ # @yield [response, operation] Access the result along with the RPC operation
1548
+ # @yieldparam response [::Gapic::PagedEnumerable<::Gapic::Operation>]
1549
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1550
+ #
1551
+ # @return [::Gapic::PagedEnumerable<::Gapic::Operation>]
1552
+ #
1553
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1554
+ #
1555
+ def list_database_operations request, options = nil
1556
+ raise ::ArgumentError, "request must be provided" if request.nil?
1557
+
1558
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::ListDatabaseOperationsRequest
1559
+
1560
+ # Converts hash and nil to an options object
1561
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1562
+
1563
+ # Customize the options with defaults
1564
+ metadata = @config.rpcs.list_database_operations.metadata.to_h
1565
+
1566
+ # Set x-goog-api-client and x-goog-user-project headers
1567
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1568
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1569
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
1570
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1571
+
1572
+ header_params = {
1573
+ "parent" => request.parent
1574
+ }
1575
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1576
+ metadata[:"x-goog-request-params"] ||= request_params_header
1577
+
1578
+ options.apply_defaults timeout: @config.rpcs.list_database_operations.timeout,
1579
+ metadata: metadata,
1580
+ retry_policy: @config.rpcs.list_database_operations.retry_policy
1581
+ options.apply_defaults metadata: @config.metadata,
1582
+ retry_policy: @config.retry_policy
1583
+
1584
+ @database_admin_stub.call_rpc :list_database_operations, request, options: options do |response, operation|
1585
+ wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
1586
+ response = ::Gapic::PagedEnumerable.new @database_admin_stub, :list_database_operations, request, response, operation, options, format_resource: wrap_lro_operation
1587
+ yield response, operation if block_given?
1588
+ return response
1589
+ end
1590
+ rescue ::GRPC::BadStatus => e
1591
+ raise ::Google::Cloud::Error.from_error(e)
1592
+ end
1593
+
1594
+ ##
1595
+ # Lists the backup {::Google::Longrunning::Operation long-running operations} in
1596
+ # the given instance. A backup operation has a name of the form
1597
+ # `projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>`.
1598
+ # The long-running operation
1599
+ # {::Google::Longrunning::Operation#metadata metadata} field type
1600
+ # `metadata.type_url` describes the type of the metadata. Operations returned
1601
+ # include those that have completed/failed/canceled within the last 7 days,
1602
+ # and pending operations. Operations returned are ordered by
1603
+ # `operation.metadata.value.progress.start_time` in descending order starting
1604
+ # from the most recently started operation.
1605
+ #
1606
+ # @overload list_backup_operations(request, options = nil)
1607
+ # Pass arguments to `list_backup_operations` via a request object, either of type
1608
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsRequest} or an equivalent Hash.
1609
+ #
1610
+ # @param request [::Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsRequest, ::Hash]
1611
+ # A request object representing the call parameters. Required. To specify no
1612
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1613
+ # @param options [::Gapic::CallOptions, ::Hash]
1614
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1615
+ #
1616
+ # @overload list_backup_operations(parent: nil, filter: nil, page_size: nil, page_token: nil)
1617
+ # Pass arguments to `list_backup_operations` via keyword arguments. Note that at
1618
+ # least one keyword argument is required. To specify no parameters, or to keep all
1619
+ # the default parameter values, pass an empty Hash as a request object (see above).
1620
+ #
1621
+ # @param parent [::String]
1622
+ # Required. The instance of the backup operations. Values are of
1623
+ # the form `projects/<project>/instances/<instance>`.
1624
+ # @param filter [::String]
1625
+ # An expression that filters the list of returned backup operations.
1626
+ #
1627
+ # A filter expression consists of a field name, a
1628
+ # comparison operator, and a value for filtering.
1629
+ # The value must be a string, a number, or a boolean. The comparison operator
1630
+ # must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
1631
+ # Colon `:` is the contains operator. Filter rules are not case sensitive.
1632
+ #
1633
+ # The following fields in the {::Google::Longrunning::Operation operation}
1634
+ # are eligible for filtering:
1635
+ #
1636
+ # * `name` - The name of the long-running operation
1637
+ # * `done` - False if the operation is in progress, else true.
1638
+ # * `metadata.@type` - the type of metadata. For example, the type string
1639
+ # for {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata} is
1640
+ # `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`.
1641
+ # * `metadata.<field_name>` - any field in metadata.value.
1642
+ # * `error` - Error associated with the long-running operation.
1643
+ # * `response.@type` - the type of response.
1644
+ # * `response.<field_name>` - any field in response.value.
1645
+ #
1646
+ # You can combine multiple expressions by enclosing each expression in
1647
+ # parentheses. By default, expressions are combined with AND logic, but
1648
+ # you can specify AND, OR, and NOT logic explicitly.
1649
+ #
1650
+ # Here are a few examples:
1651
+ #
1652
+ # * `done:true` - The operation is complete.
1653
+ # * `metadata.database:prod` - The database the backup was taken from has
1654
+ # a name containing the string "prod".
1655
+ # * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` <br/>
1656
+ # `(metadata.name:howl) AND` <br/>
1657
+ # `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
1658
+ # `(error:*)` - Returns operations where:
1659
+ # * The operation's metadata type is {::Google::Cloud::Spanner::Admin::Database::V1::CreateBackupMetadata CreateBackupMetadata}.
1660
+ # * The backup name contains the string "howl".
1661
+ # * The operation started before 2018-03-28T14:50:00Z.
1662
+ # * The operation resulted in an error.
1663
+ # @param page_size [::Integer]
1664
+ # Number of operations to be returned in the response. If 0 or
1665
+ # less, defaults to the server's maximum allowed page size.
1666
+ # @param page_token [::String]
1667
+ # If non-empty, `page_token` should contain a
1668
+ # {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsResponse#next_page_token next_page_token}
1669
+ # from a previous {::Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsResponse ListBackupOperationsResponse} to the
1670
+ # same `parent` and with the same `filter`.
1671
+ #
1672
+ # @yield [response, operation] Access the result along with the RPC operation
1673
+ # @yieldparam response [::Gapic::PagedEnumerable<::Gapic::Operation>]
1674
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1675
+ #
1676
+ # @return [::Gapic::PagedEnumerable<::Gapic::Operation>]
1677
+ #
1678
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1679
+ #
1680
+ def list_backup_operations request, options = nil
1681
+ raise ::ArgumentError, "request must be provided" if request.nil?
1682
+
1683
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::Admin::Database::V1::ListBackupOperationsRequest
1684
+
1685
+ # Converts hash and nil to an options object
1686
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1687
+
1688
+ # Customize the options with defaults
1689
+ metadata = @config.rpcs.list_backup_operations.metadata.to_h
1690
+
1691
+ # Set x-goog-api-client and x-goog-user-project headers
1692
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1693
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1694
+ gapic_version: ::Google::Cloud::Spanner::Admin::Database::V1::VERSION
1695
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1696
+
1697
+ header_params = {
1698
+ "parent" => request.parent
1699
+ }
1700
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1701
+ metadata[:"x-goog-request-params"] ||= request_params_header
1702
+
1703
+ options.apply_defaults timeout: @config.rpcs.list_backup_operations.timeout,
1704
+ metadata: metadata,
1705
+ retry_policy: @config.rpcs.list_backup_operations.retry_policy
1706
+ options.apply_defaults metadata: @config.metadata,
1707
+ retry_policy: @config.retry_policy
1708
+
1709
+ @database_admin_stub.call_rpc :list_backup_operations, request, options: options do |response, operation|
1710
+ wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
1711
+ response = ::Gapic::PagedEnumerable.new @database_admin_stub, :list_backup_operations, request, response, operation, options, format_resource: wrap_lro_operation
1712
+ yield response, operation if block_given?
1713
+ return response
1714
+ end
1715
+ rescue ::GRPC::BadStatus => e
1716
+ raise ::Google::Cloud::Error.from_error(e)
1717
+ end
1718
+
1719
+ ##
1720
+ # Configuration class for the DatabaseAdmin API.
1721
+ #
1722
+ # This class represents the configuration for DatabaseAdmin,
1723
+ # providing control over timeouts, retry behavior, logging, transport
1724
+ # parameters, and other low-level controls. Certain parameters can also be
1725
+ # applied individually to specific RPCs. See
1726
+ # {::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client::Configuration::Rpcs}
1727
+ # for a list of RPCs that can be configured independently.
1728
+ #
1729
+ # Configuration can be applied globally to all clients, or to a single client
1730
+ # on construction.
1731
+ #
1732
+ # # Examples
1733
+ #
1734
+ # To modify the global config, setting the timeout for list_databases
1735
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
1736
+ #
1737
+ # ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.configure do |config|
1738
+ # config.timeout = 10.0
1739
+ # config.rpcs.list_databases.timeout = 20.0
1740
+ # end
1741
+ #
1742
+ # To apply the above configuration only to a new client:
1743
+ #
1744
+ # client = ::Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client.new do |config|
1745
+ # config.timeout = 10.0
1746
+ # config.rpcs.list_databases.timeout = 20.0
1747
+ # end
1748
+ #
1749
+ # @!attribute [rw] endpoint
1750
+ # The hostname or hostname:port of the service endpoint.
1751
+ # Defaults to `"spanner.googleapis.com"`.
1752
+ # @return [::String]
1753
+ # @!attribute [rw] credentials
1754
+ # Credentials to send with calls. You may provide any of the following types:
1755
+ # * (`String`) The path to a service account key file in JSON format
1756
+ # * (`Hash`) A service account key as a Hash
1757
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1758
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
1759
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1760
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
1761
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
1762
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
1763
+ # * (`nil`) indicating no credentials
1764
+ # @return [::Object]
1765
+ # @!attribute [rw] scope
1766
+ # The OAuth scopes
1767
+ # @return [::Array<::String>]
1768
+ # @!attribute [rw] lib_name
1769
+ # The library name as recorded in instrumentation and logging
1770
+ # @return [::String]
1771
+ # @!attribute [rw] lib_version
1772
+ # The library version as recorded in instrumentation and logging
1773
+ # @return [::String]
1774
+ # @!attribute [rw] channel_args
1775
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
1776
+ # `GRPC::Core::Channel` object is provided as the credential.
1777
+ # @return [::Hash]
1778
+ # @!attribute [rw] interceptors
1779
+ # An array of interceptors that are run before calls are executed.
1780
+ # @return [::Array<::GRPC::ClientInterceptor>]
1781
+ # @!attribute [rw] timeout
1782
+ # The call timeout in seconds.
1783
+ # @return [::Numeric]
1784
+ # @!attribute [rw] metadata
1785
+ # Additional gRPC headers to be sent with the call.
1786
+ # @return [::Hash{::Symbol=>::String}]
1787
+ # @!attribute [rw] retry_policy
1788
+ # The retry policy. The value is a hash with the following keys:
1789
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1790
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1791
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1792
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1793
+ # trigger a retry.
1794
+ # @return [::Hash]
1795
+ # @!attribute [rw] quota_project
1796
+ # A separate project against which to charge quota.
1797
+ # @return [::String]
1798
+ #
1799
+ class Configuration
1800
+ extend ::Gapic::Config
1801
+
1802
+ config_attr :endpoint, "spanner.googleapis.com", ::String
1803
+ config_attr :credentials, nil do |value|
1804
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1805
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
1806
+ allowed.any? { |klass| klass === value }
1807
+ end
1808
+ config_attr :scope, nil, ::String, ::Array, nil
1809
+ config_attr :lib_name, nil, ::String, nil
1810
+ config_attr :lib_version, nil, ::String, nil
1811
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
1812
+ config_attr :interceptors, nil, ::Array, nil
1813
+ config_attr :timeout, nil, ::Numeric, nil
1814
+ config_attr :metadata, nil, ::Hash, nil
1815
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1816
+ config_attr :quota_project, nil, ::String, nil
1817
+
1818
+ # @private
1819
+ def initialize parent_config = nil
1820
+ @parent_config = parent_config unless parent_config.nil?
1821
+
1822
+ yield self if block_given?
1823
+ end
1824
+
1825
+ ##
1826
+ # Configurations for individual RPCs
1827
+ # @return [Rpcs]
1828
+ #
1829
+ def rpcs
1830
+ @rpcs ||= begin
1831
+ parent_rpcs = nil
1832
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
1833
+ Rpcs.new parent_rpcs
1834
+ end
1835
+ end
1836
+
1837
+ ##
1838
+ # Configuration RPC class for the DatabaseAdmin API.
1839
+ #
1840
+ # Includes fields providing the configuration for each RPC in this service.
1841
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1842
+ # the following configuration fields:
1843
+ #
1844
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
1845
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1846
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1847
+ # include the following keys:
1848
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1849
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1850
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1851
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1852
+ # trigger a retry.
1853
+ #
1854
+ class Rpcs
1855
+ ##
1856
+ # RPC-specific configuration for `list_databases`
1857
+ # @return [::Gapic::Config::Method]
1858
+ #
1859
+ attr_reader :list_databases
1860
+ ##
1861
+ # RPC-specific configuration for `create_database`
1862
+ # @return [::Gapic::Config::Method]
1863
+ #
1864
+ attr_reader :create_database
1865
+ ##
1866
+ # RPC-specific configuration for `get_database`
1867
+ # @return [::Gapic::Config::Method]
1868
+ #
1869
+ attr_reader :get_database
1870
+ ##
1871
+ # RPC-specific configuration for `update_database_ddl`
1872
+ # @return [::Gapic::Config::Method]
1873
+ #
1874
+ attr_reader :update_database_ddl
1875
+ ##
1876
+ # RPC-specific configuration for `drop_database`
1877
+ # @return [::Gapic::Config::Method]
1878
+ #
1879
+ attr_reader :drop_database
1880
+ ##
1881
+ # RPC-specific configuration for `get_database_ddl`
1882
+ # @return [::Gapic::Config::Method]
1883
+ #
1884
+ attr_reader :get_database_ddl
1885
+ ##
1886
+ # RPC-specific configuration for `set_iam_policy`
1887
+ # @return [::Gapic::Config::Method]
1888
+ #
1889
+ attr_reader :set_iam_policy
1890
+ ##
1891
+ # RPC-specific configuration for `get_iam_policy`
1892
+ # @return [::Gapic::Config::Method]
1893
+ #
1894
+ attr_reader :get_iam_policy
1895
+ ##
1896
+ # RPC-specific configuration for `test_iam_permissions`
1897
+ # @return [::Gapic::Config::Method]
1898
+ #
1899
+ attr_reader :test_iam_permissions
1900
+ ##
1901
+ # RPC-specific configuration for `create_backup`
1902
+ # @return [::Gapic::Config::Method]
1903
+ #
1904
+ attr_reader :create_backup
1905
+ ##
1906
+ # RPC-specific configuration for `get_backup`
1907
+ # @return [::Gapic::Config::Method]
1908
+ #
1909
+ attr_reader :get_backup
1910
+ ##
1911
+ # RPC-specific configuration for `update_backup`
1912
+ # @return [::Gapic::Config::Method]
1913
+ #
1914
+ attr_reader :update_backup
1915
+ ##
1916
+ # RPC-specific configuration for `delete_backup`
1917
+ # @return [::Gapic::Config::Method]
1918
+ #
1919
+ attr_reader :delete_backup
1920
+ ##
1921
+ # RPC-specific configuration for `list_backups`
1922
+ # @return [::Gapic::Config::Method]
1923
+ #
1924
+ attr_reader :list_backups
1925
+ ##
1926
+ # RPC-specific configuration for `restore_database`
1927
+ # @return [::Gapic::Config::Method]
1928
+ #
1929
+ attr_reader :restore_database
1930
+ ##
1931
+ # RPC-specific configuration for `list_database_operations`
1932
+ # @return [::Gapic::Config::Method]
1933
+ #
1934
+ attr_reader :list_database_operations
1935
+ ##
1936
+ # RPC-specific configuration for `list_backup_operations`
1937
+ # @return [::Gapic::Config::Method]
1938
+ #
1939
+ attr_reader :list_backup_operations
1940
+
1941
+ # @private
1942
+ def initialize parent_rpcs = nil
1943
+ list_databases_config = parent_rpcs&.list_databases if parent_rpcs&.respond_to? :list_databases
1944
+ @list_databases = ::Gapic::Config::Method.new list_databases_config
1945
+ create_database_config = parent_rpcs&.create_database if parent_rpcs&.respond_to? :create_database
1946
+ @create_database = ::Gapic::Config::Method.new create_database_config
1947
+ get_database_config = parent_rpcs&.get_database if parent_rpcs&.respond_to? :get_database
1948
+ @get_database = ::Gapic::Config::Method.new get_database_config
1949
+ update_database_ddl_config = parent_rpcs&.update_database_ddl if parent_rpcs&.respond_to? :update_database_ddl
1950
+ @update_database_ddl = ::Gapic::Config::Method.new update_database_ddl_config
1951
+ drop_database_config = parent_rpcs&.drop_database if parent_rpcs&.respond_to? :drop_database
1952
+ @drop_database = ::Gapic::Config::Method.new drop_database_config
1953
+ get_database_ddl_config = parent_rpcs&.get_database_ddl if parent_rpcs&.respond_to? :get_database_ddl
1954
+ @get_database_ddl = ::Gapic::Config::Method.new get_database_ddl_config
1955
+ set_iam_policy_config = parent_rpcs&.set_iam_policy if parent_rpcs&.respond_to? :set_iam_policy
1956
+ @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config
1957
+ get_iam_policy_config = parent_rpcs&.get_iam_policy if parent_rpcs&.respond_to? :get_iam_policy
1958
+ @get_iam_policy = ::Gapic::Config::Method.new get_iam_policy_config
1959
+ test_iam_permissions_config = parent_rpcs&.test_iam_permissions if parent_rpcs&.respond_to? :test_iam_permissions
1960
+ @test_iam_permissions = ::Gapic::Config::Method.new test_iam_permissions_config
1961
+ create_backup_config = parent_rpcs&.create_backup if parent_rpcs&.respond_to? :create_backup
1962
+ @create_backup = ::Gapic::Config::Method.new create_backup_config
1963
+ get_backup_config = parent_rpcs&.get_backup if parent_rpcs&.respond_to? :get_backup
1964
+ @get_backup = ::Gapic::Config::Method.new get_backup_config
1965
+ update_backup_config = parent_rpcs&.update_backup if parent_rpcs&.respond_to? :update_backup
1966
+ @update_backup = ::Gapic::Config::Method.new update_backup_config
1967
+ delete_backup_config = parent_rpcs&.delete_backup if parent_rpcs&.respond_to? :delete_backup
1968
+ @delete_backup = ::Gapic::Config::Method.new delete_backup_config
1969
+ list_backups_config = parent_rpcs&.list_backups if parent_rpcs&.respond_to? :list_backups
1970
+ @list_backups = ::Gapic::Config::Method.new list_backups_config
1971
+ restore_database_config = parent_rpcs&.restore_database if parent_rpcs&.respond_to? :restore_database
1972
+ @restore_database = ::Gapic::Config::Method.new restore_database_config
1973
+ list_database_operations_config = parent_rpcs&.list_database_operations if parent_rpcs&.respond_to? :list_database_operations
1974
+ @list_database_operations = ::Gapic::Config::Method.new list_database_operations_config
1975
+ list_backup_operations_config = parent_rpcs&.list_backup_operations if parent_rpcs&.respond_to? :list_backup_operations
1976
+ @list_backup_operations = ::Gapic::Config::Method.new list_backup_operations_config
1977
+
1978
+ yield self if block_given?
1979
+ end
1980
+ end
1981
+ end
1982
+ end
1983
+ end
1984
+ end
1985
+ end
1986
+ end
1987
+ end
1988
+ end
1989
+ end