Web API

Apps

Apps are fastapi.FastAPI instances with different capabilities: each one uses a different subset of Routes, allowing access to different API methods.

Each one can be run independently from the other.

Debug

Error

For some reason, the contents of this module are not displayed.

Dependencies

Models

Models are pydantic.BaseModel that can be received or returned by the API.

Base models

Base models are pydantic.BaseModel that are subclassed by all other models used by Mandarin.

This allows for quick changes to the configuration of all Mandarin models.

class mandarin.webapi.models.a_base.MandarinModel

A model for generic data.

class Config

The default pydantic configuration.

See also

Pydantic Configuration, pydantic.BaseModel.Config

class mandarin.webapi.models.a_base.OrmModel

A model for sqlalchemy table data.

class Config

A configuration which allows for the loading of data from __getattr__ instead of __getitem__.

orm_mode = True

Basic models

Basic models are OrmModel that represent database tables, and contain only the data as it is saved in the database; therefore, these models completely ignore table sqlalchemy.orm.relationship().

class mandarin.webapi.models.b_basic.AlbumInvolvement(*, person_id: int, album_id: int, role_id: int)
person_id: int
album_id: int
role_id: int
class mandarin.webapi.models.b_basic.Album(*, id: int, title: str, description: str)
id: int
title: str
description: str
class mandarin.webapi.models.b_basic.AuditLog(*, id: int, user_id: int, action: str, timestamp: datetime.datetime, obj: int)
id: int
user_id: int
action: str
timestamp: datetime.datetime
obj: int
class mandarin.webapi.models.b_basic.File(*, id: int, uploader_id: int)
id: int
uploader_id: int
class mandarin.webapi.models.b_basic.Genre(*, id: int, name: str, description: str, supergenre_id: int = None)
id: int
name: str
description: str
supergenre_id: Optional[int]
class mandarin.webapi.models.b_basic.Layer(*, id: int, name: str, description: str, song_id: int = None)
id: int
name: str
description: str
song_id: Optional[int]
class mandarin.webapi.models.b_basic.Person(*, id: int, name: str, description: str)
id: int
name: str
description: str
class mandarin.webapi.models.b_basic.Role(*, id: int, name: str, description: str)
id: int
name: str
description: str
class mandarin.webapi.models.b_basic.SongInvolvement(*, person_id: int, song_id: int, role_id: int)
person_id: int
song_id: int
role_id: int
class mandarin.webapi.models.b_basic.Song(*, id: int, title: str, description: str, lyrics: str, disc: pydantic.types.PositiveInt = None, track: pydantic.types.PositiveInt = None, year: int = None, album_id: int = None)
id: int
title: str
description: str
lyrics: str
disc: Optional[pydantic.types.PositiveInt]
track: Optional[pydantic.types.PositiveInt]
year: Optional[int]
album_id: Optional[int]
class mandarin.webapi.models.b_basic.User(*, id: int, sub: str, name: str, nickname: str, picture: str, email: str, email_verified: str, updated_at: str)
id: int
sub: str
name: str
nickname: str
picture: str
email: str
email_verified: str
updated_at: str

Involvement models

Involvement models are OrmModel that represent junction tables or parts of autoassociations (which cannot be represented properly through pydantic).

class mandarin.webapi.models.c_involvements.AlbumInvolvementFromPerson(*, album: mandarin.webapi.models.b_basic.Album, role: mandarin.webapi.models.b_basic.Role)
album: mandarin.webapi.models.b_basic.Album
role: mandarin.webapi.models.b_basic.Role
class mandarin.webapi.models.c_involvements.AlbumInvolvementFromRole(*, person: mandarin.webapi.models.b_basic.Person, album: mandarin.webapi.models.b_basic.Album)
person: mandarin.webapi.models.b_basic.Person
album: mandarin.webapi.models.b_basic.Album
class mandarin.webapi.models.c_involvements.AlbumInvolvementFromAlbum(*, person: mandarin.webapi.models.b_basic.Person, role: mandarin.webapi.models.b_basic.Role)
person: mandarin.webapi.models.b_basic.Person
role: mandarin.webapi.models.b_basic.Role
class mandarin.webapi.models.c_involvements.SongInvolvementFromPerson(*, song: mandarin.webapi.models.b_basic.Song, role: mandarin.webapi.models.b_basic.Role)
song: mandarin.webapi.models.b_basic.Song
role: mandarin.webapi.models.b_basic.Role
class mandarin.webapi.models.c_involvements.SongInvolvementFromRole(*, person: mandarin.webapi.models.b_basic.Person, song: mandarin.webapi.models.b_basic.Song)
person: mandarin.webapi.models.b_basic.Person
song: mandarin.webapi.models.b_basic.Song
class mandarin.webapi.models.c_involvements.SongInvolvementFromSong(*, person: mandarin.webapi.models.b_basic.Person, role: mandarin.webapi.models.b_basic.Role)
person: mandarin.webapi.models.b_basic.Person
role: mandarin.webapi.models.b_basic.Role
class mandarin.webapi.models.c_involvements.GenreTree(*, id: int, name: str, description: str, subgenres: List[GenreTree2])
id: int
name: str
description: str
subgenres: List[mandarin.webapi.models.c_involvements.GenreTree2]

