[Phase 4] Add NetBox webhook receiver (FastAPI) #17

Closed
opened 2025-12-21 13:03:47 +00:00 by Damien · 2 comments
Owner

Description

Build a FastAPI server to receive NetBox webhooks when intent changes, triggering automatic reconciliation.

Tasks

  • Create FastAPI application structure
  • Implement webhook endpoint for NetBox events
  • Parse NetBox webhook payload (device updated, config context changed)
  • Trigger reconciliation for affected devices
  • Add authentication/validation for webhook requests
  • Implement rate limiting to prevent webhook storms

Webhook Events to Handle

  • device.updated - Device configuration changed
  • config_context.updated - Intent data changed
  • config_context.created - New intent added
  • config_context.deleted - Intent removed

API Endpoints

@app.post("/webhook/netbox")
async def netbox_webhook(payload: NetBoxWebhook):
    """Receive NetBox webhook and trigger reconciliation"""
    
@app.get("/api/health")
async def health_check():
    """Health check endpoint"""
    
@app.get("/api/status")
async def get_status():
    """Get orchestrator status and recent events"""

NetBox Webhook Configuration

URL: https://orchestrator.example.com/webhook/netbox
HTTP Method: POST
HTTP Content Type: application/json
Events: device updated, config context updated

Output

  • src/api.py
## Description Build a FastAPI server to receive NetBox webhooks when intent changes, triggering automatic reconciliation. ## Tasks - [ ] Create FastAPI application structure - [ ] Implement webhook endpoint for NetBox events - [ ] Parse NetBox webhook payload (device updated, config context changed) - [ ] Trigger reconciliation for affected devices - [ ] Add authentication/validation for webhook requests - [ ] Implement rate limiting to prevent webhook storms ## Webhook Events to Handle - `device.updated` - Device configuration changed - `config_context.updated` - Intent data changed - `config_context.created` - New intent added - `config_context.deleted` - Intent removed ## API Endpoints ```python @app.post("/webhook/netbox") async def netbox_webhook(payload: NetBoxWebhook): """Receive NetBox webhook and trigger reconciliation""" @app.get("/api/health") async def health_check(): """Health check endpoint""" @app.get("/api/status") async def get_status(): """Get orchestrator status and recent events""" ``` ## NetBox Webhook Configuration ```yaml URL: https://orchestrator.example.com/webhook/netbox HTTP Method: POST HTTP Content Type: application/json Events: device updated, config context updated ``` ## Output - `src/api.py`
Damien added the phase-4-event-driven label 2025-12-21 13:03:54 +00:00
Author
Owner

🔄 Migration vers Kestra

Cette issue est désormais obsolète suite à la décision d'utiliser Kestra comme plateforme d'orchestration.

Remplacement

Kestra gère nativement les webhooks via le trigger io.kestra.plugin.core.trigger.Webhook :

triggers:
  - id: netbox_webhook
    type: io.kestra.plugin.core.trigger.Webhook
    key: "{{ secret('NETBOX_WEBHOOK_KEY') }}"

Avantages

  • Pas de code à maintenir (FastAPI)
  • UI intégrée pour voir les exécutions déclenchées
  • Gestion native des secrets
  • Retry automatique configurable

Voir la nouvelle issue #24 pour l'implémentation Kestra.

## 🔄 Migration vers Kestra Cette issue est désormais **obsolète** suite à la décision d'utiliser [Kestra](https://kestra.io) comme plateforme d'orchestration. ### Remplacement Kestra gère nativement les webhooks via le trigger `io.kestra.plugin.core.trigger.Webhook` : ```yaml triggers: - id: netbox_webhook type: io.kestra.plugin.core.trigger.Webhook key: "{{ secret('NETBOX_WEBHOOK_KEY') }}" ``` ### Avantages - Pas de code à maintenir (FastAPI) - UI intégrée pour voir les exécutions déclenchées - Gestion native des secrets - Retry automatique configurable Voir la nouvelle issue #24 pour l'implémentation Kestra.
Author
Owner

🔄 Clôture - Migration vers Kestra

Cette issue est obsolète suite à la migration vers Kestra comme moteur d'orchestration.

Raison

Kestra fournit nativement des webhooks triggers via io.kestra.plugin.core.trigger.Webhook, ce qui rend inutile le développement d'un serveur FastAPI custom.

Remplacement

triggers:
  - id: netbox_webhook
    type: io.kestra.plugin.core.trigger.Webhook
    key: "{{ secret('NETBOX_WEBHOOK_KEY') }}"

Voir la nouvelle issue [Phase 4] Kestra - Create NetBox webhook workflow pour l'implémentation.

## 🔄 Clôture - Migration vers Kestra Cette issue est **obsolète** suite à la migration vers [Kestra](https://kestra.io) comme moteur d'orchestration. ### Raison Kestra fournit nativement des **webhooks triggers** via `io.kestra.plugin.core.trigger.Webhook`, ce qui rend inutile le développement d'un serveur FastAPI custom. ### Remplacement ```yaml triggers: - id: netbox_webhook type: io.kestra.plugin.core.trigger.Webhook key: "{{ secret('NETBOX_WEBHOOK_KEY') }}" ``` Voir la nouvelle issue **[Phase 4] Kestra - Create NetBox webhook workflow** pour l'implémentation.
Sign in to join this conversation.