67 lines
1.5 KiB
Python
67 lines
1.5 KiB
Python
from typing import Annotated
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from .contact import Contact
|
|
from .status import Status
|
|
|
|
|
|
class Location(BaseModel):
|
|
id: int
|
|
code: str
|
|
description: str | None
|
|
notes: str | None
|
|
status: Status
|
|
contact: Contact | None
|
|
|
|
class LocationCreate(BaseModel):
|
|
code: str = Field(max_length=30)
|
|
description: Annotated[str | None, Field(max_length=80)] = None
|
|
notes: str | None = None
|
|
|
|
class LocationUpdate(LocationCreate):
|
|
code: Annotated[str | None, Field(max_length=30)] = None
|
|
|
|
|
|
class LocationCode(BaseModel):
|
|
id: int
|
|
code: str
|
|
description: str | None
|
|
notes: str | None
|
|
status: Status
|
|
locations: list[Location]
|
|
contact: Contact | None
|
|
|
|
class LocationCodeCreate(BaseModel):
|
|
code: str = Field(max_length=8)
|
|
description: Annotated[str | None, Field(max_length=80)] = None
|
|
notes: str | None = None
|
|
locations: list[LocationCreate] | None = None
|
|
|
|
|
|
|
|
class Country(BaseModel):
|
|
id: int
|
|
code: str
|
|
name: str
|
|
notes: str | None
|
|
status: Status
|
|
location_codes: list[LocationCode] | None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CountryCreate(BaseModel):
|
|
code: str = Field(max_length=2)
|
|
name: str = Field(max_length=80)
|
|
notes: str | None = None
|
|
location_codes: list[LocationCodeCreate] | None = None
|
|
|
|
|
|
class CountryUpdate(BaseModel):
|
|
code: str | None = Field(default=None, max_length=2)
|
|
name: str | None = Field(default=None, max_length=80)
|
|
notes: str | None = None
|