Files
leocrm/app/schemas/webhook.py
T
Agent Zero 79ece0fe2e Phase 4: Webhooks, Backup/Restore UI, Onboarding/Tutorial
- Webhooks Backend: model, schema, service (HMAC-SHA256, httpx), routes, event bus dispatcher, migration 0042
- Webhooks Frontend: SettingsWebhooksPage (CRUD, test button, event multi-select), API client
- Backup/Restore Backend: model, schema, service (pg_dump/pg_restore), routes (admin-only), migration 0043
- Backup/Restore Frontend: SettingsBackupPage (create, list, restore dialog with RESTORE confirmation, auto-refresh)
- Onboarding: OnboardingTour (8 steps, custom CSS overlay), WelcomeDialog, onboardingStore (zustand + localStorage)
- Onboarding integrated into AppShell
- Routes: /settings/webhooks, /settings/backup registered
- Settings nav: Webhooks, Backup & Restore entries added
- Migration conflict fixed: 0042_webhooks → 0043_backups chain
2026-07-26 03:17:40 +02:00

50 lines
1.7 KiB
Python

"""Pydantic schemas for Webhook CRUD."""
from __future__ import annotations
import uuid
from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
class WebhookCreate(BaseModel):
"""Schema for creating a new webhook."""
url: str = Field(..., min_length=1, max_length=500, description="Target URL for the webhook")
events: list[str] = Field(..., min_length=1, description="List of event names to subscribe to")
secret: str | None = Field(default=None, max_length=255, description="HMAC secret for payload signing")
is_active: bool = Field(default=True, description="Whether the webhook is active")
retry_count: int = Field(default=3, ge=0, le=10, description="Number of retry attempts on failure")
timeout_seconds: int = Field(default=30, ge=1, le=120, description="Request timeout in seconds")
class WebhookUpdate(BaseModel):
"""Schema for updating an existing webhook."""
url: str | None = Field(default=None, max_length=500)
events: list[str] | None = Field(default=None, min_length=1)
secret: str | None = Field(default=None, max_length=255)
is_active: bool | None = Field(default=None)
retry_count: int | None = Field(default=None, ge=0, le=10)
timeout_seconds: int | None = Field(default=None, ge=1, le=120)
class WebhookResponse(BaseModel):
"""Schema for returning a webhook."""
model_config = ConfigDict(from_attributes=True)
id: uuid.UUID
tenant_id: uuid.UUID
url: str
events: list[str]
secret: str | None = None
is_active: bool = True
retry_count: int = 3
timeout_seconds: int = 30
created_by: uuid.UUID | None = None
updated_by: uuid.UUID | None = None
created_at: datetime
updated_at: datetime