ibm_cloud_databases 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ [![Build Status](https://travis-ci.com/IBM-Cloud/ibm-cloud-sdk-ruby.svg?token=eW5FVD71iyte6tTby8gr&branch=master)](https://travis.ibm.com/IBM-Cloud/ibm-cloud-sdk-ruby)
2
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
3
+ # IBM Cloud Databases Ruby SDK
4
+
5
+ Ruby client library to interact with various [IBM Cloud IBM Cloud Databases APIs](https://cloud.ibm.com/apidocs?category=ibm-cloud-databases).
6
+
7
+ Disclaimer: this SDK is being released initially as a **pre-release** version.
8
+ Changes might occur which impact applications that use this SDK.
9
+
10
+ ## Table of Contents
11
+
12
+ <!--
13
+ The TOC below is generated using the `markdown-toc` node package.
14
+
15
+ https://github.com/jonschlinkert/markdown-toc
16
+
17
+ You should regenerate the TOC after making changes to this file.
18
+
19
+ npx markdown-toc -i README.md
20
+ -->
21
+
22
+ <!-- toc -->
23
+
24
+ - [Overview](#overview)
25
+ - [Prerequisites](#prerequisites)
26
+ - [Installation](#installation)
27
+ - [Using the SDK](#using-the-sdk)
28
+ - [Questions](#questions)
29
+ - [Issues](#issues)
30
+ - [Open source @ IBM](#open-source--ibm)
31
+ - [Contributing](#contributing)
32
+ - [License](#license)
33
+
34
+ <!-- tocstop -->
35
+
36
+ ## Overview
37
+
38
+ The IBM Cloud IBM Cloud Databases Ruby SDK allows developers to programmatically interact with the following
39
+ IBM Cloud services:
40
+
41
+ Service Name | Imported Class Name
42
+ --- | ---
43
+ [Cloud Databases V5](https://cloud.ibm.com/apidocs/cloud-databases-api/cloud-databases-api-v5) | `IbmCloudDatabases::CloudDatabasesV5`
44
+
45
+ ## Prerequisites
46
+
47
+ [ibm-cloud-onboarding]: https://cloud.ibm.com/registration
48
+
49
+ * An [IBM Cloud][ibm-cloud-onboarding] account.
50
+ * An IAM API key to allow the SDK to access your account. Create one [here](https://cloud.ibm.com/iam/apikeys).
51
+ * Ruby 2.3.0 or above.
52
+
53
+ ## Installation
54
+
55
+ To install, use `gem`
56
+
57
+ ```bash
58
+ gem install "ibm_cloud_databases"
59
+ ```
60
+
61
+ ## Using the SDK
62
+ For general SDK usage information, please see [this link](https://github.com/IBM/ibm-cloud-sdk-common/blob/main/README.md)
63
+
64
+ ## Questions
65
+
66
+ If you are having difficulties using this SDK or have a question about the IBM Cloud services,
67
+ please ask a question
68
+ [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-cloud).
69
+
70
+ ## Issues
71
+ If you encounter an issue with the project, you are welcome to submit a
72
+ [bug report](https://github.com/IBM-Cloud/ibm-cloud-sdk-ruby/issues).
73
+ Before that, please search for similar issues. It's possible that someone has already reported the problem.
74
+
75
+ ## Open source @ IBM
76
+ Find more open source projects on the [IBM Github Page](http://ibm.github.io/)
77
+
78
+ ## Contributing
79
+ See [CONTRIBUTING.md](https://github.com/IBM-Cloud/ibm-cloud-sdk-ruby/blob/master/gems/ibm_cloud_databases/CONTRIBUTING.md).
80
+
81
+ ## License
82
+
83
+ This SDK is released under the Apache 2.0 license.
84
+ The license's full text can be found in [LICENSE](https://github.com/IBM-Cloud/ibm-cloud-sdk-ruby/blob/master/gems/ibm_cloud_databases/LICENSE).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ibm_cloud_databases"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,33 @@
1
+ require_relative 'lib/ibm_cloud_databases/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "ibm_cloud_databases"
5
+ spec.version = IbmCloudDatabases::VERSION
6
+ spec.authors = ["nasar.khan@ibm.com"]
7
+ spec.email = ["nasar.khan@ibm.com"]
8
+
9
+ spec.summary = %q{IBM Cloud Databases Ruby SDK}
10
+ spec.homepage = "https://github.com/IBM-Cloud/ibm-cloud-sdk-ruby"
11
+ spec.licenses = ["Apache-2.0"]
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
+ spec.metadata["changelog_uri"] = "#{spec.metadata["source_code_uri"]}/blob/main/CHANGELOG.md"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
30
+ spec.add_runtime_dependency "http", "~> 4.4.1"
31
+ spec.add_runtime_dependency "ibm_cloud_sdk_core", "~> 1.1.1"
32
+ spec.add_runtime_dependency "jwt", "~> 2.2.1"
33
+ end
@@ -0,0 +1,946 @@
1
+ # frozen_string_literal: true
2
+
3
+ # (C) Copyright IBM Corp. 2021.
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
+ # http://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
+ # IBM OpenAPI SDK Code Generator Version: 3.36.0-6f5b0381-20210716-180747
18
+ #
19
+ # The IBM Cloud Databases API enables interaction between applications and Cloud
20
+ # Databases database deployments.
21
+ #
22
+ # Access to the API requires an IAM Bearer Token or an IAM API Key to be presented through
23
+ # bearer authentication.
24
+ #
25
+ # Deployment IDs are CRNs on the IBM Cloud Databases v5 API platform. No lookup or
26
+ # translation the Compose style UUIDs is needed. The Deployment ID is a traditional UUID
27
+ # on the Compose v5 API platform.
28
+ #
29
+ # When you use CRNs, remember to URL escape the CRN value as they can include the
30
+ # forward-slash (/) character.
31
+
32
+ require "concurrent"
33
+ require "erb"
34
+ require "json"
35
+ require "ibm_cloud_sdk_core"
36
+ require_relative "./common.rb"
37
+
38
+ module IbmCloudDatabases
39
+ ##
40
+ # The Cloud Databases V5 service.
41
+ class CloudDatabasesV5 < IBMCloudSdkCore::BaseService
42
+ include Concurrent::Async
43
+ DEFAULT_SERVICE_NAME = "cloud_databases"
44
+ DEFAULT_SERVICE_URL = "https://api.us-south.databases.cloud.ibm.com/v5/ibm"
45
+ ##
46
+ # @!method initialize(args)
47
+ # Construct a new client for the Cloud Databases service.
48
+ #
49
+ # @param args [Hash] The args to initialize with
50
+ # @option args service_url [String] The base service URL to use when contacting the service.
51
+ # The base service_url may differ between IBM Cloud regions.
52
+ # @option args authenticator [Object] The Authenticator instance to be configured for this service.
53
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
54
+ # any external configuration, if applicable.
55
+ def initialize(args = {})
56
+ @__async_initialized__ = false
57
+ defaults = {}
58
+ defaults[:service_url] = DEFAULT_SERVICE_URL
59
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
60
+ defaults[:authenticator] = nil
61
+ user_service_url = args[:service_url] unless args[:service_url].nil?
62
+ args = defaults.merge(args)
63
+ super
64
+ @service_url = user_service_url unless user_service_url.nil?
65
+ end
66
+
67
+ #########################
68
+ # Deployments
69
+ #########################
70
+
71
+ ##
72
+ # @!method list_deployables
73
+ # List all deployable databases.
74
+ # Returns a list of all the types and associated major versions of database
75
+ # deployments that can be provisioned.
76
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
77
+ def list_deployables
78
+ headers = {
79
+ }
80
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "list_deployables")
81
+ headers.merge!(sdk_headers)
82
+
83
+ method_url = "/deployables"
84
+
85
+ response = request(
86
+ method: "GET",
87
+ url: method_url,
88
+ headers: headers,
89
+ accept_json: true
90
+ )
91
+ response
92
+ end
93
+
94
+ ##
95
+ # @!method list_regions
96
+ # List all deployable regions.
97
+ # Returns a list of all the regions that deployments can be provisioned into from
98
+ # the current region. Used to determine region availability for read-only replicas.
99
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
100
+ def list_regions
101
+ headers = {
102
+ }
103
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "list_regions")
104
+ headers.merge!(sdk_headers)
105
+
106
+ method_url = "/regions"
107
+
108
+ response = request(
109
+ method: "GET",
110
+ url: method_url,
111
+ headers: headers,
112
+ accept_json: true
113
+ )
114
+ response
115
+ end
116
+
117
+ ##
118
+ # @!method get_deployment_info(id:)
119
+ # Get deployment information.
120
+ # Gets the full data that is associated with a deployment. This data includes the
121
+ # ID, name, database type, and version.
122
+ # @param id [String] Deployment ID.
123
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
124
+ def get_deployment_info(id:)
125
+ raise ArgumentError.new("id must be provided") if id.nil?
126
+
127
+ headers = {
128
+ }
129
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "get_deployment_info")
130
+ headers.merge!(sdk_headers)
131
+
132
+ method_url = "/deployments/%s" % [ERB::Util.url_encode(id)]
133
+
134
+ response = request(
135
+ method: "GET",
136
+ url: method_url,
137
+ headers: headers,
138
+ accept_json: true
139
+ )
140
+ response
141
+ end
142
+ #########################
143
+ # Database Users
144
+ #########################
145
+
146
+ ##
147
+ # @!method create_database_user(id:, user_type:, user: nil)
148
+ # Creates a user based on user type.
149
+ # Creates a user in the database that can access the database through a connection.
150
+ # @param id [String] Deployment ID.
151
+ # @param user_type [String] User type.
152
+ # @param user [CreateDatabaseUserRequestUser]
153
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
154
+ def create_database_user(id:, user_type:, user: nil)
155
+ raise ArgumentError.new("id must be provided") if id.nil?
156
+
157
+ raise ArgumentError.new("user_type must be provided") if user_type.nil?
158
+
159
+ headers = {
160
+ }
161
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "create_database_user")
162
+ headers.merge!(sdk_headers)
163
+
164
+ data = {
165
+ "user" => user
166
+ }
167
+
168
+ method_url = "/deployments/%s/users/%s" % [ERB::Util.url_encode(id), ERB::Util.url_encode(user_type)]
169
+
170
+ response = request(
171
+ method: "POST",
172
+ url: method_url,
173
+ headers: headers,
174
+ json: data,
175
+ accept_json: true
176
+ )
177
+ response
178
+ end
179
+
180
+ ##
181
+ # @!method change_user_password(id:, user_type:, username:, user: nil)
182
+ # Set specified user's password.
183
+ # Sets the password of a specified user.
184
+ # @param id [String] Deployment ID.
185
+ # @param user_type [String] User type.
186
+ # @param username [String] User ID.
187
+ # @param user [APasswordSettingUser]
188
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
189
+ def change_user_password(id:, user_type:, username:, user: nil)
190
+ raise ArgumentError.new("id must be provided") if id.nil?
191
+
192
+ raise ArgumentError.new("user_type must be provided") if user_type.nil?
193
+
194
+ raise ArgumentError.new("username must be provided") if username.nil?
195
+
196
+ headers = {
197
+ }
198
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "change_user_password")
199
+ headers.merge!(sdk_headers)
200
+
201
+ data = {
202
+ "user" => user
203
+ }
204
+
205
+ method_url = "/deployments/%s/users/%s/%s" % [ERB::Util.url_encode(id), ERB::Util.url_encode(user_type), ERB::Util.url_encode(username)]
206
+
207
+ response = request(
208
+ method: "PATCH",
209
+ url: method_url,
210
+ headers: headers,
211
+ json: data,
212
+ accept_json: true
213
+ )
214
+ response
215
+ end
216
+
217
+ ##
218
+ # @!method delete_database_user(id:, user_type:, username:)
219
+ # Deletes a user based on user type.
220
+ # Removes a user from the deployment.
221
+ # @param id [String] Deployment ID.
222
+ # @param user_type [String] User type.
223
+ # @param username [String] Username.
224
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
225
+ def delete_database_user(id:, user_type:, username:)
226
+ raise ArgumentError.new("id must be provided") if id.nil?
227
+
228
+ raise ArgumentError.new("user_type must be provided") if user_type.nil?
229
+
230
+ raise ArgumentError.new("username must be provided") if username.nil?
231
+
232
+ headers = {
233
+ }
234
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "delete_database_user")
235
+ headers.merge!(sdk_headers)
236
+
237
+ method_url = "/deployments/%s/users/%s/%s" % [ERB::Util.url_encode(id), ERB::Util.url_encode(user_type), ERB::Util.url_encode(username)]
238
+
239
+ response = request(
240
+ method: "DELETE",
241
+ url: method_url,
242
+ headers: headers,
243
+ accept_json: true
244
+ )
245
+ response
246
+ end
247
+ #########################
248
+ # Database Configuration
249
+ #########################
250
+
251
+ ##
252
+ # @!method update_database_configuration(id:, configuration:)
253
+ # Change your database configuration.
254
+ # Change your database configuration. Available for PostgreSQL, EnterpriseDB, and
255
+ # Redis ONLY.
256
+ # @param id [String] Deployment ID.
257
+ # @param configuration [SetConfigurationConfiguration]
258
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
259
+ def update_database_configuration(id:, configuration:)
260
+ raise ArgumentError.new("id must be provided") if id.nil?
261
+
262
+ raise ArgumentError.new("configuration must be provided") if configuration.nil?
263
+
264
+ headers = {
265
+ }
266
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "update_database_configuration")
267
+ headers.merge!(sdk_headers)
268
+
269
+ data = {
270
+ "configuration" => configuration
271
+ }
272
+
273
+ method_url = "/deployments/%s/configuration" % [ERB::Util.url_encode(id)]
274
+
275
+ response = request(
276
+ method: "PATCH",
277
+ url: method_url,
278
+ headers: headers,
279
+ json: data,
280
+ accept_json: true
281
+ )
282
+ response
283
+ end
284
+ #########################
285
+ # Remotes
286
+ #########################
287
+
288
+ ##
289
+ # @!method list_remotes(id:)
290
+ # List read-only replica information.
291
+ # Get the read-only replicas associated with a deployment. Available for PostgreSQL
292
+ # and EnterpriseDB ONLY.
293
+ # @param id [String] Deployment ID.
294
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
295
+ def list_remotes(id:)
296
+ raise ArgumentError.new("id must be provided") if id.nil?
297
+
298
+ headers = {
299
+ }
300
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "list_remotes")
301
+ headers.merge!(sdk_headers)
302
+
303
+ method_url = "/deployments/%s/remotes" % [ERB::Util.url_encode(id)]
304
+
305
+ response = request(
306
+ method: "GET",
307
+ url: method_url,
308
+ headers: headers,
309
+ accept_json: true
310
+ )
311
+ response
312
+ end
313
+
314
+ ##
315
+ # @!method resync_replica(id:)
316
+ # Resync read-only replica.
317
+ # Reinitialize a read-only replica. Available for PostgreSQL and EnterpriseDB ONLY.
318
+ # @param id [String] Deployment ID of the read-only replica.
319
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
320
+ def resync_replica(id:)
321
+ raise ArgumentError.new("id must be provided") if id.nil?
322
+
323
+ headers = {
324
+ }
325
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "resync_replica")
326
+ headers.merge!(sdk_headers)
327
+
328
+ method_url = "/deployments/%s/remotes/resync" % [ERB::Util.url_encode(id)]
329
+
330
+ response = request(
331
+ method: "POST",
332
+ url: method_url,
333
+ headers: headers,
334
+ accept_json: true
335
+ )
336
+ response
337
+ end
338
+
339
+ ##
340
+ # @!method set_promotion(id:, promotion:)
341
+ # Promote read-only replica to a full deployment.
342
+ # Promote a read-only replica or upgrade and promote a read-only replica. Available
343
+ # for PostgreSQL and EnterpriseDB ONLY.
344
+ # @param id [String] Deployment ID of the read-only replica to promote.
345
+ # @param promotion [SetPromotionPromotion]
346
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
347
+ def set_promotion(id:, promotion:)
348
+ raise ArgumentError.new("id must be provided") if id.nil?
349
+
350
+ raise ArgumentError.new("promotion must be provided") if promotion.nil?
351
+
352
+ headers = {
353
+ }
354
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "set_promotion")
355
+ headers.merge!(sdk_headers)
356
+
357
+ data = {
358
+ "Promotion" => promotion
359
+ }
360
+
361
+ method_url = "/deployments/%s/remotes/promotion" % [ERB::Util.url_encode(id)]
362
+
363
+ response = request(
364
+ method: "POST",
365
+ url: method_url,
366
+ headers: headers,
367
+ json: data,
368
+ accept_json: true
369
+ )
370
+ response
371
+ end
372
+ #########################
373
+ # Tasks
374
+ #########################
375
+
376
+ ##
377
+ # @!method list_deployment_tasks(id:)
378
+ # List currently running tasks on a deployment.
379
+ # Obtain a list of tasks currently running or recently run on a deployment. Tasks
380
+ # are ephemeral. Records of successful tasks are shown for 24-48 hours, and
381
+ # unsuccessful tasks are shown for 7-8 days.
382
+ # @param id [String] Deployment ID.
383
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
384
+ def list_deployment_tasks(id:)
385
+ raise ArgumentError.new("id must be provided") if id.nil?
386
+
387
+ headers = {
388
+ }
389
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "list_deployment_tasks")
390
+ headers.merge!(sdk_headers)
391
+
392
+ method_url = "/deployments/%s/tasks" % [ERB::Util.url_encode(id)]
393
+
394
+ response = request(
395
+ method: "GET",
396
+ url: method_url,
397
+ headers: headers,
398
+ accept_json: true
399
+ )
400
+ response
401
+ end
402
+
403
+ ##
404
+ # @!method get_task(id:)
405
+ # Get information about a task.
406
+ # Get information about a task and its status. Tasks themselves are persistent so
407
+ # old tasks can be consulted as well as running tasks.
408
+ # @param id [String] Task ID.
409
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
410
+ def get_task(id:)
411
+ raise ArgumentError.new("id must be provided") if id.nil?
412
+
413
+ headers = {
414
+ }
415
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "get_task")
416
+ headers.merge!(sdk_headers)
417
+
418
+ method_url = "/tasks/%s" % [ERB::Util.url_encode(id)]
419
+
420
+ response = request(
421
+ method: "GET",
422
+ url: method_url,
423
+ headers: headers,
424
+ accept_json: true
425
+ )
426
+ response
427
+ end
428
+ #########################
429
+ # Backups
430
+ #########################
431
+
432
+ ##
433
+ # @!method get_backup_info(backup_id:)
434
+ # Get information about a backup.
435
+ # Get information about a backup, such as creation date.
436
+ # @param backup_id [String] Backup ID.
437
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
438
+ def get_backup_info(backup_id:)
439
+ raise ArgumentError.new("backup_id must be provided") if backup_id.nil?
440
+
441
+ headers = {
442
+ }
443
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "get_backup_info")
444
+ headers.merge!(sdk_headers)
445
+
446
+ method_url = "/backups/%s" % [ERB::Util.url_encode(backup_id)]
447
+
448
+ response = request(
449
+ method: "GET",
450
+ url: method_url,
451
+ headers: headers,
452
+ accept_json: true
453
+ )
454
+ response
455
+ end
456
+
457
+ ##
458
+ # @!method list_deployment_backups(id:)
459
+ # List currently available backups from a deployment.
460
+ # Get details of all currently available backups from a deployment.
461
+ # @param id [String] Deployment ID.
462
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
463
+ def list_deployment_backups(id:)
464
+ raise ArgumentError.new("id must be provided") if id.nil?
465
+
466
+ headers = {
467
+ }
468
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "list_deployment_backups")
469
+ headers.merge!(sdk_headers)
470
+
471
+ method_url = "/deployments/%s/backups" % [ERB::Util.url_encode(id)]
472
+
473
+ response = request(
474
+ method: "GET",
475
+ url: method_url,
476
+ headers: headers,
477
+ accept_json: true
478
+ )
479
+ response
480
+ end
481
+
482
+ ##
483
+ # @!method start_ondemand_backup(id:)
484
+ # Initiate an on-demand backup.
485
+ # Signal the platform to create an on-demand backup for the specified deployment.
486
+ # The returned task can be polled to track progress of the backup as it takes place.
487
+ # @param id [String] Deployment ID.
488
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
489
+ def start_ondemand_backup(id:)
490
+ raise ArgumentError.new("id must be provided") if id.nil?
491
+
492
+ headers = {
493
+ }
494
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "start_ondemand_backup")
495
+ headers.merge!(sdk_headers)
496
+
497
+ method_url = "/deployments/%s/backups" % [ERB::Util.url_encode(id)]
498
+
499
+ response = request(
500
+ method: "POST",
501
+ url: method_url,
502
+ headers: headers,
503
+ accept_json: true
504
+ )
505
+ response
506
+ end
507
+
508
+ ##
509
+ # @!method get_pit_rdata(id:)
510
+ # Get earliest point-in-time-recovery timestamp.
511
+ # Returns the earliest available time for point-in-time-recovery in ISO8601 UTC
512
+ # format. PostgreSQL and EnterpriseDB only.
513
+ # @param id [String] Deployment ID.
514
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
515
+ def get_pit_rdata(id:)
516
+ raise ArgumentError.new("id must be provided") if id.nil?
517
+
518
+ headers = {
519
+ }
520
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "get_pit_rdata")
521
+ headers.merge!(sdk_headers)
522
+
523
+ method_url = "/deployments/%s/point_in_time_recovery_data" % [ERB::Util.url_encode(id)]
524
+
525
+ response = request(
526
+ method: "GET",
527
+ url: method_url,
528
+ headers: headers,
529
+ accept_json: true
530
+ )
531
+ response
532
+ end
533
+ #########################
534
+ # Connections
535
+ #########################
536
+
537
+ ##
538
+ # @!method get_connection(id:, user_type:, user_id:, endpoint_type:, certificate_root: nil)
539
+ # Discover connection information for a deployment for a user with an endpoint
540
+ # type.
541
+ # Discover connection information for a deployment for a user with an endpoint type.
542
+ # @param id [String] Deployment ID.
543
+ # @param user_type [String] User type.
544
+ # @param user_id [String] User ID.
545
+ # @param endpoint_type [String] Endpoint Type. The endpoint must be enabled on the deployment before its
546
+ # connection information can be fetched.
547
+ # @param certificate_root [String] Optional certificate root path to prepend certificate names. Certificates would be
548
+ # stored in this directory for use by other commands.
549
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
550
+ def get_connection(id:, user_type:, user_id:, endpoint_type:, certificate_root: nil)
551
+ raise ArgumentError.new("id must be provided") if id.nil?
552
+
553
+ raise ArgumentError.new("user_type must be provided") if user_type.nil?
554
+
555
+ raise ArgumentError.new("user_id must be provided") if user_id.nil?
556
+
557
+ raise ArgumentError.new("endpoint_type must be provided") if endpoint_type.nil?
558
+
559
+ headers = {
560
+ }
561
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "get_connection")
562
+ headers.merge!(sdk_headers)
563
+
564
+ params = {
565
+ "certificate_root" => certificate_root
566
+ }
567
+
568
+ method_url = "/deployments/%s/users/%s/%s/connections/%s" % [ERB::Util.url_encode(id), ERB::Util.url_encode(user_type), ERB::Util.url_encode(user_id), ERB::Util.url_encode(endpoint_type)]
569
+
570
+ response = request(
571
+ method: "GET",
572
+ url: method_url,
573
+ headers: headers,
574
+ params: params,
575
+ accept_json: true
576
+ )
577
+ response
578
+ end
579
+
580
+ ##
581
+ # @!method complete_connection(id:, user_type:, user_id:, endpoint_type:, password: nil, certificate_root: nil)
582
+ # Discover connection information for a deployment for a user with substitutions
583
+ # and an endpoint type.
584
+ # Discover connection information for a deployment for a user. Behaves the same as
585
+ # the GET method but substitutes the provided password parameter into the returned
586
+ # connection information.
587
+ # @param id [String] Deployment ID.
588
+ # @param user_type [String] User type of `database` is the only currently supported value.
589
+ # @param user_id [String] User ID.
590
+ # @param endpoint_type [String] Endpoint Type. The select endpoint must be enabled on the deployment before its
591
+ # connection information can be fetched.
592
+ # @param password [String] Password to be substituted into the response.
593
+ # @param certificate_root [String] Optional certificate root path to prepend certificate names. Certificates would be
594
+ # stored in this directory for use by other commands.
595
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
596
+ def complete_connection(id:, user_type:, user_id:, endpoint_type:, password: nil, certificate_root: nil)
597
+ raise ArgumentError.new("id must be provided") if id.nil?
598
+
599
+ raise ArgumentError.new("user_type must be provided") if user_type.nil?
600
+
601
+ raise ArgumentError.new("user_id must be provided") if user_id.nil?
602
+
603
+ raise ArgumentError.new("endpoint_type must be provided") if endpoint_type.nil?
604
+
605
+ headers = {
606
+ }
607
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "complete_connection")
608
+ headers.merge!(sdk_headers)
609
+
610
+ data = {
611
+ "password" => password,
612
+ "certificate_root" => certificate_root
613
+ }
614
+
615
+ method_url = "/deployments/%s/users/%s/%s/connections/%s" % [ERB::Util.url_encode(id), ERB::Util.url_encode(user_type), ERB::Util.url_encode(user_id), ERB::Util.url_encode(endpoint_type)]
616
+
617
+ response = request(
618
+ method: "POST",
619
+ url: method_url,
620
+ headers: headers,
621
+ json: data,
622
+ accept_json: true
623
+ )
624
+ response
625
+ end
626
+ #########################
627
+ # Scaling
628
+ #########################
629
+
630
+ ##
631
+ # @!method list_deployment_scaling_groups(id:)
632
+ # List currently available scaling groups from a deployment.
633
+ # Scaling groups represent the various resources that are allocated to a deployment.
634
+ # This command allows for the retrieval of all of the groups for a particular
635
+ # deployment.
636
+ # @param id [String] Deployment ID.
637
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
638
+ def list_deployment_scaling_groups(id:)
639
+ raise ArgumentError.new("id must be provided") if id.nil?
640
+
641
+ headers = {
642
+ }
643
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "list_deployment_scaling_groups")
644
+ headers.merge!(sdk_headers)
645
+
646
+ method_url = "/deployments/%s/groups" % [ERB::Util.url_encode(id)]
647
+
648
+ response = request(
649
+ method: "GET",
650
+ url: method_url,
651
+ headers: headers,
652
+ accept_json: true
653
+ )
654
+ response
655
+ end
656
+
657
+ ##
658
+ # @!method get_default_scaling_groups(type:)
659
+ # Get default scaling groups for a new deployment.
660
+ # Scaling groups represent the various resources allocated to a deployment. When a
661
+ # new deployment is created, there are a set of defaults for each database type.
662
+ # This endpoint returns them for a particular database.
663
+ # @param type [String] Database type name.
664
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
665
+ def get_default_scaling_groups(type:)
666
+ raise ArgumentError.new("type must be provided") if type.nil?
667
+
668
+ headers = {
669
+ }
670
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "get_default_scaling_groups")
671
+ headers.merge!(sdk_headers)
672
+
673
+ method_url = "/deployables/%s/groups" % [ERB::Util.url_encode(type)]
674
+
675
+ response = request(
676
+ method: "GET",
677
+ url: method_url,
678
+ headers: headers,
679
+ accept_json: true
680
+ )
681
+ response
682
+ end
683
+
684
+ ##
685
+ # @!method set_deployment_scaling_group(id:, group_id:, set_deployment_scaling_group_request:)
686
+ # Set scaling values on a specified group.
687
+ # Set scaling value on a specified group. Can only be performed on
688
+ # is_adjustable=true groups. Values set are for the group as a whole and resources
689
+ # are distributed amongst the group. Values must be greater than or equal to the
690
+ # minimum size and must be a multiple of the step size.
691
+ # @param id [String] Deployment ID.
692
+ # @param group_id [String] Group Id.
693
+ # @param set_deployment_scaling_group_request [SetDeploymentScalingGroupRequest] Scaling group settings.
694
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
695
+ def set_deployment_scaling_group(id:, group_id:, set_deployment_scaling_group_request:)
696
+ raise ArgumentError.new("id must be provided") if id.nil?
697
+
698
+ raise ArgumentError.new("group_id must be provided") if group_id.nil?
699
+
700
+ raise ArgumentError.new("set_deployment_scaling_group_request must be provided") if set_deployment_scaling_group_request.nil?
701
+
702
+ headers = {
703
+ }
704
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "set_deployment_scaling_group")
705
+ headers.merge!(sdk_headers)
706
+
707
+ data = set_deployment_scaling_group_request
708
+ headers["Content-Type"] = "application/json"
709
+
710
+ method_url = "/deployments/%s/groups/%s" % [ERB::Util.url_encode(id), ERB::Util.url_encode(group_id)]
711
+
712
+ response = request(
713
+ method: "PATCH",
714
+ url: method_url,
715
+ headers: headers,
716
+ data: data,
717
+ accept_json: true
718
+ )
719
+ response
720
+ end
721
+ #########################
722
+ # Autoscaling
723
+ #########################
724
+
725
+ ##
726
+ # @!method get_autoscaling_conditions(id:, group_id:)
727
+ # Get the autoscaling configuration from a deployment.
728
+ # The Autoscaling configuration represents the various conditions that control
729
+ # autoscaling for a deployment. This command allows for the retrieval of all
730
+ # autoscaling conditions for a particular deployment.
731
+ # @param id [String] Deployment ID.
732
+ # @param group_id [String] Group ID.
733
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
734
+ def get_autoscaling_conditions(id:, group_id:)
735
+ raise ArgumentError.new("id must be provided") if id.nil?
736
+
737
+ raise ArgumentError.new("group_id must be provided") if group_id.nil?
738
+
739
+ headers = {
740
+ }
741
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "get_autoscaling_conditions")
742
+ headers.merge!(sdk_headers)
743
+
744
+ method_url = "/deployments/%s/groups/%s/autoscaling" % [ERB::Util.url_encode(id), ERB::Util.url_encode(group_id)]
745
+
746
+ response = request(
747
+ method: "GET",
748
+ url: method_url,
749
+ headers: headers,
750
+ accept_json: true
751
+ )
752
+ response
753
+ end
754
+
755
+ ##
756
+ # @!method set_autoscaling_conditions(id:, group_id:, autoscaling:)
757
+ # Set the autoscaling configuration from a deployment.
758
+ # Enable, disable, or set the conditions for autoscaling on your deployment. Memory,
759
+ # disk, and CPU (if available) can be set separately and are not all required.
760
+ # @param id [String] Deployment ID.
761
+ # @param group_id [String] Group ID.
762
+ # @param autoscaling [AutoscalingSetGroupAutoscaling]
763
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
764
+ def set_autoscaling_conditions(id:, group_id:, autoscaling:)
765
+ raise ArgumentError.new("id must be provided") if id.nil?
766
+
767
+ raise ArgumentError.new("group_id must be provided") if group_id.nil?
768
+
769
+ raise ArgumentError.new("autoscaling must be provided") if autoscaling.nil?
770
+
771
+ headers = {
772
+ }
773
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "set_autoscaling_conditions")
774
+ headers.merge!(sdk_headers)
775
+
776
+ data = {
777
+ "autoscaling" => autoscaling
778
+ }
779
+
780
+ method_url = "/deployments/%s/groups/%s/autoscaling" % [ERB::Util.url_encode(id), ERB::Util.url_encode(group_id)]
781
+
782
+ response = request(
783
+ method: "PATCH",
784
+ url: method_url,
785
+ headers: headers,
786
+ json: data,
787
+ accept_json: true
788
+ )
789
+ response
790
+ end
791
+ #########################
792
+ # Management
793
+ #########################
794
+
795
+ ##
796
+ # @!method kill_connections(id:)
797
+ # Kill connections to a PostgreSQL or EnterpriseDB deployment.
798
+ # Closes all the connections on a deployment. Available for PostgreSQL and
799
+ # EnterpriseDB ONLY.
800
+ # @param id [String] Deployment ID.
801
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
802
+ def kill_connections(id:)
803
+ raise ArgumentError.new("id must be provided") if id.nil?
804
+
805
+ headers = {
806
+ }
807
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "kill_connections")
808
+ headers.merge!(sdk_headers)
809
+
810
+ method_url = "/deployments/%s/management/database_connections" % [ERB::Util.url_encode(id)]
811
+
812
+ response = request(
813
+ method: "DELETE",
814
+ url: method_url,
815
+ headers: headers,
816
+ accept_json: true
817
+ )
818
+ response
819
+ end
820
+ #########################
821
+ # Security
822
+ #########################
823
+
824
+ ##
825
+ # @!method get_allowlist(id:)
826
+ # Retrieve the allowlisted addresses and ranges for a deployment.
827
+ # Retrieve the allowlisted addresses and ranges for a deployment.
828
+ # @param id [String] Deployment ID.
829
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
830
+ def get_allowlist(id:)
831
+ raise ArgumentError.new("id must be provided") if id.nil?
832
+
833
+ headers = {
834
+ }
835
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "get_allowlist")
836
+ headers.merge!(sdk_headers)
837
+
838
+ method_url = "/deployments/%s/whitelists/ip_addresses" % [ERB::Util.url_encode(id)]
839
+
840
+ response = request(
841
+ method: "GET",
842
+ url: method_url,
843
+ headers: headers,
844
+ accept_json: true
845
+ )
846
+ response
847
+ end
848
+
849
+ ##
850
+ # @!method set_allowlist(id:, ip_addresses: nil, if_match: nil)
851
+ # Set the allowlist for a deployment.
852
+ # Set the allowlist for a deployment. This action overwrites all existing entries,
853
+ # so when you modify the allowlist via a GET/update/PUT, provide the GET response's
854
+ # ETag header value in this endpoint's If-Match header to ensure that changes that
855
+ # are made by other clients are not accidentally overwritten.
856
+ # @param id [String] Deployment ID.
857
+ # @param ip_addresses [Array[AllowlistEntry]] An array of allowlist entries.
858
+ # @param if_match [String] Verify that the current allowlist matches a provided ETag value. Use in
859
+ # conjunction with the GET operation's ETag header to ensure synchronicity between
860
+ # clients.
861
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
862
+ def set_allowlist(id:, ip_addresses: nil, if_match: nil)
863
+ raise ArgumentError.new("id must be provided") if id.nil?
864
+
865
+ headers = {
866
+ "If-Match" => if_match
867
+ }
868
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "set_allowlist")
869
+ headers.merge!(sdk_headers)
870
+
871
+ data = {
872
+ "ip_addresses" => ip_addresses
873
+ }
874
+
875
+ method_url = "/deployments/%s/whitelists/ip_addresses" % [ERB::Util.url_encode(id)]
876
+
877
+ response = request(
878
+ method: "PUT",
879
+ url: method_url,
880
+ headers: headers,
881
+ json: data,
882
+ accept_json: true
883
+ )
884
+ response
885
+ end
886
+
887
+ ##
888
+ # @!method add_allowlist_entry(id:, ip_address: nil)
889
+ # Add an address or range to the allowlist for a deployment.
890
+ # Add an address or range to the allowlist for a deployment.
891
+ # @param id [String] Deployment ID.
892
+ # @param ip_address [AllowlistEntry]
893
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
894
+ def add_allowlist_entry(id:, ip_address: nil)
895
+ raise ArgumentError.new("id must be provided") if id.nil?
896
+
897
+ headers = {
898
+ }
899
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "add_allowlist_entry")
900
+ headers.merge!(sdk_headers)
901
+
902
+ data = {
903
+ "ip_address" => ip_address
904
+ }
905
+
906
+ method_url = "/deployments/%s/whitelists/ip_addresses" % [ERB::Util.url_encode(id)]
907
+
908
+ response = request(
909
+ method: "POST",
910
+ url: method_url,
911
+ headers: headers,
912
+ json: data,
913
+ accept_json: true
914
+ )
915
+ response
916
+ end
917
+
918
+ ##
919
+ # @!method delete_allowlist_entry(id:, ipaddress:)
920
+ # Delete an address or range from the allowlist of a deployment.
921
+ # Delete an address or range from the allowlist of a deployment.
922
+ # @param id [String] Deployment ID.
923
+ # @param ipaddress [String] An IPv4 address or a CIDR range (netmasked IPv4 address).
924
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
925
+ def delete_allowlist_entry(id:, ipaddress:)
926
+ raise ArgumentError.new("id must be provided") if id.nil?
927
+
928
+ raise ArgumentError.new("ipaddress must be provided") if ipaddress.nil?
929
+
930
+ headers = {
931
+ }
932
+ sdk_headers = Common.new.get_sdk_headers("cloud_databases", "V5", "delete_allowlist_entry")
933
+ headers.merge!(sdk_headers)
934
+
935
+ method_url = "/deployments/%s/whitelists/ip_addresses/%s" % [ERB::Util.url_encode(id), ERB::Util.url_encode(ipaddress)]
936
+
937
+ response = request(
938
+ method: "DELETE",
939
+ url: method_url,
940
+ headers: headers,
941
+ accept_json: true
942
+ )
943
+ response
944
+ end
945
+ end
946
+ end