-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
NetBox version
v4.3.5
Feature type
New functionality
Proposed functionality
Implement a mechanism by which plugins can contribute additional data to outbound webhooks generated in response to an event rule. This mechanism would enable a plugin to register a callback function to be called whenever a webhook is being generated. The callback would accept the object and current request, and return any data to be included in the webhook's payload.
Something like this:
@webhook_data(models=(Site, Location))
def my_plugins_callback(instance, request):
if instance.tenant is not None:
return {
'billing_id': Customer.objects.get(tenant=instance.tenant)
}
Any data returned by the callback will be attached to the webhook payload, e.g. within a context
key on the JSON object root. (An empty response will be ignored.)
This should be implemented in a way so as not to break the current format of a webhook payload.
Use case
One example where this would be useful is in the netbox-branching plugin, where it would be helpful to attach the branch in which a change is being made as context. (See netboxlabs/netbox-branching#132 for some discussion around this use case.) However, it's not difficult to image other scenarios where this would be convenient.
Database changes
N/A
External dependencies
N/A