Files
iptv-manager-service/app/models/schemas.py
Stefano 8c7ed421c9
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m7s
Using Optional[str] instead of str | None for optional fields
2025-05-23 11:49:13 -05:00

53 lines
1.3 KiB
Python

from datetime import datetime
from typing import List, Optional
from uuid import UUID
from pydantic import BaseModel
class ChannelURLCreate(BaseModel):
"""Pydantic model for creating channel URLs"""
url: str
class ChannelURLBase(ChannelURLCreate):
"""Base Pydantic model for channel URL responses"""
id: UUID
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
class ChannelURLResponse(ChannelURLBase):
"""Pydantic model for channel URL responses"""
pass
class ChannelCreate(BaseModel):
"""Pydantic model for creating channels"""
urls: List[str] # List of URLs to create with the channel
name: str
group_title: str
tvg_id: str
tvg_logo: str
tvg_name: str
class ChannelUpdate(BaseModel):
"""Pydantic model for updating channels"""
name: Optional[str] = None
group_title: Optional[str] = None
tvg_id: Optional[str] = None
tvg_logo: Optional[str] = None
tvg_name: Optional[str] = None
class ChannelResponse(BaseModel):
"""Pydantic model for channel responses"""
id: UUID
name: str
group_title: str
tvg_id: str
tvg_logo: str
tvg_name: str
urls: List[ChannelURLResponse] # List of URL objects without channel_id
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True