# UsersApi

## UsersApi

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

| Method                             | HTTP request                                      | Description   |
| ---------------------------------- | ------------------------------------------------- | ------------- |
| [**users\_delete**](#users_delete) | **DELETE** /clusters/{clusterId}/users/{username} | Delete user   |
| [**users\_get**](#users_get)       | **GET** /clusters/{clusterId}/users/{username}    | Get user      |
| [**users\_list**](#users_list)     | **GET** /clusters/{clusterId}/users               | List users    |
| [**users\_patch**](#users_patch)   | **PATCH** /clusters/{clusterId}/users/{username}  | Patch user    |
| [**users\_post**](#users_post)     | **POST** /clusters/{clusterId}/users              | Create a user |

## **users\_delete**

> users\_delete(cluster\_id, username)

Delete user

Deletes a single user

#### 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.UsersApi(api_client)
    cluster_id = '498ae72f-411f-11eb-9d07-046c59cc737e' # str | The unique ID of the cluster.
    username = 'benjamin' # str | The authentication username.
    try:
        # Delete user
        api_instance.users_delete(cluster_id, username)
    except ApiException as e:
        print('Exception when calling UsersApi.users_delete: %s\n' % e)
```

#### Parameters

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

#### Return type

void (empty response body)

#### Authorization

basicAuth, tokenAuth

#### HTTP request headers

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

## **users\_get**

> UserResource users\_get(cluster\_id, username)

Get user

Retrieves a single user

#### 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.UsersApi(api_client)
    cluster_id = '498ae72f-411f-11eb-9d07-046c59cc737e' # str | The unique ID of the cluster.
    username = 'benjamin' # str | The authentication username.
    try:
        # Get user
        api_response = api_instance.users_get(cluster_id, username)
        print(api_response)
    except ApiException as e:
        print('Exception when calling UsersApi.users_get: %s\n' % e)
```

#### Parameters

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

#### Return type

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

#### Authorization

basicAuth, tokenAuth

#### HTTP request headers

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

## **users\_list**

> UserList users\_list(cluster\_id, limit=limit, offset=offset, system=system)

List users

Retrieves a list of users

#### 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.UsersApi(api_client)
    cluster_id = '498ae72f-411f-11eb-9d07-046c59cc737e' # str | The unique ID of the cluster.
    try:
        # List users
        api_response = api_instance.users_list(cluster_id)
        print(api_response)
    except ApiException as e:
        print('Exception when calling UsersApi.users_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]   |
| **system**      | **bool** | If set to 'true' all users, including system users are returned. System users cannot be deleted or updated. | \[optional]                   |

#### Return type

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

#### Authorization

basicAuth, tokenAuth

#### HTTP request headers

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

## **users\_patch**

> UserResource users\_patch(cluster\_id, username, users\_patch\_request)

Patch user

Patches a single user. Only changing the password is supported. System users cannot be patched.

#### 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.UsersApi(api_client)
    cluster_id = '498ae72f-411f-11eb-9d07-046c59cc737e' # str | The unique ID of the cluster.
    username = 'benjamin' # str | The authentication username.
    users_patch_request = ionoscloud_dbaas_postgres.UsersPatchRequest() # UsersPatchRequest | Patch containing all properties that should be updated
    try:
        # Patch user
        api_response = api_instance.users_patch(cluster_id, username, users_patch_request)
        print(api_response)
    except ApiException as e:
        print('Exception when calling UsersApi.users_patch: %s\n' % e)
```

#### Parameters

| Name                      | Type                                                                                                                        | Description                                            | Notes |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | ----- |
| **cluster\_id**           | **str**                                                                                                                     | The unique ID of the cluster.                          |       |
| **username**              | **str**                                                                                                                     | The authentication username.                           |       |
| **users\_patch\_request** | [**UsersPatchRequest**](https://docs.ionos.com/sections-test/python-sdk/dbaas-postgres-python-sdk/models/userspatchrequest) | Patch containing all properties that should be updated |       |

#### Return type

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

#### Authorization

basicAuth, tokenAuth

#### HTTP request headers

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

## **users\_post**

> UserResource users\_post(cluster\_id, user)

Create a user

Create a new Postgres User

#### 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.UsersApi(api_client)
    cluster_id = '498ae72f-411f-11eb-9d07-046c59cc737e' # str | The unique ID of the cluster.
    user = ionoscloud_dbaas_postgres.User() # User | 
    try:
        # Create a user
        api_response = api_instance.users_post(cluster_id, user)
        print(api_response)
    except ApiException as e:
        print('Exception when calling UsersApi.users_post: %s\n' % e)
```

#### Parameters

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

#### Return type

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

#### Authorization

basicAuth, tokenAuth

#### HTTP request headers

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