# DatabasesApi

## DatabasesApi

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

| Method                                     | HTTP request                                              | Description       |
| ------------------------------------------ | --------------------------------------------------------- | ----------------- |
| [**databases\_delete**](#databases_delete) | **DELETE** /clusters/{clusterId}/databases/{databasename} | Delete database   |
| [**databases\_get**](#databases_get)       | **GET** /clusters/{clusterId}/databases/{databasename}    | Get database      |
| [**databases\_list**](#databases_list)     | **GET** /clusters/{clusterId}/databases                   | List databases    |
| [**databases\_post**](#databases_post)     | **POST** /clusters/{clusterId}/databases                  | Create a database |

## **databases\_delete**

> databases\_delete(cluster\_id, databasename)

Delete database

Deletes a single database

#### Example

```python
from __future__ import print_function
import time
import ionoscloud_dbaas_postgres
from ionoscloud_dbaas_postgres.rest import ApiException

# Defining the host is optional and defaults to https://api.ionos.com/databases/postgresql
configuration = ionoscloud_dbaas_postgres.Configuration(
    host = 'https://api.ionos.com/databases/postgresql',
)

# Example of configuring HTTP Basic Authorization
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

with ionoscloud_dbaas_postgres.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ionoscloud_dbaas_postgres.DatabasesApi(api_client)
    cluster_id = '498ae72f-411f-11eb-9d07-046c59cc737e' # str | The unique ID of the cluster.
    databasename = 'benjamindb' # str | The database name.
    try:
        # Delete database
        api_instance.databases_delete(cluster_id, databasename)
    except ApiException as e:
        print('Exception when calling DatabasesApi.databases_delete: %s\n' % e)
```

#### Parameters

| Name             | Type    | Description                   | Notes |
| ---------------- | ------- | ----------------------------- | ----- |
| **cluster\_id**  | **str** | The unique ID of the cluster. |       |
| **databasename** | **str** | The database name.            |       |

#### Return type

void (empty response body)

#### Authorization

basicAuth, tokenAuth

#### HTTP request headers

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

## **databases\_get**

> DatabaseResource databases\_get(cluster\_id, databasename)

Get database

Retrieves a single database

#### Example

```python
from __future__ import print_function
import time
import ionoscloud_dbaas_postgres
from ionoscloud_dbaas_postgres.rest import ApiException

# Defining the host is optional and defaults to https://api.ionos.com/databases/postgresql
configuration = ionoscloud_dbaas_postgres.Configuration(
    host = 'https://api.ionos.com/databases/postgresql',
)

# Example of configuring HTTP Basic Authorization
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

with ionoscloud_dbaas_postgres.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ionoscloud_dbaas_postgres.DatabasesApi(api_client)
    cluster_id = '498ae72f-411f-11eb-9d07-046c59cc737e' # str | The unique ID of the cluster.
    databasename = 'benjamindb' # str | The database name.
    try:
        # Get database
        api_response = api_instance.databases_get(cluster_id, databasename)
        print(api_response)
    except ApiException as e:
        print('Exception when calling DatabasesApi.databases_get: %s\n' % e)
```

#### Parameters

| Name             | Type    | Description                   | Notes |
| ---------------- | ------- | ----------------------------- | ----- |
| **cluster\_id**  | **str** | The unique ID of the cluster. |       |
| **databasename** | **str** | The database name.            |       |

#### Return type

[**DatabaseResource**](https://docs.ionos.com/sections-test/python-sdk/dbaas-postgres-python-sdk/models/databaseresource)

#### Authorization

basicAuth, tokenAuth

#### HTTP request headers

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

## **databases\_list**

> DatabaseList databases\_list(cluster\_id, limit=limit, offset=offset)

List databases

Retrieves a list of databases

#### Example

```python
from __future__ import print_function
import time
import ionoscloud_dbaas_postgres
from ionoscloud_dbaas_postgres.rest import ApiException

# Defining the host is optional and defaults to https://api.ionos.com/databases/postgresql
configuration = ionoscloud_dbaas_postgres.Configuration(
    host = 'https://api.ionos.com/databases/postgresql',
)

# Example of configuring HTTP Basic Authorization
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

with ionoscloud_dbaas_postgres.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ionoscloud_dbaas_postgres.DatabasesApi(api_client)
    cluster_id = '498ae72f-411f-11eb-9d07-046c59cc737e' # str | The unique ID of the cluster.
    try:
        # List databases
        api_response = api_instance.databases_list(cluster_id)
        print(api_response)
    except ApiException as e:
        print('Exception when calling DatabasesApi.databases_list: %s\n' % e)
```

#### Parameters

| Name            | Type    | Description                                                                          | Notes                         |
| --------------- | ------- | ------------------------------------------------------------------------------------ | ----------------------------- |
| **cluster\_id** | **str** | The unique ID of the cluster.                                                        |                               |
| **limit**       | **int** | The maximum number of elements to return. Use together with 'offset' for pagination. | \[optional] \[default to 100] |
| **offset**      | **int** | The first element to return. Use together with 'limit' for pagination.               | \[optional] \[default to 0]   |

#### Return type

[**DatabaseList**](https://docs.ionos.com/sections-test/python-sdk/dbaas-postgres-python-sdk/models/databaselist)

#### Authorization

basicAuth, tokenAuth

#### HTTP request headers

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

## **databases\_post**

> DatabaseResource databases\_post(cluster\_id, database)

Create a database

Create a new database

#### Example

```python
from __future__ import print_function
import time
import ionoscloud_dbaas_postgres
from ionoscloud_dbaas_postgres.rest import ApiException

# Defining the host is optional and defaults to https://api.ionos.com/databases/postgresql
configuration = ionoscloud_dbaas_postgres.Configuration(
    host = 'https://api.ionos.com/databases/postgresql',
)

# Example of configuring HTTP Basic Authorization
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

with ionoscloud_dbaas_postgres.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ionoscloud_dbaas_postgres.DatabasesApi(api_client)
    cluster_id = '498ae72f-411f-11eb-9d07-046c59cc737e' # str | The unique ID of the cluster.
    database = ionoscloud_dbaas_postgres.Database() # Database | a database to create
    try:
        # Create a database
        api_response = api_instance.databases_post(cluster_id, database)
        print(api_response)
    except ApiException as e:
        print('Exception when calling DatabasesApi.databases_post: %s\n' % e)
```

#### Parameters

| Name            | Type                                                                                                      | Description                   | Notes |
| --------------- | --------------------------------------------------------------------------------------------------------- | ----------------------------- | ----- |
| **cluster\_id** | **str**                                                                                                   | The unique ID of the cluster. |       |
| **database**    | [**Database**](https://docs.ionos.com/sections-test/python-sdk/dbaas-postgres-python-sdk/models/database) | a database to create          |       |

#### Return type

[**DatabaseResource**](https://docs.ionos.com/sections-test/python-sdk/dbaas-postgres-python-sdk/models/databaseresource)

#### Authorization

basicAuth, tokenAuth

#### HTTP request headers

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