https://dev.kronoz.win/r/marzneshin.git
1from pydantic import ConfigDict, BaseModel, Field
2
3
4class Service(BaseModel):
5 id: int | None = None
6 name: str | None = Field(None)
7 model_config = ConfigDict(from_attributes=True)
8
9
10class ServiceCreate(Service):
11 inbound_ids: list[int] = Field([])
12 model_config = ConfigDict(
13 json_schema_extra={
14 "example": {
15 "name": "my service 1",
16 "inbound_ids": [1, 5, 9],
17 }
18 }
19 )
20
21
22class ServiceModify(Service):
23 inbound_ids: list[int] | None = Field(None)
24 model_config = ConfigDict(
25 json_schema_extra={
26 "example": {
27 "id": 2,
28 "name": "my service 2",
29 "inbound_ids": [1, 2, 3],
30 }
31 }
32 )
33
34
35class ServiceResponse(Service):
36 inbound_ids: list[int]
37 user_ids: list[int]
38
39 model_config = ConfigDict(from_attributes=True)