Introduction

Overview

An enterprise-grade Database is provided as a Service (DBaaS) solution that can be managed through a browser-based "Data Center Designer" (DCD) tool or via an easy to use API.
The API allows you to create additional database clusters or modify existing ones. It is designed to allow users to leverage the same power and flexibility found within the DCD visual tool. Both tools are consistent with their concepts and lend well to making the experience smooth and intuitive.

Getting Started

Instalation

1. Build a gem

To build the Ruby code into a gem:
1
gem build ionoscloud-dbaas-postgres.gemspec
Copied!
Then either install the gem locally:
1
gem install ./ionoscloud-dbaas-postgres-<gem-version>.gem
Copied!
(for development, run gem install --dev ./ionoscloud-dbaas-postgres-<gem-version>.gem to install the development dependencies)
or publish the gem to a gem hosting service, e.g. RubyGems.
Finally add this to the Gemfile:
1
gem 'ionoscloud-dbaas-postgres', '~> <gem-version>'
Copied!

2. Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/ionos-cloud/sdk-ruby-dbaas-postgres, then add the following in the Gemfile:
1
gem 'ionoscloud-dbaas-postgres', :git => 'https://github.com/ionos-cloud/sdk-ruby-dbaas-postgres.git'
Copied!

3. Include the Ruby code directly

Include the Ruby code directly using -I as follows:
1
ruby -Ilib script.rb
Copied!

4. Install from RubyGems

Just add this to the Gemfile:
1
gem 'ionoscloud-dbaas-postgres', '~> <gem-version>'
Copied!

After installing please run the following code:

1
# Load the gem
2
require 'ionoscloud-dbaas-postgres'
3
4
# Setup authorization
5
IonoscloudDbaasPostgres.configure do |config|
6
# Configure HTTP basic authorization: Basic Authentication
7
config.username = 'YOUR_USERNAME'
8
config.password = 'YOUR_PASSWORD'
9
10
# Configure API key authorization: Token Authentication
11
config.api_key['Authorization'] = 'YOUR API KEY'
12
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
13
#config.api_key_prefix['Authorization'] = 'Bearer'
14
end
15
16
api_instance = IonoscloudDbaasPostgres::DefaultApi.new
17
opts = {
18
pretty: true, # Boolean | Controls whether response is pretty-printed (with indentation and new lines)
19
depth: 56, # Integer | Controls the details depth of response objects. Eg. GET /datacenters/[ID] - depth=0: only direct properties are included. Children (servers etc.) are not included - depth=1: direct properties and children references are included - depth=2: direct properties and children properties are included - depth=3: direct properties and children properties and children's children are included - depth=... and so on
20
x_contract_number: 56 # Integer | Users having more than 1 contract need to provide contract number, against which all API requests should be executed
21
}
22
23
begin
24
#Display API information
25
result = api_instance.api_info_get(opts)
26
p result
27
rescue IonoscloudDbaasPostgres::ApiError => e
28
puts "Exception when calling DefaultApi->api_info_get: #{e}"
29
end
Copied!

Authentication

The username and password or the authentication token can be manually specified when initializing the SDK client:
1
IonoscloudDbaasPostgres.configure do |config|
2
# Configure HTTP basic authorization: Basic Authentication
3
config.username = 'YOUR_USERNAME'
4
config.password = 'YOUR_PASSWORD'
5
6
# Configure API key authorization: Token Authentication
7
config.api_key['Authorization'] = 'YOUR API KEY'
8
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
9
#config.api_key_prefix['Authorization'] = 'Bearer'
10
end
Copied!
Environment variables can also be used for initialization. For example:
1
IonoscloudDbaasPostgres.configure do |config|
2
config.username = ENV['IONOS_USERNAME']
3
config.password = ENV['IONOS_PASSWORD']
4
config.api_key['Authorization'] = ENV['IONOS_TOKEN']
5
end
Copied!
Warning: Make sure to follow the Information Security Best Practices when using credentials within your code or storing them in a file.

Changing the base URL

Base URL for the HTTP operation can be changed in the following way:
1
IonoscloudDbaasPostgres.configure do |config|
2
config.username = ENV['IONOS_USERNAME']
3
config.password = ENV['IONOS_PASSWORD']
4
5
# Configure the url used by the SDK
6
config.host = 'https://api.ionos.com/databases/postgresql'
7
# This must be set as well because of the way the API works, otherwise the set url will not be used
8
condif.server_index = nil
9
end
Copied!

Feature Reference

The IONOS Cloud SDK for Ruby aims to offer access to all resources in the IONOS Cloud API and also offers some additional features that make the integration easier:
  • authentication for API calls
  • handling of asynchronous requests

FAQ

  1. 1.
    How can I open a bug/feature request?
Bugs & feature requests can be open on the repository issues: https://github.com/ionos-cloud/sdk-ruby-dbaas-postgres/issues/new/choose
  1. 1.
    Can I contribute to the Ruby SDK?
Pure SDKs are automatically generated using OpenAPI Generator and don’t support manual changes. If you need changes please open an issue and we’ll try to take care of it.
Last modified 4mo ago