(request, username)
API Endpoint for Device Synchronisation
API Endpoint for Device Synchronisation
API Endpoint for Device Synchronisation
def main(request, username):
    """API Endpoint for Device Synchronisation"""

    if request.method == "GET":
        return JsonResponse(get_sync_status(request.user))

    else:
        try:
            actions = parse_request_body(request)
        except ValueError as e:
            return HttpResponseBadRequest(str(e))

        synclist = actions.get("synchronize", [])
        stopsync = actions.get("stop-synchronize", [])

        try:
            update_sync_status(request.user, synclist, stopsync)
        except ValueError as e:
            return HttpResponseBadRequest(str(e))
        except Client.DoesNotExist as e:
            return HttpResponseNotFound(str(e))

        return JsonResponse(get_sync_status(request.user))
def main ( request , username ) : if request . method == "GET" : return JsonResponse ( get_sync_status ( request . user ) ) else : try : actions = parse_request_body ( request ) except ValueError as e : return HttpResponseBadRequest ( str ( e ) ) synclist = actions . get ( "synchronize" , [ ] ) stopsync = actions . get ( "stop-synchronize" , [ ] ) try : update_sync_status ( request . user , synclist , stopsync ) except ValueError as e : return HttpResponseBadRequest ( str ( e ) ) except Client . DoesNotExist as e : return HttpResponseNotFound ( str ( e ) ) return JsonResponse ( get_sync_status ( request . user ) )