Slack Notifications¶
These functions handle the processing of Jamf Pro webhook events to Slack notifications.
-
jackalope.routes.jamfpro.webhooks.
webhook_notification
(webhook)¶ Takes a Jamf Pro webhook event object and returns a formatted Slack message from the details if it is in the supported webhook events list.
If the webhook event is not supported
None
will be returned.Parameters: webhook – Jamf Pro webhook JSON as dictionary. Returns: Formatted Slack message. Return type: dict or None
-
jackalope.routes.jamfpro.webhooks.
_message
(text, title, title_link=None, color='gray', fallback_text=None, image=None, fields=None)¶ Create a Slack formatted message to use with
jackalope.slack.send_notification()
.Parameters: - text (str) – The main text to display in the message.
- title (str) – The title of the message.
- title_link (str) – An optional URL to pass that will convert the title into a clickable link.
- color (str) – The color to display in the sidebar of the message. Must
be of a value in the
_colors
dictionary or will default togray
. - fallback_text (str) – Alternative text to display in place of the
provided
text
value. If not submitted this will be set to the value oftext
. - image (str) – The filename of an image located in
/static/images/
to link to with the message. If not submitted this will be set togeneral_64.png
. - fields (dict) – A dictionary of keyword values to populate the optional
fields
attribute of the Slack message.
-
jackalope.slack.
send_notification
(url, message)¶ Send a formatted Slack message to a channel’s inbound webhook.
Parameters: - url (str) – The URL for a Slack channel’s inbound webhook.
- message (dict) – A formatted Slack message generated by
jackalope.routes.jamfpro.webhooks._message()
.