snowflake.core.notification_integration.NotificationIntegrationCollection

class snowflake.core.notification_integration.NotificationIntegrationCollection(root: Root)

Bases: AccountObjectCollectionParent[NotificationIntegrationResource]

Represents the collection operations on the Snowflake Notification Integration resource.

With this collection, you can create, update, and iterate through notification integrations that you have access to in the current context.

Examples

Creating a notification integrations instance:

>>> # This example assumes that mySecret already exists
>>> notification_integrations = root.notification_integrations
>>> new_ni = NotificationIntegration(
...     name="my_notification_integration",
...     enabled=True,
...     notification_hook=NotificationWebhook(
...         webhook_url="https://events.pagerduty.com/v2/enqueue",
...         webhook_secret=WebhookSecret(
...             name="mySecret".upper(), database_name=database, schema_name=schema
...         ),
...         webhook_body_template='{"key": "SNOWFLAKE_WEBHOOK_SECRET", "msg": "SNOWFLAKE_WEBHOOK_MESSAGE"}',
...         webhook_headers={"content-type": "application/json", "user-content": "chrome"},
...     )
... )
>>> notification_integrations.create(new_ni)
Copy

Attributes

root

Methods

create(notification_integration: NotificationIntegration, *, mode: CreateMode = CreateMode.error_if_exists) NotificationIntegrationResource

Create a notification integration in Snowflake.

Parameters:
  • notification_integration (NotificationIntegration) – The NotificationIntegration object, together with the NotificationIntegration’s properties: name, enabled, notification_hook; comment is optional.

  • mode (CreateMode, optional) –

    One of the following enum values:

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

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

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

    Default is CreateMode.error_if_exists.

Examples

Creating a notification integration instance:

>>> notification_integrations.create(
...     NotificationIntegration(
...         name="my_notification_integration",
...         notification_hook=NotificationEmail(
...             allowed_recipients=["my_email@company.com"],
...             default_recipients=["my_email@company.com"],
...             default_subject="test default subject",
...         ),
...         comment="This is a comment",
...         enabled=True,
...     ),
...     mode=CreateMode.if_not_exists,
... )
Copy
items() ItemsView[str, T]
iter(*, like: str | None = None) Iterator[NotificationIntegration]

Iterate through NotificationIntegration 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 notification integrations that you have access to see:

>>> notification_integrations = notification_integrations.iter()
Copy

Showing information of the exact notification integration you want to see:

>>> notification_integrations = notification_integrations.iter(like="your-notification-integration-name")
Copy

Showing notification integrations starting with ‘your-notification-integration-name-‘:

>>> notification_integrations = notification_integrations.iter(like="your-notification-integration-name-%")
Copy

Using a for-loop to retrieve information from iterator:

>>> for notification_integration in notification_integrations:
>>>     print(
...         notification_integration.name,
...         notification_integration.enabled,
...         repr(notification_integration.notification_hook),
...     )
Copy
keys() KeysView[str]
values() ValuesView[T]
Language: English