snowflake.core.external_volume.ExternalVolumeCollection

class snowflake.core.external_volume.ExternalVolumeCollection(root: Root)

Bases: AccountObjectCollectionParent[ExternalVolumeResource]

Represents the collection operations of the Snowflake External Volume resource.

With this collection, you can create, iterate through, and search for external volume that you have access to in the current context.

Examples

Creating an external volume instance:

>>> external_volume_collection = root.external_volumes
>>> external_volume = ExternalVolume(
...     name="MY_EXTERNAL_VOLUME",
...     storage_location=StorageLocationS3(
...         name="abcd-my-s3-us-west-2",
...         storage_base_url="s3://MY_EXAMPLE_BUCKET/",
...         storage_aws_role_arn="arn:aws:iam::123456789022:role/myrole",
...         encryption=Encryption(type="AWS_SSE_KMS",
...                                kms_key_id="1234abcd-12ab-34cd-56ef-1234567890ab")
...     ),
...     comment="This is my external volume",
... )
>>> external_volume_collection.create(external_volume)
Copy

Attributes

root

Methods

create(external_volume: ExternalVolume, *, mode: CreateMode = CreateMode.error_if_exists) ExternalVolumeResource

Create an external volume in Snowflake.

Parameters:
  • external_volume (ExternalVolume)

  • mode (CreateMode, optional) –

    One of the following strings.

    CreateMode.error_if_exists: Throw an snowflake.core.exceptions.ConflictError if the external volume already exists in Snowflake. Equivalent to SQL create external volume <name> ....

    CreateMode.or_replace: Replace if the external volume already exists in Snowflake. Equivalent to SQL create or replace external volume <name> ....

    CreateMode.if_not_exists: Do nothing if the external volume already exists in Snowflake. Equivalent to SQL create external volume <name> if not exists...

    Default value is CreateMode.error_if_exists.

Examples

Creating an external volume in Snowflake and getting a reference to it:

>>> external_volume_parameters = ExternalVolume(
...     name="MY_EXTERNAL_VOLUME",
...     storage_location=StorageLocationS3(
...         name="abcd-my-s3-us-west-2",
...         storage_base_url="s3://MY_EXAMPLE_BUCKET/",
...         storage_aws_role_arn="arn:aws:iam::123456789022:role/myrole",
...         encryption=Encryption(type="AWS_SSE_KMS",
...                                kms_key_id="1234abcd-12ab-34cd-56ef-1234567890ab")
...     ),
...     comment="This is my external volume",
... )
>>> # Use the external volume collection created before to create a referece to the external volume resource
>>> # in Snowflake.
>>> external_volume_reference = external_volume_collection.create(external_volume_parameters)
Copy
items() ItemsView[str, T]
iter(*, like: str | None = None) Iterator[ExternalVolume]

Iterate through ExternalVolume objects in Snowflake, filtering on any optional like pattern.

Parameters:

like (str, optional) – A case-insensitive string functioning as a filter, with support for SQL wildcard characters (% and _).

Examples

Showing all external volumes you have access to see:

>>> external_volumes = external_volume_collection.iter()
Copy

Showing information of the exact external volume you want to see:

>>> external_volumes = external_volume_collection.iter(like="your-external-volume-name")
Copy

Showing external volumes starting with ‘your-external-volume-name’:

>>> external_volumes = external_volume_collection.iter(like="your-external-volume-name%")
Copy

Using a for loop to retrieve information from iterator:

>>> for external_volume in external_volumes:
>>>     print(external_volume.name, external_volume.comment)
Copy
keys() KeysView[str]
values() ValuesView[T]
Language: English