network_rules
Creates, updates, deletes, gets or lists a network_rules resource.
Overview
| Name | network_rules |
| Type | Resource |
| Id | snowflake.security.network_rules |
Fields
The following fields are returned by SELECT queries:
- get
- list
successful
| Name | Datatype | Description |
|---|---|---|
name | string | Name of the network rule (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
database_name | string | Database in which the network rule is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
schema_name | string | Schema in which the network rule is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
comment | string | Comment for the network rule |
created_on | string (date-time) | Date and time when the network rule was created |
mode | string | Specifies what is restricted by the network rule. Possible values: INGRESS, INTERNAL_STAGE, EGRESS |
owner | string | Role that owns the network rule (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
owner_role_type | string | The type of role that owns the network rule |
type | string | Type of the network rule |
value_list | array | List of values in a network rule |
A Snowflake network rule
| Name | Datatype | Description |
|---|---|---|
name | string | Name of the network rule (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
database_name | string | Database in which the network rule is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
schema_name | string | Schema in which the network rule is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
comment | string | Comment for the network rule |
created_on | string (date-time) | Date and time when the network rule was created |
mode | string | Specifies what is restricted by the network rule. Possible values: INGRESS, INTERNAL_STAGE, EGRESS |
owner | string | Role that owns the network rule (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
owner_role_type | string | The type of role that owns the network rule |
type | string | Type of the network rule |
value_list | array | List of values in a network rule |
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 network rule | |
list | select | database_name, schema_name, endpoint | like, startsWith, showLimit, fromName | List network rules |
create | insert | database_name, schema_name, endpoint, type, name | createMode | Create a network rule |
delete | delete | database_name, schema_name, name, endpoint | ifExists | Delete a network rule |
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. |
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. |
fromName | string | 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 | 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. |
showLimit | integer | Parameter to limit the maximum number of rows returned by a command. |
startsWith | string | 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
- get
- list
Fetch a network rule
SELECT
name,
database_name,
schema_name,
comment,
created_on,
mode,
owner,
owner_role_type,
type,
value_list
FROM snowflake.security.network_rules
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;
List network rules
SELECT
name,
database_name,
schema_name,
comment,
created_on,
mode,
owner,
owner_role_type,
type,
value_list
FROM snowflake.security.network_rules
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND "like" = '{{ like }}'
AND startsWith = '{{ startsWith }}'
AND showLimit = '{{ showLimit }}'
AND fromName = '{{ fromName }}'
;
INSERT examples
- create
- Manifest
Create a network rule
INSERT INTO snowflake.security.network_rules (
type,
mode,
value_list,
comment,
name,
database_name,
schema_name,
endpoint,
createMode
)
SELECT
'{{ type }}' /* required */,
'{{ mode }}',
'{{ value_list }}',
'{{ comment }}',
'{{ name }}' /* required */,
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
RETURNING
status
;
# Description fields are for documentation purposes
- name: network_rules
props:
- name: database_name
value: "{{ database_name }}"
description: Required parameter for the network_rules resource.
- name: schema_name
value: "{{ schema_name }}"
description: Required parameter for the network_rules resource.
- name: endpoint
value: "{{ endpoint }}"
description: Required parameter for the network_rules resource.
- name: type
value: "{{ type }}"
description: |
Type of the network rule
- name: mode
value: "{{ mode }}"
description: |
Specifies what is restricted by the network rule. Possible values: INGRESS, INTERNAL_STAGE, EGRESS
- name: value_list
value:
- "{{ value_list }}"
description: |
List of values in a network rule
- name: comment
value: "{{ comment }}"
description: |
Comment for the network rule
- name: name
value: "{{ name }}"
description: |
Name of the network rule
- 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.
DELETE examples
- delete
Delete a network rule
DELETE FROM snowflake.security.network_rules
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}'
;