Add comprehensive backend features and mobile UI improvements
Backend: - Add 2FA authentication with TOTP support - Add API keys management system - Add audit logging for security events - Add file upload/management system - Add notifications system with preferences - Add session management - Add webhooks integration - Add analytics endpoints - Add export functionality - Add password policy enforcement - Add new database migrations for core tables Frontend: - Add module position system (top/bottom sidebar sections) - Add search and notifications module configuration tabs - Add mobile logo replacing hamburger menu - Center page title absolutely when no tabs present - Align sidebar footer toggles with navigation items - Add lighter icon color in dark theme for mobile - Add API keys management page - Add notifications page with context - Add admin analytics and audit logs pages 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
98
backend/app/schemas/webhook.py
Normal file
98
backend/app/schemas/webhook.py
Normal file
@@ -0,0 +1,98 @@
|
||||
"""Webhook schemas."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional, List
|
||||
from pydantic import BaseModel, HttpUrl, Field
|
||||
|
||||
|
||||
# Webhook Base
|
||||
class WebhookBase(BaseModel):
|
||||
"""Base webhook schema."""
|
||||
name: str = Field(..., min_length=1, max_length=100)
|
||||
url: str = Field(..., min_length=1, max_length=500)
|
||||
events: List[str] = Field(default=["*"])
|
||||
is_active: bool = True
|
||||
retry_count: int = Field(default=3, ge=0, le=10)
|
||||
timeout_seconds: int = Field(default=30, ge=5, le=120)
|
||||
|
||||
|
||||
class WebhookCreate(WebhookBase):
|
||||
"""Schema for creating a webhook."""
|
||||
pass
|
||||
|
||||
|
||||
class WebhookUpdate(BaseModel):
|
||||
"""Schema for updating a webhook."""
|
||||
name: Optional[str] = Field(None, min_length=1, max_length=100)
|
||||
url: Optional[str] = Field(None, min_length=1, max_length=500)
|
||||
events: Optional[List[str]] = None
|
||||
is_active: Optional[bool] = None
|
||||
retry_count: Optional[int] = Field(None, ge=0, le=10)
|
||||
timeout_seconds: Optional[int] = Field(None, ge=5, le=120)
|
||||
|
||||
|
||||
class Webhook(WebhookBase):
|
||||
"""Webhook response schema."""
|
||||
id: str
|
||||
secret: Optional[str] = None
|
||||
created_by: Optional[str] = None
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
last_triggered_at: Optional[datetime] = None
|
||||
success_count: int
|
||||
failure_count: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class WebhookWithSecret(Webhook):
|
||||
"""Webhook response with secret (for creation)."""
|
||||
secret: str
|
||||
|
||||
|
||||
# Webhook Delivery
|
||||
class WebhookDeliveryBase(BaseModel):
|
||||
"""Base webhook delivery schema."""
|
||||
webhook_id: str
|
||||
event_type: str
|
||||
payload: str
|
||||
|
||||
|
||||
class WebhookDelivery(WebhookDeliveryBase):
|
||||
"""Webhook delivery response schema."""
|
||||
id: str
|
||||
status: str
|
||||
status_code: Optional[int] = None
|
||||
response_body: Optional[str] = None
|
||||
error_message: Optional[str] = None
|
||||
attempt_count: int
|
||||
next_retry_at: Optional[datetime] = None
|
||||
created_at: datetime
|
||||
delivered_at: Optional[datetime] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# Event types
|
||||
WEBHOOK_EVENTS = [
|
||||
"user.created",
|
||||
"user.updated",
|
||||
"user.deleted",
|
||||
"user.login",
|
||||
"user.logout",
|
||||
"user.password_changed",
|
||||
"user.2fa_enabled",
|
||||
"user.2fa_disabled",
|
||||
"settings.updated",
|
||||
"api_key.created",
|
||||
"api_key.revoked",
|
||||
"*", # All events
|
||||
]
|
||||
|
||||
|
||||
class WebhookTest(BaseModel):
|
||||
"""Schema for testing a webhook."""
|
||||
event_type: str = "test.ping"
|
||||
payload: Optional[dict] = None
|
||||
Reference in New Issue
Block a user