Slack
Classes to ease interaction with Slack
koheesio.notifications.slack.SlackNotification #
Generic Slack notification class via the Blocks
API
NOTE:
channel
parameter is used only with Slack Web API: https://api.slack.com/messaging/sending If webhook is used, the channel specification is not required
Example:
s = SlackNotification(
url="slack-webhook-url",
channel="channel",
message="Some *markdown* compatible text",
)
s.execute()
channel
class-attribute
instance-attribute
#
headers
class-attribute
instance-attribute
#
message
class-attribute
instance-attribute
#
message: str = Field(
default=...,
description="The message that gets posted to Slack",
)
execute #
get_payload #
get_payload() -> str
Generate payload with Block Kit
.
More details: https://api.slack.com/block-kit
Source code in src/koheesio/notifications/slack.py
koheesio.notifications.slack.SlackNotificationWithSeverity #
Slack notification class via the Blocks
API with etra severity information and predefined extra fields
Example: from koheesio.steps.integrations.notifications import NotificationSeverity
s = SlackNotificationWithSeverity(
url="slack-webhook-url",
channel="channel",
message="Some *markdown* compatible text"
severity=NotificationSeverity.ERROR,
title="Title",
environment="dev",
application="Application"
)
s.execute()
application
class-attribute
instance-attribute
#
application: str = Field(
default=..., description="Pipeline or application name"
)
environment
class-attribute
instance-attribute
#
environment: str = Field(
default=...,
description="Environment description, e.g. dev / qa /prod",
)
severity
class-attribute
instance-attribute
#
severity: NotificationSeverity = Field(
default=..., description="Severity of the message"
)
timestamp
class-attribute
instance-attribute
#
timestamp: datetime = Field(
default_factory=utc_now,
alias="execution_timestamp",
description="Pipeline or application execution timestamp",
)
title
class-attribute
instance-attribute
#
title: str = Field(
default=..., description="Title of your message"
)
execute #
get_payload_message #
get_payload_message() -> str
Generate payload message based on the predefined set of parameters