herostools.actor.webhook¶
Classes¶
HERODataArchiver that renders metadata and payload into a JSON template |
Module Contents¶
- class herostools.actor.webhook.HEROWebhookSender(webhook_url: str, body_template: str, request_timeout: float = 10, *args, **kwargs)[source]¶
Bases:
herostools.actor.archiver.base.HERODataArchiverHERODataArchiver that renders metadata and payload into a JSON template and posts them to an arbitrary incoming-webhook endpoint.
Works with any webhook-compatible platform (Slack, Mattermost, Discord, MS Teams, …) since the payload format is fully defined by the template.
- Parameters:
object_selector – Zenoh object selector for the devices to subscribe to.
event_name – Name of the event.
webhook_url – Full URL of the incoming webhook endpoint.
default_metadata – Default metadata merged with every incoming payload’s metadata.
body_template – Template for POST message body as JSON string rendered with Jinja2, using the payload and metadata as template variables (e.g.
'{"text": {{ payload.value | tojson }}}'). Rendering payload only works, if it is json serializable.max_retries – Number of times to retry a failed delivery before dropping the item.
request_timeout – Timeout in seconds for the POST request to the webhook endpoint.
- _payload_in_template¶
- _webhook_url¶
- _template¶
- request_timeout = 10¶