# 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**](/postgres-sdk-python/models/userresource.md)

#### 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**](/postgres-sdk-python/models/userlist.md)

#### 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**](/postgres-sdk-python/models/userspatchrequest.md) | Patch containing all properties that should be updated |       |

#### Return type

[**UserResource**](/postgres-sdk-python/models/userresource.md)

#### 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**](/postgres-sdk-python/models/user.md) |                               |       |

#### Return type

[**UserResource**](/postgres-sdk-python/models/userresource.md)

#### Authorization

basicAuth, tokenAuth

#### HTTP request headers

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ionos.com/postgres-sdk-python/api/usersapi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
