Files
PaskaJoululeffa2024-backend/src/models/movie.py
T

41 lines
1.3 KiB
Python

from pydantic import BaseModel, Field
from datetime import datetime, date
from typing import Optional
class MovieBase(BaseModel):
name: Optional[str] | None = Field(
None, description="Name of the movie", examples=["A Maple Valley Christmas"]
)
imdb_id: str = Field(description="IMDB ID of the movie", examples=["tt1234567"])
showtime: date = Field(description="Showtime of the movie", examples=["2024-12-01"])
plot: str = Field(
description="Plot of the movie", examples=["Erica is a rancher..."]
)
class MovieIn(MovieBase):
actors: Optional[list[str]] | None = Field(
None,
description="Actors of the movie",
examples=[["Peyton List", "Andrew W. Walker"]],
)
release_date: datetime | None = Field(
None, description="Release date of the movie", examples=["2022-11-05"]
)
poster_url: str | None = Field(
None, description="Poster URL of the movie", examples=["https://..."]
)
class Movie(MovieIn):
id: Optional[str] = Field(
default=None, examples=["123e4567-e89b-12d3-a456-426655440000"]
)
created_at: datetime = Field(
default_factory=datetime.utcnow, description="Creation date of the movie"
)
modified_at: datetime = Field(
default_factory=datetime.utcnow, description="Modification date of the movie"
)