For the Song Service, it is recommended to implement a simple CRUD service to manage the song record (metadata). The service should provide the ability to manage some metadata about the songs (artist, album, etc.). Make sure the service is still available over HTTP.
Service definition could be next:
POST /songs | Create a new song metadata record in database | |||||
Request | Parameter | Description | Body example | Description | Restriction | |
{ "name": "We are the champions", "artist": "Queen", "album": "News of the world", "length": "2:59", "resourceId": "123", "year": ""1977 } |
Song metadata record, referencing to resource id (mp3 file itself) | MP3 audio data | ||||
Response | Body | Description | Code | |||
{ "id":1123 } |
Integer id – ID of the created song metadata | 200 – OK 400 – Song metadata missing validation error 500 – An internal server error has occurred |
||||
GET /songs/{id} | Get song metadata | |||||
Request | Parameter | Description | Restriction | Body example | Description | Restriction |
Integer id | Song metadata ID to get | ID of an existing song metadata | ||||
Response | Body | Description | Code | |||
{ "name": "We are the champions", "artist": "Queen", "album": "News of the world", "length": "2:59", "resourceId": "123", "year": ""1977 } |
200 – OK 404 – The song metadata with the specified id does not exist 500 – An internal server error has occurred |
|||||
DELETE /songs?id=1,2 | Delete a song(s) metadata. If there is no song metadata for id, do nothing | |||||
Request | Parameter | Description | Restriction | Body example | Description | Restriction |
String id | CSV of song metadata IDs to remove | Valid CSV length < 200 characters | ||||
Response | Body | Description | Code | |||
{ "ids": [1,2] } |
Integer [] ids - IDs of deleted resources | 200 – OK 500 – An internal server error has occurred |
Note
As a database, it is best to use Docker database/storage containers ( e.g. postgres image) in the implementation.