Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs][media] Add summary and description to media routes #41

Merged
merged 2 commits into from
Nov 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/app/api/routes/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,44 @@
router = APIRouter()


@router.post("/", response_model=MediaOut, status_code=201)
@router.post("/", response_model=MediaOut, status_code=201, summary="Create a media related to a specific device")
async def create_media(payload: MediaIn):
"""
Creates a media related to specific device, based on device_id as argument

Below, click on "Schema" for more detailed information about arguments
or "Example Value" to get a concrete idea of arguments
"""
return await crud.create_entry(media, payload)


@router.get("/{media_id}/", response_model=MediaOut)
@router.get("/{media_id}/", response_model=MediaOut, summary="Get information about a specific media")
async def get_media(media_id: int = Path(..., gt=0)):
"""
Based on a media_id, retrieves information about the given media
"""
return await crud.get_entry(media, media_id)


@router.get("/", response_model=List[MediaOut])
@router.get("/", response_model=List[MediaOut], summary="Get the list of all media")
async def fetch_media():
"""
Retrieves the list of all media with each related information
"""
return await crud.fetch_all(media)


@router.put("/{media_id}/", response_model=MediaOut)
@router.put("/{media_id}/", response_model=MediaOut, summary="Update information about a specific media")
async def update_media(payload: MediaIn, media_id: int = Path(..., gt=0)):
"""
Based on a media_id, updates information about the given media
"""
return await crud.update_entry(media, payload, media_id)


@router.delete("/{media_id}/", response_model=MediaOut)
@router.delete("/{media_id}/", response_model=MediaOut, summary="Delete a specific media")
async def delete_media(media_id: int = Path(..., gt=0)):
"""
Based on a media_id, deletes the given media
"""
return await crud.delete_entry(media, media_id)