users
Creates, updates, deletes, gets or lists a users
resource.
Overview
Name | users |
Type | Resource |
Id | digitalocean.databases.users |
Fields
Name | Datatype | Description |
---|---|---|
name | string | The name of a database user. |
access_cert | string | Access certificate for TLS client authentication. (Kafka only) |
access_key | string | Access key for TLS client authentication. (Kafka only) |
mysql_settings | object | |
password | string | A randomly generated password for the database user. |
role | string | A string representing the database user's role. The value will be either "primary" or "normal". |
settings | object |
Methods
Name | Accessible by | Required Params | Description |
---|---|---|---|
databases_get_user | SELECT | database_cluster_uuid, username | To show information about an existing database user, send a GET request to /v2/databases/$DATABASE_ID/users/$USERNAME . Note: User management is not supported for Redis clusters. The response will be a JSON object with a user key. This will be set to an object containing the standard database user attributes. For MySQL clusters, additional options will be contained in the mysql_settings object. For Kafka clusters, additional options will be contained in the settings object. |
databases_list_users | SELECT | database_cluster_uuid | To list all of the users for your database cluster, send a GET request to /v2/databases/$DATABASE_ID/users . Note: User management is not supported for Redis clusters. The result will be a JSON object with a users key. This will be set to an array of database user objects, each of which will contain the standard database user attributes. For MySQL clusters, additional options will be contained in the mysql_settings object. |
databases_add_user | INSERT | database_cluster_uuid, data__name | To add a new database user, send a POST request to /v2/databases/$DATABASE_ID/users with the desired username. Note: User management is not supported for Redis clusters. When adding a user to a MySQL cluster, additional options can be configured in the mysql_settings object. When adding a user to a Kafka cluster, additional options can be configured in the settings object. The response will be a JSON object with a key called user . The value of this will be an object that contains the standard attributes associated with a database user including its randomly generated password. |
databases_delete_user | DELETE | database_cluster_uuid, username | To remove a specific database user, send a DELETE request to /v2/databases/$DATABASE_ID/users/$USERNAME . A status of 204 will be given. This indicates that the request was processed successfully, but that no response body is needed. Note: User management is not supported for Redis clusters. |
databases_reset_auth | EXEC | database_cluster_uuid, username | To reset the password for a database user, send a POST request to /v2/databases/$DATABASE_ID/users/$USERNAME/reset_auth . For mysql databases, the authentication method can be specifying by including a key in the JSON body called mysql_settings with the auth_plugin value specified. The response will be a JSON object with a user key. This will be set to an object containing the standard database user attributes. |
databases_update_user | EXEC | database_cluster_uuid, username | To update an existing database user, send a PUT request to /v2/databases/$DATABASE_ID/users/$USERNAME with the desired settings. Note: only settings can be updated via this type of request. If you wish to change the name of a user, you must recreate a new user. The response will be a JSON object with a key called user . The value of this will be an object that contains the name of the update database user, along with the settings object that has been updated. |
SELECT
examples
To list all of the users for your database cluster, send a GET request to /v2/databases/$DATABASE_ID/users
. Note: User management is not supported for Redis clusters. The result will be a JSON object with a users
key. This will be set to an array of database user objects, each of which will contain the standard database user attributes. For MySQL clusters, additional options will be contained in the mysql_settings object.
SELECT
name,
access_cert,
access_key,
mysql_settings,
password,
role,
settings
FROM digitalocean.databases.users
WHERE database_cluster_uuid = '{{ database_cluster_uuid }}';
INSERT
example
Use the following StackQL query and manifest file to create a new users
resource.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO digitalocean.databases.users (
data__name,
data__mysql_settings,
data__settings,
database_cluster_uuid
)
SELECT
'{{ name }}',
'{{ mysql_settings }}',
'{{ settings }}',
'{{ database_cluster_uuid }}'
;
/*+ create */
INSERT INTO digitalocean.databases.users (
data__name,
database_cluster_uuid
)
SELECT
'{{ name }}',
'{{ database_cluster_uuid }}'
;
- name: users
props:
- name: database_cluster_uuid
value: string
- name: data__name
value: string
- name: name
value: string
- name: mysql_settings
props:
- name: auth_plugin
value: string
- name: settings
props:
- name: pg_allow_replication
value: boolean
- name: opensearch_acl
value: array
props:
- name: index
value: string
- name: permission
value: string
- name: acl
value: array
props:
- name: id
value: string
- name: topic
value: string
- name: permission
value: string
DELETE
example
Deletes the specified users
resource.
/*+ delete */
DELETE FROM digitalocean.databases.users
WHERE database_cluster_uuid = '{{ database_cluster_uuid }}'
AND username = '{{ username }}';