# ClustersApi

All URIs are relative to *<https://api.ionos.com/databases/postgresql>*

| Method                                                                 | HTTP request                                   | Description              |
| ---------------------------------------------------------------------- | ---------------------------------------------- | ------------------------ |
| [**cluster\_postgres\_versions\_get**](#cluster_postgres_versions_get) | **GET** /clusters/{clusterId}/postgresversions | List PostgreSQL versions |
| [**clusters\_delete**](#clusters_delete)                               | **DELETE** /clusters/{clusterId}               | Delete a cluster         |
| [**clusters\_find\_by\_id**](#clusters_find_by_id)                     | **GET** /clusters/{clusterId}                  | Fetch a cluster          |
| [**clusters\_get**](#clusters_get)                                     | **GET** /clusters                              | List clusters            |
| [**clusters\_patch**](#clusters_patch)                                 | **PATCH** /clusters/{clusterId}                | Patch a cluster          |
| [**clusters\_post**](#clusters_post)                                   | **POST** /clusters                             | Create a cluster         |
| [**postgres\_versions\_get**](#postgres_versions_get)                  | **GET** /clusters/postgresversions             | List PostgreSQL versions |

## cluster\_postgres\_versions\_get

> cluster\_postgres\_versions\_get(cluster\_id)

List PostgreSQL versions

Retrieves a list of all PostgreSQL versions available for this cluster including the current version.

### Examples

```ruby
require 'time'
require 'ionoscloud-dbaas-postgres'
# setup authorization
IonoscloudDbaasPostgres.configure do |config|
  # Configure HTTP basic authorization: basicAuth
  config.username = 'YOUR USERNAME'
  config.password = 'YOUR PASSWORD'

  # Configure API key authorization: tokenAuth
  config.api_key['Authorization'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['Authorization'] = 'Bearer'
end

api_instance = IonoscloudDbaasPostgres::ClustersApi.new
cluster_id = 'cluster_id_example' # String | The unique ID of the cluster.

begin
  # List PostgreSQL versions
  result = api_instance.cluster_postgres_versions_get(cluster_id)
  p result
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->cluster_postgres_versions_get: #{e}"
end
```

#### Using the cluster\_postgres\_versions\_get\_with\_http\_info variant

This returns an Array which contains the response data, status code and headers.

> \<Array(, Integer, Hash)> cluster\_postgres\_versions\_get\_with\_http\_info(cluster\_id)

```ruby
begin
  # List PostgreSQL versions
  data, status_code, headers = api_instance.cluster_postgres_versions_get_with_http_info(cluster_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <PostgresVersionList>
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->cluster_postgres_versions_get_with_http_info: #{e}"
end
```

### Parameters

| Name            | Type       | Description                   | Notes |
| --------------- | ---------- | ----------------------------- | ----- |
| **cluster\_id** | **String** | The unique ID of the cluster. |       |

### Return type

[**PostgresVersionList**](https://docs.ionos.com/sections-test/ruby-sdk/dbaas-postgres-ruby-sdk/models/postgresversionlist)

### Authorization

basicAuth, tokenAuth

### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## clusters\_delete

> clusters\_delete(cluster\_id)

Delete a cluster

Delete a PostgreSQL cluster.

### Examples

```ruby
require 'time'
require 'ionoscloud-dbaas-postgres'
# setup authorization
IonoscloudDbaasPostgres.configure do |config|
  # Configure HTTP basic authorization: basicAuth
  config.username = 'YOUR USERNAME'
  config.password = 'YOUR PASSWORD'

  # Configure API key authorization: tokenAuth
  config.api_key['Authorization'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['Authorization'] = 'Bearer'
end

api_instance = IonoscloudDbaasPostgres::ClustersApi.new
cluster_id = 'cluster_id_example' # String | The unique ID of the cluster.

begin
  # Delete a cluster
  result = api_instance.clusters_delete(cluster_id)
  p result
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->clusters_delete: #{e}"
end
```

#### Using the clusters\_delete\_with\_http\_info variant

This returns an Array which contains the response data, status code and headers.

> \<Array(, Integer, Hash)> clusters\_delete\_with\_http\_info(cluster\_id)

```ruby
begin
  # Delete a cluster
  data, status_code, headers = api_instance.clusters_delete_with_http_info(cluster_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <ClusterResponse>
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->clusters_delete_with_http_info: #{e}"
end
```

### Parameters

| Name            | Type       | Description                   | Notes |
| --------------- | ---------- | ----------------------------- | ----- |
| **cluster\_id** | **String** | The unique ID of the cluster. |       |

### Return type

[**ClusterResponse**](https://docs.ionos.com/sections-test/ruby-sdk/dbaas-postgres-ruby-sdk/models/clusterresponse)

### Authorization

basicAuth, tokenAuth

### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## clusters\_find\_by\_id

> clusters\_find\_by\_id(cluster\_id)

Fetch a cluster

You can retrieve a PostgreSQL cluster by using its ID. This value can be found in the response body when a PostgreSQL cluster is created or when you GET a list of PostgreSQL clusters.

### Examples

```ruby
require 'time'
require 'ionoscloud-dbaas-postgres'
# setup authorization
IonoscloudDbaasPostgres.configure do |config|
  # Configure HTTP basic authorization: basicAuth
  config.username = 'YOUR USERNAME'
  config.password = 'YOUR PASSWORD'

  # Configure API key authorization: tokenAuth
  config.api_key['Authorization'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['Authorization'] = 'Bearer'
end

api_instance = IonoscloudDbaasPostgres::ClustersApi.new
cluster_id = 'cluster_id_example' # String | The unique ID of the cluster.

begin
  # Fetch a cluster
  result = api_instance.clusters_find_by_id(cluster_id)
  p result
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->clusters_find_by_id: #{e}"
end
```

#### Using the clusters\_find\_by\_id\_with\_http\_info variant

This returns an Array which contains the response data, status code and headers.

> \<Array(, Integer, Hash)> clusters\_find\_by\_id\_with\_http\_info(cluster\_id)

```ruby
begin
  # Fetch a cluster
  data, status_code, headers = api_instance.clusters_find_by_id_with_http_info(cluster_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <ClusterResponse>
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->clusters_find_by_id_with_http_info: #{e}"
end
```

### Parameters

| Name            | Type       | Description                   | Notes |
| --------------- | ---------- | ----------------------------- | ----- |
| **cluster\_id** | **String** | The unique ID of the cluster. |       |

### Return type

[**ClusterResponse**](https://docs.ionos.com/sections-test/ruby-sdk/dbaas-postgres-ruby-sdk/models/clusterresponse)

### Authorization

basicAuth, tokenAuth

### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## clusters\_get

> clusters\_get(opts)

List clusters

Retrieves a list of PostgreSQL clusters.

### Examples

```ruby
require 'time'
require 'ionoscloud-dbaas-postgres'
# setup authorization
IonoscloudDbaasPostgres.configure do |config|
  # Configure HTTP basic authorization: basicAuth
  config.username = 'YOUR USERNAME'
  config.password = 'YOUR PASSWORD'

  # Configure API key authorization: tokenAuth
  config.api_key['Authorization'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['Authorization'] = 'Bearer'
end

api_instance = IonoscloudDbaasPostgres::ClustersApi.new
opts = {
  limit: 100, # Integer | The maximum number of elements to return. Use together with 'offset' for pagination.
  offset: 200, # Integer | The first element to return. Use together with 'limit' for pagination.
  filter_name: 'filter_name_example' # String | Response filter to list only the PostgreSQL clusters that contain the specified name. The value is case insensitive and matched on the 'displayName' field. 
}

begin
  # List clusters
  result = api_instance.clusters_get(opts)
  p result
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->clusters_get: #{e}"
end
```

#### Using the clusters\_get\_with\_http\_info variant

This returns an Array which contains the response data, status code and headers.

> \<Array(, Integer, Hash)> clusters\_get\_with\_http\_info(opts)

```ruby
begin
  # List clusters
  data, status_code, headers = api_instance.clusters_get_with_http_info(opts)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <ClusterList>
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->clusters_get_with_http_info: #{e}"
end
```

### Parameters

| Name             | Type        | Description                                                                                                                                                 | Notes                        |
| ---------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| **limit**        | **Integer** | The maximum number of elements to return. Use together with 'offset' for pagination.                                                                        | \[optional]\[default to 100] |
| **offset**       | **Integer** | The first element to return. Use together with 'limit' for pagination.                                                                                      | \[optional]\[default to 0]   |
| **filter\_name** | **String**  | Response filter to list only the PostgreSQL clusters that contain the specified name. The value is case insensitive and matched on the 'displayName' field. | \[optional]                  |

### Return type

[**ClusterList**](https://docs.ionos.com/sections-test/ruby-sdk/dbaas-postgres-ruby-sdk/models/clusterlist)

### Authorization

basicAuth, tokenAuth

### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## clusters\_patch

> clusters\_patch(cluster\_id, patch\_cluster\_request)

Patch a cluster

Patch attributes of a PostgreSQL cluster.

### Examples

```ruby
require 'time'
require 'ionoscloud-dbaas-postgres'
# setup authorization
IonoscloudDbaasPostgres.configure do |config|
  # Configure HTTP basic authorization: basicAuth
  config.username = 'YOUR USERNAME'
  config.password = 'YOUR PASSWORD'

  # Configure API key authorization: tokenAuth
  config.api_key['Authorization'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['Authorization'] = 'Bearer'
end

api_instance = IonoscloudDbaasPostgres::ClustersApi.new
cluster_id = 'cluster_id_example' # String | The unique ID of the cluster.
patch_cluster_request = IonoscloudDbaasPostgres::PatchClusterRequest.new # PatchClusterRequest | Part of the cluster which should be modified.

begin
  # Patch a cluster
  result = api_instance.clusters_patch(cluster_id, patch_cluster_request)
  p result
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->clusters_patch: #{e}"
end
```

#### Using the clusters\_patch\_with\_http\_info variant

This returns an Array which contains the response data, status code and headers.

> \<Array(, Integer, Hash)> clusters\_patch\_with\_http\_info(cluster\_id, patch\_cluster\_request)

```ruby
begin
  # Patch a cluster
  data, status_code, headers = api_instance.clusters_patch_with_http_info(cluster_id, patch_cluster_request)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <ClusterResponse>
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->clusters_patch_with_http_info: #{e}"
end
```

### Parameters

| Name                        | Type                                                                                                                        | Description                                   | Notes |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | ----- |
| **cluster\_id**             | **String**                                                                                                                  | The unique ID of the cluster.                 |       |
| **patch\_cluster\_request** | [**PatchClusterRequest**](https://docs.ionos.com/sections-test/ruby-sdk/dbaas-postgres-ruby-sdk/models/patchclusterrequest) | Part of the cluster which should be modified. |       |

### Return type

[**ClusterResponse**](https://docs.ionos.com/sections-test/ruby-sdk/dbaas-postgres-ruby-sdk/models/clusterresponse)

### Authorization

basicAuth, tokenAuth

### HTTP request headers

* **Content-Type**: application/json
* **Accept**: application/json

## clusters\_post

> clusters\_post(create\_cluster\_request)

Create a cluster

Creates a new PostgreSQL cluster. If the `fromBackup` field is populated, the new cluster will be created based on the given backup.

### Examples

```ruby
require 'time'
require 'ionoscloud-dbaas-postgres'
# setup authorization
IonoscloudDbaasPostgres.configure do |config|
  # Configure HTTP basic authorization: basicAuth
  config.username = 'YOUR USERNAME'
  config.password = 'YOUR PASSWORD'

  # Configure API key authorization: tokenAuth
  config.api_key['Authorization'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['Authorization'] = 'Bearer'
end

api_instance = IonoscloudDbaasPostgres::ClustersApi.new
create_cluster_request = IonoscloudDbaasPostgres::CreateClusterRequest.new # CreateClusterRequest | The cluster to be created.

begin
  # Create a cluster
  result = api_instance.clusters_post(create_cluster_request)
  p result
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->clusters_post: #{e}"
end
```

#### Using the clusters\_post\_with\_http\_info variant

This returns an Array which contains the response data, status code and headers.

> \<Array(, Integer, Hash)> clusters\_post\_with\_http\_info(create\_cluster\_request)

```ruby
begin
  # Create a cluster
  data, status_code, headers = api_instance.clusters_post_with_http_info(create_cluster_request)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <ClusterResponse>
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->clusters_post_with_http_info: #{e}"
end
```

### Parameters

| Name                         | Type                                                                                                                          | Description                | Notes |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------------------------- | ----- |
| **create\_cluster\_request** | [**CreateClusterRequest**](https://docs.ionos.com/sections-test/ruby-sdk/dbaas-postgres-ruby-sdk/models/createclusterrequest) | The cluster to be created. |       |

### Return type

[**ClusterResponse**](https://docs.ionos.com/sections-test/ruby-sdk/dbaas-postgres-ruby-sdk/models/clusterresponse)

### Authorization

basicAuth, tokenAuth

### HTTP request headers

* **Content-Type**: application/json
* **Accept**: application/json

## postgres\_versions\_get

> postgres\_versions\_get

List PostgreSQL versions

Retrieves a list of all available PostgreSQL versions.

### Examples

```ruby
require 'time'
require 'ionoscloud-dbaas-postgres'
# setup authorization
IonoscloudDbaasPostgres.configure do |config|
  # Configure HTTP basic authorization: basicAuth
  config.username = 'YOUR USERNAME'
  config.password = 'YOUR PASSWORD'

  # Configure API key authorization: tokenAuth
  config.api_key['Authorization'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['Authorization'] = 'Bearer'
end

api_instance = IonoscloudDbaasPostgres::ClustersApi.new

begin
  # List PostgreSQL versions
  result = api_instance.postgres_versions_get
  p result
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->postgres_versions_get: #{e}"
end
```

#### Using the postgres\_versions\_get\_with\_http\_info variant

This returns an Array which contains the response data, status code and headers.

> \<Array(, Integer, Hash)> postgres\_versions\_get\_with\_http\_info

```ruby
begin
  # List PostgreSQL versions
  data, status_code, headers = api_instance.postgres_versions_get_with_http_info
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <PostgresVersionList>
rescue IonoscloudDbaasPostgres::ApiError => e
  puts "Error when calling ClustersApi->postgres_versions_get_with_http_info: #{e}"
end
```

### Parameters

This endpoint does not need any parameter.

### Return type

[**PostgresVersionList**](https://docs.ionos.com/sections-test/ruby-sdk/dbaas-postgres-ruby-sdk/models/postgresversionlist)

### Authorization

basicAuth, tokenAuth

### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json
