feat(api): Pydantic schemas + Data Repositories
This commit is contained in:
69
app/schemas/org.py
Normal file
69
app/schemas/org.py
Normal file
@@ -0,0 +1,69 @@
|
||||
"""Organization-related schemas."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Literal
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Field, HttpUrl
|
||||
|
||||
|
||||
class OrgResponse(BaseModel):
|
||||
"""Organization summary response."""
|
||||
|
||||
id: UUID
|
||||
name: str
|
||||
slug: str
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class MemberResponse(BaseModel):
|
||||
"""Organization member response."""
|
||||
|
||||
id: UUID
|
||||
user_id: UUID
|
||||
email: str
|
||||
role: Literal["admin", "member", "viewer"]
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class ServiceCreate(BaseModel):
|
||||
"""Request body for creating a service."""
|
||||
|
||||
name: str = Field(min_length=1, max_length=100)
|
||||
slug: str = Field(
|
||||
min_length=1,
|
||||
max_length=50,
|
||||
pattern=r"^[a-z0-9]+(?:-[a-z0-9]+)*$",
|
||||
description="URL-friendly identifier (lowercase, hyphens allowed)",
|
||||
)
|
||||
|
||||
|
||||
class ServiceResponse(BaseModel):
|
||||
"""Service response."""
|
||||
|
||||
id: UUID
|
||||
name: str
|
||||
slug: str
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class NotificationTargetCreate(BaseModel):
|
||||
"""Request body for creating a notification target."""
|
||||
|
||||
name: str = Field(min_length=1, max_length=100)
|
||||
target_type: Literal["webhook", "email", "slack"]
|
||||
webhook_url: HttpUrl | None = Field(
|
||||
default=None, description="Required for webhook type"
|
||||
)
|
||||
enabled: bool = True
|
||||
|
||||
|
||||
class NotificationTargetResponse(BaseModel):
|
||||
"""Notification target response."""
|
||||
|
||||
id: UUID
|
||||
name: str
|
||||
target_type: Literal["webhook", "email", "slack"]
|
||||
webhook_url: str | None
|
||||
enabled: bool
|
||||
created_at: datetime
|
||||
Reference in New Issue
Block a user