[PR #20025] [MERGED] Closes #20003: Introduce mechanism to register callbacks for webhook context #15800

Closed
opened 2025-12-30 00:24:08 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20025
Author: @jeremystretch
Created: 8/5/2025
Status: Merged
Merged: 8/7/2025
Merged by: @jeremystretch

Base: featureHead: 20003-webhook-context


📝 Commits (6)

  • b24d302 Closes #20003: Introduce mechanism to register callbacks for webhook context
  • 55f5b15 Swap ContentType with ObjectType
  • 86ad4e6 Add plugin dev documentation for webhook callbacks
  • 28a7101 Merge branch 'feature' into 20003-webhook-context
  • fb9f053 Fix tests
  • c9067ec Add note about namespacing webhook data

📊 Changes

10 files changed (+153 additions, -25 deletions)

View changed files

docs/plugins/development/webhooks.md (+75 -0)
📝 mkdocs.yml (+1 -0)
📝 netbox/core/signals.py (+2 -2)
📝 netbox/extras/events.py (+13 -10)
📝 netbox/extras/tests/test_event_rules.py (+14 -9)
📝 netbox/extras/webhooks.py (+31 -3)
📝 netbox/netbox/registry.py (+1 -0)
📝 netbox/netbox/tests/dummy_plugin/__init__.py (+1 -1)
netbox/netbox/tests/dummy_plugin/webhook_callbacks.py (+8 -0)
📝 netbox/netbox/tests/test_plugins.py (+7 -0)

📄 Description

Closes: #20003

  • Simplify the signature of enqueue_event() to pass the request object directly (instead of the user & request ID)
  • Attach the request object to the event when it is enqueued for processing
  • Alter the signature of process_event_rules() to take a request object rather than a request ID
  • Alter the parameters recorded for send_webhook tasks
    • Replace model_name with object_type
    • Add request if present
  • Introduce the process_event_rules() function for use by plugins
    • Add webhook_callbacks to the NetBox registry
  • Extend send_webhook() to gather additional context data from registered webhook callbacks
  • Update event tests

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/20025 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 8/5/2025 **Status:** ✅ Merged **Merged:** 8/7/2025 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `20003-webhook-context` --- ### 📝 Commits (6) - [`b24d302`](https://github.com/netbox-community/netbox/commit/b24d30261c056b66f295576f4363d4803f58917f) Closes #20003: Introduce mechanism to register callbacks for webhook context - [`55f5b15`](https://github.com/netbox-community/netbox/commit/55f5b15af372b432a5283410787fef1d24c8accf) Swap ContentType with ObjectType - [`86ad4e6`](https://github.com/netbox-community/netbox/commit/86ad4e6d25d5716f70ad10b5da09d6157aa82c4e) Add plugin dev documentation for webhook callbacks - [`28a7101`](https://github.com/netbox-community/netbox/commit/28a71011981c7e9e4124c01d527834d5fab67a2a) Merge branch 'feature' into 20003-webhook-context - [`fb9f053`](https://github.com/netbox-community/netbox/commit/fb9f053257b7a4af5f332da22e3d4a8587d956f4) Fix tests - [`c9067ec`](https://github.com/netbox-community/netbox/commit/c9067ec4bb5c14021a4eb16407d9e9f994ce194f) Add note about namespacing webhook data ### 📊 Changes **10 files changed** (+153 additions, -25 deletions) <details> <summary>View changed files</summary> ➕ `docs/plugins/development/webhooks.md` (+75 -0) 📝 `mkdocs.yml` (+1 -0) 📝 `netbox/core/signals.py` (+2 -2) 📝 `netbox/extras/events.py` (+13 -10) 📝 `netbox/extras/tests/test_event_rules.py` (+14 -9) 📝 `netbox/extras/webhooks.py` (+31 -3) 📝 `netbox/netbox/registry.py` (+1 -0) 📝 `netbox/netbox/tests/dummy_plugin/__init__.py` (+1 -1) ➕ `netbox/netbox/tests/dummy_plugin/webhook_callbacks.py` (+8 -0) 📝 `netbox/netbox/tests/test_plugins.py` (+7 -0) </details> ### 📄 Description ### Closes: #20003 - Simplify the signature of `enqueue_event()` to pass the request object directly (instead of the user & request ID) - Attach the request object to the event when it is enqueued for processing - Alter the signature of `process_event_rules()` to take a request object rather than a request ID - Alter the parameters recorded for `send_webhook` tasks - Replace `model_name` with `object_type` - Add `request` if present - Introduce the `process_event_rules()` function for use by plugins - Add `webhook_callbacks` to the NetBox registry - Extend `send_webhook()` to gather additional context data from registered webhook callbacks - Update event tests --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:24:08 +01:00
adam closed this issue 2025-12-30 00:24:08 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15800