Skip to main content

postgresql_users

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

Overview​

Namepostgresql_users
TypeResource
Idovh.public_cloud_database.postgresql_users

Fields​

The following fields are returned by SELECT queries:

successful operation

NameDatatypeDescription
idstring (uuid)Unique identifier of the user
adminbooleanWhether this is the service administrator, the user created automatically at provisioning time, which cannot be deleted
checksumstringHash of the resource used for concurrency control
created_atstring (date-time)Date at which the user was created (wire: createdAt)
credentials_last_updated_atstring (date-time)Date at which the user credentials were last updated (wire: credentialsLastUpdatedAt)
passwordstring (password)Password of the user. Returned only on creation or password reset.
rolesarrayList of roles assigned to the user. Available roles depend on the engine.
statusstringCurrent readiness status of the user (CREATING, DELETING, ERROR, READY, UPDATING)
usernamestringLogin name of the user

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectservice_id, user_id, project_idReturns the user, its roles and its status. The password is not returned. (Beta version)
listselectservice_id, project_idx_pagination_cursor, x_pagination_sizeReturns the users of the service with their roles and status. Passwords are not returned. (Beta version)
createinsertservice_id, project_id, nameCreates a user with the given roles and generates its password. The password is returned only on creation and on password reset. (Beta version)
updateupdateservice_id, user_id, project_idPartially updates the roles of the user. The roles list replaces the current roles. Setting credentialsLastUpdatedAt resets the password and returns the new one. (Beta version)
deletedeleteservice_id, user_id, project_idPermanently deletes the user. (Beta version)
replaceexecserviceId, userId, project_id, rolesUpdates the roles of the user. The roles list replaces the current roles. To reset the password, use the resetPassword route of the user or a partial update with credentialsLastUpdatedAt. (Beta version)
reset_passwordexecserviceId, userId, project_idGenerates a new password for the user and returns it in the response. Reading the user never returns it. The previous password stops working once the new one is applied, and credentialsLastUpdatedAt becomes the date of this reset. This is the same reset as a partial update of the user that sets credentialsLastUpdatedAt. (Beta version)

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
api_hoststringThe OVHcloud API host. Selected by OVH_ENDPOINT (ovh-eu, ovh-ca or ovh-us; default ovh-eu). (default: api.eu.ovhcloud.com, x-stackQL-envVarSelector: {"envVar":"OVH_ENDPOINT","default":"ovh-eu","values":{"ovh-eu":"api.eu.ovhcloud.com","ovh-ca":"api.ca.ovhcloud.com","ovh-us":"api.us.ovhcloud.com"}})
project_idstringThe Public Cloud project ID. Resolved from OVH_CLOUD_PROJECT_SERVICE when set.
serviceIdstring (uuid)Service ID
service_idstring (uuid)Service ID (wire: serviceId)
userIdstring (uuid)User ID
user_idstring (uuid)User ID (wire: userId)
x_pagination_cursorstringPagination cursor (wire: X-Pagination-Cursor)
x_pagination_sizeintegerPagination size (wire: X-Pagination-Size)

SELECT examples​

Returns the user, its roles and its status. The password is not returned. (Beta version)

SELECT
id,
admin,
checksum,
created_at,
credentials_last_updated_at,
password,
roles,
status,
username
FROM ovh.public_cloud_database.postgresql_users
WHERE service_id = '{{ service_id }}' -- required
AND user_id = '{{ user_id }}' -- required
AND project_id = '{{ project_id }}' -- required unless OVH_CLOUD_PROJECT_SERVICE is set
;

INSERT examples​

Creates a user with the given roles and generates its password. The password is returned only on creation and on password reset. (Beta version)

INSERT INTO ovh.public_cloud_database.postgresql_users (
name,
roles,
service_id,
project_id
)
SELECT
'{{ name }}' /* required */,
'{{ roles }}',
'{{ service_id }}',
'{{ project_id }}'
RETURNING
id,
admin,
checksum,
created_at,
credentials_last_updated_at,
password,
roles,
status,
username
;

UPDATE examples​

Partially updates the roles of the user. The roles list replaces the current roles. Setting credentialsLastUpdatedAt resets the password and returns the new one. (Beta version)

UPDATE ovh.public_cloud_database.postgresql_users
SET
credentials_last_updated_at = '{{ credentials_last_updated_at }}',
roles = '{{ roles }}'
WHERE
service_id = '{{ service_id }}' --required
AND user_id = '{{ user_id }}' --required
AND project_id = '{{ project_id }}' --required unless OVH_CLOUD_PROJECT_SERVICE is set
RETURNING
id,
admin,
checksum,
created_at,
credentials_last_updated_at,
password,
roles,
status,
username;

DELETE examples​

Permanently deletes the user. (Beta version)

DELETE FROM ovh.public_cloud_database.postgresql_users
WHERE service_id = '{{ service_id }}' --required
AND user_id = '{{ user_id }}' --required
AND project_id = '{{ project_id }}' --required unless OVH_CLOUD_PROJECT_SERVICE is set
;

Lifecycle Methods​

EXEC variables use wire (API) names.

Updates the roles of the user. The roles list replaces the current roles. To reset the password, use the resetPassword route of the user or a partial update with credentialsLastUpdatedAt. (Beta version)

EXEC ovh.public_cloud_database.postgresql_users.replace
@serviceId='{{ serviceId }}' --required,
@userId='{{ userId }}' --required,
@project_id='{{ project_id }}' --required unless OVH_CLOUD_PROJECT_SERVICE is set
@@json=
'{
"roles": "{{ roles }}"
}'
;