Input models

Input models are OrmModel that represent editable data of database tables.

They are mainly used in PUT methods of the API, which edit the properties of the specified object.

class mandarin.webapi.models.d_inputs.AlbumInvolvementInput(*, person_id: int, album_id: int, role_id: int)
person_id: int
album_id: int
role_id: int
class mandarin.webapi.models.d_inputs.AlbumInput(*, title: str, description: str)
title: str
description: str
class mandarin.webapi.models.d_inputs.AuditLogInput(*, user_id: int, action: str, timestamp: datetime.datetime, obj: int)
user_id: int
action: str
timestamp: datetime.datetime
obj: int
class mandarin.webapi.models.d_inputs.FileInput(*, uploader_id: int)
uploader_id: int
class mandarin.webapi.models.d_inputs.GenreInput(*, name: str, description: str, supergenre_id: int = None)
name: str
description: str
supergenre_id: Optional[int]
class mandarin.webapi.models.d_inputs.LayerInput(*, name: str, description: str, song_id: int = None)
name: str
description: str
song_id: Optional[int]
class mandarin.webapi.models.d_inputs.PersonInput(*, name: str, description: str)
name: str
description: str
class mandarin.webapi.models.d_inputs.RoleInput(*, name: str, description: str)
name: str
description: str
class mandarin.webapi.models.d_inputs.SongInvolvementInput(*, person_id: int, song_id: int, role_id: int)
person_id: int
song_id: int
role_id: int
class mandarin.webapi.models.d_inputs.SongInput(*, title: str, description: str, lyrics: str, disc: pydantic.types.PositiveInt = None, track: pydantic.types.PositiveInt = None, year: int = None, album_id: int = None)
title: str
description: str
lyrics: str
disc: Optional[pydantic.types.PositiveInt]
track: Optional[pydantic.types.PositiveInt]
year: Optional[int]
album_id: Optional[int]

Output models

Output models are OrmModel that represent the full data of database tables.

In them, sqlalchemy.orm.relationship() should be expanded up to 1 layer, and then regular b_basic objects should be used.

They are returned by most methods of the API.

