From 64cb53f2250f13db57ec85e86eaefc563b7370b3 Mon Sep 17 00:00:00 2001 From: Cathy Hu Date: Mon, 6 Jul 2020 14:50:11 +0200 Subject: [PATCH] [twitter] Add DELETE id, GET all, GET id for twitter --- kibicara/platforms/twitter/webapi.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kibicara/platforms/twitter/webapi.py b/kibicara/platforms/twitter/webapi.py index 7c7e933..c73ee1b 100644 --- a/kibicara/platforms/twitter/webapi.py +++ b/kibicara/platforms/twitter/webapi.py @@ -27,6 +27,22 @@ router = APIRouter() twitter_callback_router = APIRouter() +@router.get('/') +async def twitter_read_all(hood=Depends(get_hood)): + return await Twitter.objects.filter(hood=hood).all() + + +@router.get('/{twitter_id}') +async def twitter_read(twitter=Depends(get_twitter)): + return twitter + + +@router.delete('/{twitter_id}', status_code=status.HTTP_204_NO_CONTENT) +async def twitter_delete(twitter=Depends(get_twitter)): + spawner.stop(twitter) + await twitter.delete() + + @router.post('/', status_code=status.HTTP_201_CREATED) async def twitter_create(response: Response, hood=Depends(get_hood)): try: