tags
Creates, updates, deletes, gets or lists a tags resource.
Overview
| Name | tags |
| Type | Resource |
| Id | snowflake.security.tags |
Fields
The following fields are returned by SELECT queries:
- get
- list
successful
| Name | Datatype | Description |
|---|---|---|
name | string | Name of the tag (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
database_name | string | Database in which the tag is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
schema_name | string | Schema in which the tag is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
allowed_values | array | Possible string values that can be assigned with the tag when the tag is set on an object |
comment | string | Comment for the tag |
created_on | string (date-time) | Date and time when the tag was created. |
on_conflict | string | Specifies what happens when there is a conflict between the values of propagated tags |
owner | string | Role that owns the tag (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
owner_role_type | string | The type of role that owns the tag |
propagate | string | Specifies that the tag will be automatically propagated from source objects to target objects |
A Snowflake tag
| Name | Datatype | Description |
|---|---|---|
name | string | Name of the tag (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
database_name | string | Database in which the tag is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
schema_name | string | Schema in which the tag is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
allowed_values | array | Possible string values that can be assigned with the tag when the tag is set on an object |
comment | string | Comment for the tag |
created_on | string (date-time) | Date and time when the tag was created. |
on_conflict | string | Specifies what happens when there is a conflict between the values of propagated tags |
owner | string | Role that owns the tag (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
owner_role_type | string | The type of role that owns the tag |
propagate | string | Specifies that the tag will be automatically propagated from source objects to target objects |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | database_name, schema_name, name, endpoint | Fetch a tag | |
list | select | database_name, schema_name, endpoint | like | List tags |
create | insert | database_name, schema_name, endpoint, name | createMode | Create a tag |
create_or_alter | replace | database_name, schema_name, tag_name, endpoint, name | Create or update a tag | |
delete | delete | database_name, schema_name, name, endpoint | ifExists | Delete a tag |
undrop | exec | database_name, schema_name, name, endpoint | Undrop a tag | |
rename | exec | database_name, schema_name, name, targetName, endpoint | ifExists, targetDatabase, targetSchema | Rename a tag with a new identifier |
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 |
|---|---|---|
database_name | string | Identifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases. |
endpoint | string | Organization and account identifier (orgname-accountname) (default: orgname-accountname) |
name | string | Identifier (i.e. name) for the resource. |
schema_name | string | Identifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database. |
tag_name | string | Identifier (i.e. name) for the resource. |
targetName | string | Name of the target resource. |
createMode | string | 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. |
ifExists | boolean | 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 | Parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. |
targetDatabase | string | Database of the target resource. Defaults to the source's database |
targetSchema | string | Schema of the target resource. Defaults to the source's schema |
SELECT examples
- get
- list
Fetch a tag
SELECT
name,
database_name,
schema_name,
allowed_values,
comment,
created_on,
on_conflict,
owner,
owner_role_type,
propagate
FROM snowflake.security.tags
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;
List tags
SELECT
name,
database_name,
schema_name,
allowed_values,
comment,
created_on,
on_conflict,
owner,
owner_role_type,
propagate
FROM snowflake.security.tags
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND "like" = '{{ like }}'
;
INSERT examples
- create
- Manifest
Create a tag
INSERT INTO snowflake.security.tags (
allowed_values,
propagate,
on_conflict,
comment,
name,
database_name,
schema_name,
endpoint,
createMode
)
SELECT
'{{ allowed_values }}',
'{{ propagate }}',
'{{ on_conflict }}',
'{{ comment }}',
'{{ name }}' /* required */,
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
RETURNING
status
;
# Description fields are for documentation purposes
- name: tags
props:
- name: database_name
value: "{{ database_name }}"
description: Required parameter for the tags resource.
- name: schema_name
value: "{{ schema_name }}"
description: Required parameter for the tags resource.
- name: endpoint
value: "{{ endpoint }}"
description: Required parameter for the tags resource.
- name: allowed_values
value:
- "{{ allowed_values }}"
description: |
Possible string values that can be assigned with the tag when the tag is set on an object
- name: propagate
value: "{{ propagate }}"
description: |
Specifies that the tag will be automatically propagated from source objects to target objects
- name: on_conflict
value: "{{ on_conflict }}"
description: |
Specifies what happens when there is a conflict between the values of propagated tags
- name: comment
value: "{{ comment }}"
description: |
Comment for the tag
- name: name
value: "{{ name }}"
description: |
Name of the tag
- name: createMode
value: "{{ createMode }}"
description: 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.
description: 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.
REPLACE examples
- create_or_alter
Create or update a tag
REPLACE snowflake.security.tags
SET
allowed_values = '{{ allowed_values }}',
propagate = '{{ propagate }}',
on_conflict = '{{ on_conflict }}',
comment = '{{ comment }}',
name = '{{ name }}'
WHERE
database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND tag_name = '{{ tag_name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND name = '{{ name }}' --required
RETURNING
status;
DELETE examples
- delete
Delete a tag
DELETE FROM snowflake.security.tags
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}'
;
Lifecycle Methods
- undrop
- rename
Undrop a tag
EXEC snowflake.security.tags.undrop
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@endpoint='{{ endpoint }}' --required
;
Rename a tag with a new identifier
EXEC snowflake.security.tags.rename
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@targetName='{{ targetName }}' --required,
@endpoint='{{ endpoint }}' --required,
@ifExists={{ ifExists }},
@targetDatabase='{{ targetDatabase }}',
@targetSchema='{{ targetSchema }}'
;