Notifications

Base notification

class hammurabi.notifications.base.Notification(recipients: List[str], message_template: str)[source]

A git push notification which serves as a base for different kind of notifications like Slack or E-mail notification.

Slack notification

class hammurabi.notifications.slack.SlackNotification(recipients: List[str], message_template: str)[source]

Send slack notification through Slack webhooks.

Example usage:

>>> from pathlib import Path
>>> from hammurabi import Law, Pillar, Renamed, IsDirectoryExist, SlackNotification
>>>
>>> example_law = Law(
>>>     name="Name of the law",
>>>     description="Well detailed description what this law does.",
>>>     rules=(
>>>         Renamed(
>>>             name="Rename the dir if an other one exists",
>>>             path=Path("old-name"),
>>>             new_name="new-name",
>>>             preconditions=[
>>>                 IsDirectoryExist(path=Path("other-dir"))
>>>             ]
>>>         ),
>>>     )
>>> )
>>>
>>> pillar = Pillar(notifications=[
>>>     SlackNotification(
>>>         recipients=["https://slack.webhook.url"],
>>>         message_template="Dear team, the {repository} has new update.",
>>>     )
>>> ])
>>> pillar.register(example_law)

Warning

This notification requires the slack-notifications extra to be installed.