File tree Expand file tree Collapse file tree
qwave-server/src/qwave/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313router = APIRouter ()
1414
1515class AlbumSummary (BaseModel ):
16- id : int
17- title : str
16+ id : int
17+ title : str
1818 release_date : Optional [str ]
1919 album_artist : Optional [dict ]
20- track_count : int
20+ track_count : int
2121
2222class TrackInAlbum (BaseModel ):
23- id : int
24- title : str
23+ id : int
24+ title : str
2525 track_number : Optional [int ]
26- duration : int
27- artists : List [dict ]
26+ duration : int
27+ artists : List [dict ]
2828
2929class AlbumDetail (BaseModel ):
30- id : int
31- title : str
30+ id : int
31+ title : str
3232 release_date : Optional [str ]
3333 album_artist : Optional [dict ]
34- tracks : List [TrackInAlbum ]
34+ tracks : List [TrackInAlbum ]
3535
3636class UpdateAlbumRequest (BaseModel ):
37- title : Optional [str ] = Field (None , min_length = 1 , max_length = 255 )
37+ title : Optional [str ] = Field (None , min_length = 1 , max_length = 255 )
3838 release_date : Optional [str ] = None # ISO date string
3939
4040@router .get ("" , response_model = dict )
Original file line number Diff line number Diff line change 1111router = APIRouter ()
1212
1313class ArtistSummary (BaseModel ):
14- id : int
15- name : str
16- track_count : int
17- album_count : int
18-
19- class Config :
20- from_attributes = True
14+ model_config = {"from_attributes" : True }
15+ id : int
16+ name : str
17+ track_count : int
18+ album_count : int
2119
2220class ArtistDetail (BaseModel ):
23- id : int
24- name : str
25- track_count : int
26- album_count : int
27-
28- class Config :
29- from_attributes = True
21+ model_config = {"from_attributes" : True }
22+ id : int
23+ name : str
24+ track_count : int
25+ album_count : int
3026
3127class ArtistListResponse (BaseModel ):
32- artists : List [ArtistSummary ]
33- total : int
28+ artists : List [ArtistSummary ]
29+ total : int
3430
3531class TrackSummary (BaseModel ):
36- id : int
37- title : str
38- duration : float
39- album : Optional [dict ]
40-
41- class Config :
42- from_attributes = True
32+ model_config = {"from_attributes" : True }
33+ id : int
34+ title : str
35+ duration : float
36+ album : Optional [dict ]
4337
4438class TracksResponse (BaseModel ):
45- tracks : List [TrackSummary ]
46- total : int
39+ tracks : List [TrackSummary ]
40+ total : int
4741
4842class AlbumSummary (BaseModel ):
49- id : int
50- title : str
51- release_date : Optional [str ]
52- track_count : int
53-
54- class Config :
55- from_attributes = True
43+ model_config = {"from_attributes" : True }
44+ id : int
45+ title : str
46+ release_date : Optional [str ]
47+ track_count : int
5648
5749class AlbumsResponse (BaseModel ):
58- albums : List [AlbumSummary ]
50+ albums : List [AlbumSummary ]
5951
6052@router .get ("" , response_model = ArtistListResponse )
6153def list_artists (
Original file line number Diff line number Diff line change 1111# endpoints: /register /login /logout /me
1212
1313class RegisterRequest (BaseModel ):
14- username : str = Field (..., min_length = 3 , max_length = 255 )
15- password : str = Field (..., min_length = 4 )
14+ username : str = Field (..., min_length = 3 , max_length = 255 )
15+ password : str = Field (..., min_length = 4 )
1616
1717class LoginRequest (BaseModel ):
18- username : str
19- password : str
18+ username : str
19+ password : str
2020
2121class UserResponse (BaseModel ):
22- user_id : int
23- username : str
24- created_at : str
25-
26- class Config :
27- from_attributes = True
22+ model_config = {"from_attributes" : True }
23+ user_id : int
24+ username : str
25+ created_at : str
2826
2927class LoginResponse (BaseModel ):
30- token : str
31- user_id : int
32- expires_at : str
28+ token : str
29+ user_id : int
30+ expires_at : str
3331
3432class MessageResponse (BaseModel ):
35- message : str
33+ message : str
3634
3735
3836def get_current_token (authorization : str = Header (None )) -> str :
Original file line number Diff line number Diff line change 1010router = APIRouter ()
1111
1212class CreateGenreRequest (BaseModel ):
13- name : str = Field (..., min_length = 1 , max_length = 128 )
13+ name : str = Field (..., min_length = 1 , max_length = 128 )
1414
1515class GenreSummary (BaseModel ):
16- id : int
17- name : str
18- track_count : int
16+ id : int
17+ name : str
18+ track_count : int
1919
2020class GenreResponse (BaseModel ):
21- id : int
22- name : str
21+ model_config = {"from_attributes" : True }
22+ id : int
23+ name : str
2324
24- class Config :
25- from_attributes = True
26-
2725@router .get ("" , response_model = dict )
2826def list_genres (
2927 user = Depends (get_current_user ),
Original file line number Diff line number Diff line change 88# /info /config
99
1010class ServerInfoResponse (BaseModel ):
11- name : str
12- theme_colors : dict
13- logo_url : Optional [str ]
14- background_url : Optional [str ]
11+ name : str
12+ theme_colors : dict
13+ logo_url : Optional [str ]
14+ background_url : Optional [str ]
1515
1616class ServerConfigResponse (BaseModel ):
17- opus_bitrate : int
18- acoustid_enabled : bool
17+ opus_bitrate : int
18+ acoustid_enabled : bool
1919 max_upload_size_mb : int
2020
2121@router .get ("/info" , response_model = ServerInfoResponse )
Original file line number Diff line number Diff line change 88
99router = APIRouter ()
1010
11+ # =========================== table item model thingies
1112class ArtistInfo (BaseModel ):
12- id : int
13- name :
13+ id : int
14+ name : str
15+ is_primary : bool
16+
17+ class AlbumInfo (BaseModel ):
18+ id : int
19+ title : str
20+ release_date : Optional [str ] = None
21+
22+ class GenreInfo (BaseModel ):
23+ id : int
24+ name : str
25+
26+ class UserInfo (BaseModel ):
27+ id : int
28+ username : str
29+
30+ # ========================== track responsesssssssssss
31+ class TrackSummary (BaseModel ):
32+ id : int
33+ title : str
34+ duration : int
35+ artists : List [ArtistInfo ]
36+ album : Optional [AlbumInfo ]
37+
38+ class abc (BaseModel ):
39+ abc : int
40+
41+
42+ # ===========
43+ class UpdateTrackResponse (BaseModel ):
44+ id : int
45+ updated_fields : List [str ]
46+ track : dict # maybe make this a model?
You can’t perform that action at this time.
0 commit comments