from datetime import datetime, timezone from typing import Any from pydantic import BaseModel, ConfigDict, Field class ImageRecord(BaseModel): fullres_image: str preview_image: str order_index: int = 0 class CarRecord(BaseModel): parser_id: str brand: str model: str year: int | None = None price: int | None = None currency: str = "USD" mileage: int = 0 country: str = "US" is_sold: bool = False color: str = "other" drive: str | None = None gearbox: str | None = None steering_wheel: str | None = None body_type: str = "OTHER" engine_volume: int | None = None selling_type: str = "AUCTION" one_owner: bool = False new_car: bool = False is_hidden: bool = False origin: str = "NA" origin_url: str origin_id: str is_damaged: bool = False evaluation: str | None = None non_smoking: bool = True rental: bool = False repair_history: bool = False slug: str last_seen_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc)) content_hash: str = "" images: list[ImageRecord] = Field(default_factory=list) raw_attributes: dict[str, Any] = Field(default_factory=dict) mapping_notes: list[str] = Field(default_factory=list) class CarRead(BaseModel): # Ответ API по авто. model_config = ConfigDict(from_attributes=True) id: int parser_id: str brand: str model: str year: int | None = None price: int | None = None currency: str = "USD" mileage: int = 0 country: str = "US" is_sold: bool = False color: str = "other" drive: str | None = None gearbox: str | None = None steering_wheel: str | None = None body_type: str = "OTHER" engine_volume: int | None = None selling_type: str = "AUCTION" origin: str = "NA" origin_url: str = "" origin_id: str = "" is_damaged: bool = False slug: str = "" last_seen_at: datetime | None = None created_at: datetime | None = None updated_at: datetime | None = None