55 lines
1.0 KiB
Python

from typing import Optional, List
from pydantic import BaseModel
from app.schemas.song import Song
# Shared properties
class PlaylistBase(BaseModel):
name: Optional[str] = None
description: Optional[str] = None
is_public: Optional[bool] = True
cover_image_path: Optional[str] = None
# Properties to receive on playlist creation
class PlaylistCreate(PlaylistBase):
name: str
# Properties to receive on playlist update
class PlaylistUpdate(PlaylistBase):
pass
class PlaylistInDBBase(PlaylistBase):
id: int
name: str
user_id: int
class Config:
from_attributes = True
# Properties to return to client
class Playlist(PlaylistInDBBase):
pass
# Properties to return with songs included
class PlaylistWithSongs(Playlist):
songs: List[Song] = []
# Properties stored in DB
class PlaylistInDB(PlaylistInDBBase):
pass
# For adding/removing songs from playlist
class PlaylistSongAdd(BaseModel):
song_id: int
class PlaylistSongRemove(BaseModel):
song_id: int