File size: 1,375 Bytes
9e798a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from pydantic import BaseModel, Field, HttpUrl
from typing import List, Optional


class BaseResponse(BaseModel):
    code: int
    message: str
    payload: Optional[dict] = None


# Create Portal Request
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",
            }
        }


# Update Portal Request
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")


# Portal Response
class PortalResponse(BaseModel):
    id: int
    name: str
    description: str
    url: HttpUrl

    class Config:
        orm_mode = True


# List of Portals Response
class PortalListResponse(BaseModel):
    portals: List[PortalResponse]
    total_count: int

    class Config:
        orm_mode = True