snowflake.core.image_repository.ImageRepositoryCollection¶
- class snowflake.core.image_repository.ImageRepositoryCollection(schema: SchemaResource)¶
Bases:
SchemaObjectCollectionParent
[ImageRepositoryResource
]Represents the collection operations on the Snowflake Image Repository resource.
With this collection, you can create, iterate through, and search for image repositories that you have access to in the current context.
Examples
Creating an image repository instance:
>>> image_repository = ImageRepository(name="my_image_repository") >>> image_repositories = root.databases["my_db"].schemas["my_schema"].image_repositories >>> image_repositories.create(image_repository)
Attributes
- database¶
- root¶
Methods
- create(image_repository: ImageRepositoryModel, mode: CreateMode = CreateMode.error_if_exists) ImageRepositoryResource ¶
Create an image repository in Snowflake.
- Parameters:
image_repository (ImageRepository) – The
ImageRepository
object, together with theImageRepository
’s properties: name;mode (CreateMode, optional) –
One of the following enum values.
CreateMode.error_if_exists
: Throw ansnowflake.core.exceptions.ConflictError
if the image repository already exists in Snowflake. Equivalent to SQLcreate image repository <name> ...
.CreateMode.or_replace
: Replace if the image repository already exists in Snowflake. Equivalent to SQLcreate or replace image repository <name> ...
.CreateMode.if_not_exists
: Do nothing if the image repository already exists in Snowflake. Equivalent to SQLcreate image repository <name> if not exists...
Default value is
CreateMode.error_if_exists
.
Examples
Creating an image repository, replacing an existing image repository with the same name:
>>> image_repository = ImageRepository(name="my_image_repository") >>> image_repositories = root.databases["my_db"].schemas["my_schema"].image_repositories >>> image_repositories.create(image_repository, mode=CreateMode.or_replace)
- items() ItemsView[str, T] ¶
- iter(*, like: str | None = None) Iterator[ImageRepositoryModel] ¶
Iterate through
ImageRepository
objects from 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 image repositories that you have access to see:
>>> image_respositories = image_repository_collection.iter()
Showing information of the exact image repository you want to see:
>>> image_respositories = image_repository_collection.iter(like="your-image-repository-name")
Showing image repositories starting with ‘your-image-repository-name-‘:
>>> image_respositories = image_repository_collection.iter(like="your-image-repository-name-%")
Using a for loop to retrieve information from iterator:
>>> for image_repository in image_respositories: >>> print(image_repository.name)
- keys() KeysView[str] ¶
- values() ValuesView[T] ¶