|
from pydantic import BaseModel, Field, HttpUrl |
|
from typing import List, Optional |
|
|
|
|
|
class BaseResponse(BaseModel): |
|
code: int |
|
message: str |
|
payload: Optional[dict] = None |
|
|
|
|
|
|
|
class CreatePortalRequest(BaseModel): |
|
name: str = Field( |
|
..., max_length=50, description="Name of the portal, e.g., Android or MikroTik" |
|
) |
|
description: str = Field( |
|
..., max_length=255, description="Description of the portal" |
|
) |
|
url: HttpUrl = Field(..., description="URL of the portal") |
|
|
|
class Config: |
|
schema_extra = { |
|
"example": { |
|
"name": "Android", |
|
"description": "Official Android developer portal", |
|
"url": "https://developer.android.com", |
|
} |
|
} |
|
|
|
|
|
|
|
class UpdatePortalRequest(BaseModel): |
|
description: Optional[str] = Field( |
|
None, max_length=255, description="Updated description of the portal" |
|
) |
|
url: Optional[HttpUrl] = Field(None, description="Updated URL of the portal") |
|
|
|
|
|
|
|
class PortalResponse(BaseModel): |
|
id: int |
|
name: str |
|
description: str |
|
url: HttpUrl |
|
|
|
class Config: |
|
orm_mode = True |
|
|
|
|
|
|
|
class PortalListResponse(BaseModel): |
|
portals: List[PortalResponse] |
|
total_count: int |
|
|
|
class Config: |
|
orm_mode = True |
|
|