user_grants
Creates, updates, deletes, gets or lists a user_grants resource.
Overview​
| Name | user_grants |
| Type | Resource |
| Id | ovh.hosting_private_database.user_grants |
Fields​
The following fields are returned by SELECT queries:
- get
- list
successful operation
| Name | Datatype | Description |
|---|---|---|
database_name | string | Dump of this database name (wire: databaseName) |
creation_date | string (date-time) | Automatic deletion date of the dump (wire: creationDate) |
grant | string | Grant set (admin, none, overquota_admin, overquota_rw, ro, rw) |
Grant
| Name | Datatype | Description |
|---|---|---|
database_name | string | Dump of this database name (wire: databaseName) |
creation_date | string (date-time) | Automatic deletion date of the dump (wire: creationDate) |
grant | string | Grant set (admin, none, overquota_admin, overquota_rw, ro, rw) |
Methods​
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | database_name, service_name, user_name | Returns the rights of the user on the database and the creation date of the grant. | |
list | select | service_name, user_name | x_pagination_mode | Returns the names of the databases the user has a grant on. |
create | insert | service_name, user_name, database_name, grant | Grants the user rights on a database. Returns a task to follow the change. | |
delete | delete | database_name, service_name, user_name | Revokes the rights of the user on the database. The user and the database are kept. | |
update | exec | databaseName, serviceName, userName, grant | Changes 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.
| Name | Datatype | Description |
|---|---|---|
api_host | string | The 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"}}) |
databaseName | string | Database name |
database_name | string | Database name (wire: databaseName) |
serviceName | string | Service name |
service_name | string | Service name (wire: serviceName) |
userName | string | User name |
user_name | string | User name (wire: userName) |
x_pagination_mode | string | Sent as CachedObjectList-Pages by default so the list returns the full objects rather than their identifiers. (wire: X-Pagination-Mode) |
SELECT examples​
- get
- list
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
;
Returns the names of the databases the user has a grant on.
SELECT
database_name,
creation_date,
grant
FROM ovh.hosting_private_database.user_grants
WHERE service_name = '{{ service_name }}' -- required
AND user_name = '{{ user_name }}' -- required
AND x_pagination_mode = '{{ x_pagination_mode }}'
;
INSERT examples​
- create
- Manifest
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
;
# Description fields are for documentation purposes
- name: user_grants
props:
- name: service_name
value: "{{ service_name }}"
description: Required parameter for the user_grants resource.
- name: user_name
value: "{{ user_name }}"
description: Required parameter for the user_grants resource.
- name: database_name
value: "{{ database_name }}"
description: |
Database name where add grant
- name: grant
value: "{{ grant }}"
description: |
Grant on a database for a specific user
valid_values: ['admin', 'none', 'overquota_admin', 'overquota_rw', 'ro', 'rw']
DELETE examples​
- delete
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.
- update
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 }}"
}'
;