roles
Creates, updates, deletes, gets or lists a roles
resource.
Overview
Name | roles |
Type | Resource |
Id | snowflake.role.roles |
Fields
The following fields are returned by SELECT
queries:
- list_roles
A Snowflake role
Name | Datatype | Description |
---|---|---|
name | string | Name of the role. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
assigned_to_users | integer (int64) | The number of users to whom this role has been assigned. |
comment | string | Comment of the role. |
created_on | string (date-time) | Date and time when the role was created. |
granted_roles | integer (int64) | The number of roles that have been granted to this role. |
granted_to_roles | integer (int64) | The number of roles to which this role has been granted. |
is_current | boolean | Specifies whether the role being fetched is the user's current role. |
is_default | boolean | Specifies whether the role being fetched is the user's default role. |
is_inherited | boolean | Specifies whether the role used to run the command inherits the specified role. |
owner | string | Specifies the role that owns this role. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
list_roles | select | endpoint | like , startsWith , showLimit , fromName | List roles |
create_role | insert | endpoint | createMode | Create a role |
delete_role | delete | name , endpoint | ifExists | Delete a role |
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 |
---|---|---|
endpoint | string | Organization and Account Name (default: orgid-acctid) |
name | string | Identifier (i.e. name) for the resource. |
createMode | string | Query parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists : Throws an error if you try to create a resource that already exists. - orReplace : Automatically replaces the existing resource with the current one. - ifNotExists : Creates a new resource when an alter is requested for a non-existent resource. |
fromName | string | Query parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name. |
ifExists | boolean | Query parameter that specifies how to handle the request for a resource that does not exist: - true : The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false : The endpoint throws an error if the resource doesn't exist. |
like | string | Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. |
showLimit | integer | Query parameter to limit the maximum number of rows returned by a command. |
startsWith | string | Query parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching. |
SELECT
examples
- list_roles
List roles
SELECT
name,
assigned_to_users,
comment,
created_on,
granted_roles,
granted_to_roles,
is_current,
is_default,
is_inherited,
owner
FROM snowflake.role.roles
WHERE endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}'
AND startsWith = '{{ startsWith }}'
AND showLimit = '{{ showLimit }}'
AND fromName = '{{ fromName }}';
INSERT
examples
- create_role
- Manifest
Create a role
INSERT INTO snowflake.role.roles (
data__name,
data__comment,
endpoint,
createMode
)
SELECT
'{{ name }}' --required,
'{{ comment }}',
'{{ endpoint }}',
'{{ createMode }}'
;
# Description fields are for documentation purposes
- name: roles
props:
- name: endpoint
value: string
description: Required parameter for the roles resource.
- name: name
value: string
description: >
Name of the role.
- name: comment
value: string
description: >
Comment of the role.
- name: createMode
value: string
description: Query parameter allowing support for different modes of resource creation. Possible values include: - `errorIfExists`: Throws an error if you try to create a resource that already exists. - `orReplace`: Automatically replaces the existing resource with the current one. - `ifNotExists`: Creates a new resource when an alter is requested for a non-existent resource.
DELETE
examples
- delete_role
Delete a role
DELETE FROM snowflake.role.roles
WHERE name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}';