Skip to main content

user_grants

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

Overview​

Nameuser_grants
TypeResource
Idovh.hosting_private_database.user_grants

Fields​

The following fields are returned by SELECT queries:

successful operation

NameDatatypeDescription
database_namestringDump of this database name (wire: databaseName)
creation_datestring (date-time)Automatic deletion date of the dump (wire: creationDate)
grantstringGrant set (admin, none, overquota_admin, overquota_rw, ro, rw)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectdatabase_name, service_name, user_nameReturns the rights of the user on the database and the creation date of the grant.
listselectservice_name, user_namex_pagination_modeReturns the names of the databases the user has a grant on.
createinsertservice_name, user_name, database_name, grantGrants the user rights on a database. Returns a task to follow the change.
deletedeletedatabase_name, service_name, user_nameRevokes the rights of the user on the database. The user and the database are kept.
updateexecdatabaseName, serviceName, userName, grantChanges the rights of the user on the database. Returns a task to follow the change.

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"}})
databaseNamestringDatabase name
database_namestringDatabase name (wire: databaseName)
serviceNamestringService name
service_namestringService name (wire: serviceName)
userNamestringUser name
user_namestringUser name (wire: userName)
x_pagination_modestringSent as CachedObjectList-Pages by default so the list returns the full objects rather than their identifiers. (wire: X-Pagination-Mode)

SELECT examples​

Returns the rights of the user on the database and the creation date of the grant.

SELECT
database_name,
creation_date,
grant
FROM ovh.hosting_private_database.user_grants
WHERE database_name = '{{ database_name }}' -- required
AND service_name = '{{ service_name }}' -- required
AND user_name = '{{ user_name }}' -- required
;

INSERT examples​

Grants the user rights on a database. Returns a task to follow the change.

INSERT INTO ovh.hosting_private_database.user_grants (
database_name,
grant,
service_name,
user_name
)
SELECT
'{{ database_name }}' /* required */,
'{{ grant }}' /* required */,
'{{ service_name }}',
'{{ user_name }}'
RETURNING
id,
dump_id,
database_name,
user_name,
done_date,
function,
last_update,
start_date,
status
;

DELETE examples​

Revokes the rights of the user on the database. The user and the database are kept.

DELETE FROM ovh.hosting_private_database.user_grants
WHERE database_name = '{{ database_name }}' --required
AND service_name = '{{ service_name }}' --required
AND user_name = '{{ user_name }}' --required
;

Lifecycle Methods​

EXEC variables use wire (API) names.

Changes the rights of the user on the database. Returns a task to follow the change.

EXEC ovh.hosting_private_database.user_grants.update
@databaseName='{{ databaseName }}' --required,
@serviceName='{{ serviceName }}' --required,
@userName='{{ userName }}' --required
@@json=
'{
"grant": "{{ grant }}"
}'
;