Webhooks

Webhooks are triggered after Netpicker completes a process. Use the {{ __ctx__ }} tag in the webhook template to get the results as dictionary or use the {{ __ctx__ | tojson }} tag to get the results of the process in JSON format.

Watch this video for a quick guide:

Webhook callback request content

The __ctx__ variable has two properties: event and payload, where the type of the latter depends on the event.

finish:backup-config

The payload is a dictionary of ipaddress keys of devices and value the summary of the configuration fetched.

{
“event”: “finish:backup-config”,
“payload”: {
“192.168.60.190”: {
“id”: “183901632300949504”,
“changed”: False,
“upload_date”: “2024-05-22T11:19:25.863658”,
“file_size”: 10774,
“digest”: “3a616657755a8c66b5dc8f237fc2f8b5027d7e6eddbede818298c41a62531d76”,
“commit”: “6493afb1f1007651551de6c4f9ada34890cb823e”
}}}

In case a backup fails, the value for a device will be None (null when converted to JSON):

{
“event”: “finish:backup-config”,
“payload”: {
“192.168.60.190”: null
}
}

Webhoook templates

You can use Jinja template syntax to write custom templates for your webhooks, for example:

{“text”: “Config backup\n\n{% for d in __ctx__[‘payload’] %}{{ d }} – {% if __ctx__[‘payload’][d] %}Changed: {{ __ctx__[‘payload’][d][‘changed’] }}{% else %}Backup failed{% endif %}\n{% endfor %}”}

Which will result in this output:

Config backup

192.168.60.201 – Changed: False
192.168.60.202 – Changed: False
172.21.0.3 – Backup failed

finish:execute-rules

The payload returns the filter criteria for devices, policies, rules and tags, and the summary of the results from executing the policies.

{
“event”: “finish:execute-rules”,
“payload”: {
“results”: [
{ “192.168.60.190”: {
“MEDIUM”: 3,
“SUCCESS”: 3
}
}
],
“initiator”: “[[email protected]](mailto:[email protected])”,
“devices”: [“192.168.60.190”],
“policies”: [],
“rules”: [],
“tags”: [],
“batch_id”: “28819c59-5788-48d0-a377-02ed9b3a9a98”
}}

Would you like a hands-on session?

A couple times a week our in-house trainer is available for a private or group session. In this session we can cover our Slurp’it or Mock’it solution but also integrations with Netpicker, NetBox, Nautobot & Infrahub.

Yes, keep me informed

Connect with us on LinkedIn to stay updated on the latest happenings, news, and exciting developments at Slurp’it. Just click the button below to follow us and be a part of our professional network.

Newsletter