snowflake.core.network_policy.NetworkPolicyCollection

class snowflake.core.network_policy.NetworkPolicyCollection(root: Root)

Bases: NetworkPolicyCollectionBase

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)
Copy

Attributes

root

The Root object this collection belongs to.

Methods

create(network_policy: NetworkPolicy, mode: CreateMode | str | None = None) NetworkPolicyResource

Create a network policy.

Parameters:
  • network_policy (NetworkPolicy) – (required)

  • mode (Union[CreateMode, str]) – 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.

create_async(network_policy: NetworkPolicy, mode: CreateMode | str | None = None) PollingOperation[NetworkPolicyResource]

An asynchronous version of create().

Refer to PollingOperation for more information on asynchronous execution and the return type.

items() ItemsView[str, T]
iter() Iterator[NetworkPolicy]

List network policies.

iter_async() PollingOperation[Iterator[NetworkPolicy]]

An asynchronous version of iter().

Refer to PollingOperation for more information on asynchronous execution and the return type.

keys() KeysView[str]
update_reference(old_name: str, new_name: str, resource: T) None

Update the collection with a new item.

values() ValuesView[T]