Skip to main content

users

Creates, updates, deletes, gets or lists a users resource.

Overview

Nameusers
TypeResource
Iddigitalocean.databases.users

Fields

NameDatatypeDescription
namestringThe name of a database user.
access_certstringAccess certificate for TLS client authentication. (Kafka only)
access_keystringAccess key for TLS client authentication. (Kafka only)
mysql_settingsobject
passwordstringA randomly generated password for the database user.
rolestringA string representing the database user's role. The value will be either "primary" or "normal".
settingsobject

Methods

NameAccessible byRequired ParamsDescription
databases_get_userSELECTdatabase_cluster_uuid, usernameTo 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_usersSELECTdatabase_cluster_uuidTo 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_userINSERTdatabase_cluster_uuid, data__nameTo 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_userDELETEdatabase_cluster_uuid, usernameTo 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_authEXECdatabase_cluster_uuid, usernameTo 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_userEXECdatabase_cluster_uuid, usernameTo 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.

/*+ create */
INSERT INTO digitalocean.databases.users (
data__name,
data__mysql_settings,
data__settings,
database_cluster_uuid
)
SELECT
'{{ name }}',
'{{ mysql_settings }}',
'{{ settings }}',
'{{ database_cluster_uuid }}'
;

DELETE example

Deletes the specified users resource.

/*+ delete */
DELETE FROM digitalocean.databases.users
WHERE database_cluster_uuid = '{{ database_cluster_uuid }}'
AND username = '{{ username }}';