class mandarin.webapi.models.e_outputs.AlbumInvolvementOutput(*, person: mandarin.webapi.models.b_basic.Person, album: mandarin.webapi.models.b_basic.Album, role: mandarin.webapi.models.b_basic.Role)
person: mandarin.webapi.models.b_basic.Person
album: mandarin.webapi.models.b_basic.Album
role: mandarin.webapi.models.b_basic.Role
class mandarin.webapi.models.e_outputs.AlbumOutput(*, id: int, title: str, description: str, songs: List[mandarin.webapi.models.b_basic.Song], involvements: List[mandarin.webapi.models.c_involvements.AlbumInvolvementFromAlbum], genres: List[mandarin.webapi.models.b_basic.Genre])
id: int
title: str
description: str
songs: List[mandarin.webapi.models.b_basic.Song]
involvements: List[mandarin.webapi.models.c_involvements.AlbumInvolvementFromAlbum]
genres: List[mandarin.webapi.models.b_basic.Genre]
class mandarin.webapi.models.e_outputs.AuditLogOutput(*, id: int, user: mandarin.webapi.models.b_basic.User, action: str, timestamp: datetime.datetime, obj: int)
id: int
user: mandarin.webapi.models.b_basic.User
action: str
timestamp: datetime.datetime
obj: int
class mandarin.webapi.models.e_outputs.FileOutput(*, id: int, uploader: mandarin.webapi.models.b_basic.User)
id: int
uploader: mandarin.webapi.models.b_basic.User
class mandarin.webapi.models.e_outputs.GenreOutput(*, id: int, name: str, description: str, songs: List[mandarin.webapi.models.b_basic.Song], albums: List[mandarin.webapi.models.b_basic.Album], supergenre: mandarin.webapi.models.b_basic.Genre = None, subgenres: List[mandarin.webapi.models.c_involvements.GenreTree])
id: int
name: str
description: str
songs: List[mandarin.webapi.models.b_basic.Song]
albums: List[mandarin.webapi.models.b_basic.Album]
supergenre: Optional[mandarin.webapi.models.b_basic.Genre]
subgenres: List[mandarin.webapi.models.c_involvements.GenreTree]
class mandarin.webapi.models.e_outputs.LayerOutput(*, id: int, name: str, description: str, song: mandarin.webapi.models.b_basic.Song = None)
id: int
name: str
description: str
song: Optional[mandarin.webapi.models.b_basic.Song]
class mandarin.webapi.models.e_outputs.PersonOutput(*, id: int, name: str, description: str, song_involvements: List[mandarin.webapi.models.c_involvements.SongInvolvementFromPerson], album_involvements: List[mandarin.webapi.models.c_involvements.AlbumInvolvementFromPerson])
id: int
name: str
description: str
song_involvements: List[mandarin.webapi.models.c_involvements.SongInvolvementFromPerson]
album_involvements: List[mandarin.webapi.models.c_involvements.AlbumInvolvementFromPerson]
class mandarin.webapi.models.e_outputs.RoleOutput(*, id: int, name: str, description: str, song_involvements: List[mandarin.webapi.models.c_involvements.SongInvolvementFromRole], album_involvements: List[mandarin.webapi.models.c_involvements.AlbumInvolvementFromRole])
id: int
name: str
description: str
song_involvements: List[mandarin.webapi.models.c_involvements.SongInvolvementFromRole]
album_involvements: List[mandarin.webapi.models.c_involvements.AlbumInvolvementFromRole]
class mandarin.webapi.models.e_outputs.SongInvolvementOutput(*, person: mandarin.webapi.models.b_basic.Person, song: mandarin.webapi.models.b_basic.Song, role: mandarin.webapi.models.b_basic.Role)
person: mandarin.webapi.models.b_basic.Person
song: mandarin.webapi.models.b_basic.Song
role: mandarin.webapi.models.b_basic.Role
class mandarin.webapi.models.e_outputs.SongOutput(*, id: int, title: str, description: str, lyrics: str, disc: pydantic.types.PositiveInt = None, track: pydantic.types.PositiveInt = None, year: int = None, album: mandarin.webapi.models.b_basic.Album = None, layers: List[mandarin.webapi.models.b_basic.Layer], involvements: List[mandarin.webapi.models.c_involvements.SongInvolvementFromSong], genres: List[mandarin.webapi.models.b_basic.Genre])
id: int
title: str
description: str
lyrics: str
disc: Optional[pydantic.types.PositiveInt]
track: Optional[pydantic.types.PositiveInt]
year: Optional[int]
album: Optional[mandarin.webapi.models.b_basic.Album]
layers: List[mandarin.webapi.models.b_basic.Layer]
involvements: List[mandarin.webapi.models.c_involvements.SongInvolvementFromSong]
genres: List[mandarin.webapi.models.b_basic.Genre]
class mandarin.webapi.models.e_outputs.UserOutput(*, id: int, sub: str, name: str, nickname: str, picture: str, email: str, email_verified: str, updated_at: str, audit_logs: List[mandarin.webapi.models.b_basic.AuditLog])
id: int
sub: str
name: str
nickname: str
picture: str
email: str
email_verified: str
updated_at: str
audit_logs: List[mandarin.webapi.models.b_basic.AuditLog]

Routes

Error

For some reason, the contents of this module are not displayed.

Utils

Error

It currently isn’t possible to import this module without side effects.