46 lines
921 B
Python
46 lines
921 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class SongBase(BaseModel):
|
|
title: str
|
|
artist_id: str
|
|
album_id: Optional[str] = None
|
|
genre: Optional[str] = None
|
|
track_number: Optional[int] = None
|
|
duration: Optional[float] = None
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class SongCreate(SongBase):
|
|
file_path: str
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class SongUpdate(SongBase):
|
|
title: Optional[str] = None
|
|
artist_id: Optional[str] = None
|
|
file_path: Optional[str] = None
|
|
|
|
|
|
class SongInDBBase(SongBase):
|
|
id: str
|
|
file_path: str
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Additional properties to return via API
|
|
class Song(SongInDBBase):
|
|
pass
|
|
|
|
|
|
# Additional properties stored in DB
|
|
class SongInDB(SongInDBBase):
|
|
pass |