hammurabi.notifications package¶
Submodules¶
hammurabi.notifications.base module¶
Notifications are responsible for letting the end users/owners that a change happened on a git repository. Notifications describes where to send the notification but not responsible for delivering it. For example, you can use an email notification method, but the notification method is not responsible for handling emails and delivering the message.
-
class
hammurabi.notifications.base.Notification(recipients: List[str], message_template: str)[source]¶ Bases:
abc.ABCA
git pushnotification which serves as a base for different kind of notifications like Slack or E-mail notification.
hammurabi.notifications.slack module¶
Send notification to a slack channel when Hammurabi creates/updates a pull request.
-
class
hammurabi.notifications.slack.SlackNotification(recipients: List[str], message_template: str)[source]¶ Bases:
hammurabi.notifications.base.NotificationSend 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-notificationsextra to be installed.