snowflake.core.notebook.NotebookResource¶
- class snowflake.core.notebook.NotebookResource(name: str, collection_class: NotebookCollectionBase)¶
Bases:
NotebookResourceBaseRepresents a reference to a Snowflake notebook.
With this notebook reference, you can fetch information about a notebook, as well as perform certain actions on it.
Attributes
- database¶
The DatabaseResource this reference belongs to.
- fully_qualified_name¶
Return the fully qualified name of the object this reference points to.
- root¶
The Root object this reference belongs to.
Methods
- add_live_version(from_last: bool | None = None, comment: str | None = None) None¶
Adds a LIVE version to the notebook.
- Parameters:
from_last (bool) – Sets the LIVE version to the LAST version of the notebook
comment (str) – Sets a comment for the notebook or version of the notebook
- add_live_version_async(from_last: bool | None = None, comment: str | None = None) PollingOperation[None]¶
An asynchronous version of
add_live_version().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- commit(version: str | None = None, comment: str | None = None) None¶
Commits the LIVE version of the notebook.
- Parameters:
version (str) – live version of the alias
comment (str) – Sets a comment for the notebook or version of the notebook
- commit_async(version: str | None = None, comment: str | None = None) PollingOperation[None]¶
An asynchronous version of
commit().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- drop(if_exists: bool | None = None) None¶
Delete a notebook.
- Parameters:
if_exists (bool) – 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.
- drop_async(if_exists: bool | None = None) PollingOperation[None]¶
An asynchronous version of
drop().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- execute(async_exec: bool | None = None) None¶
Execute a Notebook.
- Parameters:
async_exec (bool) – Asynchronous execution enable/disable. Default is disable.
- execute_async(async_exec: bool | None = None) PollingOperation[None]¶
An asynchronous version of
execute().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- fetch_async() PollingOperation[Notebook]¶
An asynchronous version of
fetch().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- get_tags(with_lineage: bool | None = None) dict[TagResource, TagValue]¶
Get the tag assignments for a notebook.
Returns all tags assigned to a notebook. This operation requires an active warehouse.
- Parameters:
with_lineage (bool) – Parameter that specifies whether tag assignments inherited by the object from its ancestors in securable object hierarchy should be returned as well: - true: All tags assigned to this object should be returned, inheritance included. - false: Only tags explicitly assigned to this object should be returned.
- get_tags_async(with_lineage: bool | None = None) PollingOperation[dict[TagResource, TagValue]]¶
An asynchronous version of
get_tags().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- rename(target_name: str, target_database: str | None = None, target_schema: str | None = None, if_exists: bool | None = None) None¶
Rename this notebook.
- Parameters:
target_name (str) – The new name of the notebook
target_database (str, optional) – The new database name of the notebook. If not provided, the current database name is used. The default is
None.target_schema (str, optional) – The new schema name of the notebook. If not provided, the current schema name is used. The default is
None.if_exists (bool, optional) – Whether to check for the existence of notebook before renaming. The default is
None, which is equivalent toFalse.
Examples
Renaming this notebook using its reference:
>>> notebook_reference.rename("my_other_notebook")
Renaming this notebook if it exists:
>>> notebook_reference.rename("my_other_notebook", if_exists=True)
- rename_async(target_name: str, if_exists: bool | None = None, target_database: str | None = None, target_schema: str | None = None) PollingOperation[None]¶
An asynchronous version of
rename().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- set_tags(tags: dict[TagResource, TagValue], if_exists: bool | None = None) None¶
Set tags on a notebook.
- Parameters:
tags (dict[TagResource, TagValue]) – (required)
if_exists (bool) – 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.
- set_tags_async(tags: dict[TagResource, TagValue], if_exists: bool | None = None) PollingOperation[None]¶
An asynchronous version of
set_tags().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- unset_tags(tag_resources: set[TagResource], if_exists: bool | None = None) None¶
Unset tags from a notebook.
- Parameters:
tag_resources (set[TagResource]) – (required)
if_exists (bool) – 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.
- unset_tags_async(tag_resources: set[TagResource], if_exists: bool | None = None) PollingOperation[None]¶
An asynchronous version of
unset_tags().Refer to
PollingOperationfor more information on asynchronous execution and the return type.