snowflake.core.network_policy.NetworkPolicyCollectionΒΆ
- class snowflake.core.network_policy.NetworkPolicyCollection(root: Root)ΒΆ
Bases:
AccountObjectCollectionParent
[NetworkPolicyResource
]Represents the collection operations on the Snowflake Network Policy resource.
With this collection, you can create, iterate through, and fetch network policies that you have access to in the current context.
Examples
Creating a network policy instance with only a single ip allowed:
>>> network_policies = root.network_policies >>> new_network_policy = NetworkPolicy( ... name = 'single_ip_policy', ... allowed_ip_list=['192.168.1.32/32'], ... blocked_ip_list=['0.0.0.0'], ... ) >>> network_policies.create(new_network_policy)
Attributes
- rootΒΆ
Methods
- create(network_policy: NetworkPolicy, mode: CreateMode = CreateMode.error_if_exists) NetworkPolicyResource ΒΆ
Create a network policy in Snowflake.
- Parameters:
network_policy (NetworkPolicy) β The
NetworkPolicy
object, together withNetworkPolicy
βs properties: name; allowed_network_rule_list, blocked_network_rule_list, allowed_ip_list, blocked_ip_list, comment are optionalmode (CreateMode, optional) β
One of the following enum values:
CreateMode.error_if_exists
: Throw ansnowflake.core.exceptions.ConflictError
if the network policy already exists in Snowflake. Equivalent to SQLcreate network policy <name> ...
.CreateMode.or_replace
: Replace if the network policy already exists in Snowflake. Equivalent to SQLcreate or replace network policy <name> ...
.CreateMode.if_not_exists
: Do nothing if the network policy already exists in Snowflake. Equivalent to SQLcreate network policy <name> if not exists...
Default is
CreateMode.error_if_exists
.
Examples
Create a Network Policy instance:
>>> root.network_policies.create(NetworkPolicy( ... name = 'my_network_policy', ... allowed_network_rule_list = allowed_rules, ... blocked_network_rule_list = blocked_rules, ... allowed_ip_list=['8.8.8.8'], ... blocked_ip_list=['0.0.0.0'], ... ))
- items() ItemsView[str, T] ΒΆ
- iter() Iterator[NetworkPolicy] ΒΆ
Iterate through
NetworkPolicy
objects from Snowflake.Examples
Printing the names of all visible network policies:
>>> for network_policy in root.network_policies.iter(): >>> print(network_policy.name)
- keys() KeysView[str] ΒΆ
- values() ValuesView[T] ΒΆ