def post(self, request, rid): with self._handle_exception(request): rs = ReplicaShare.objects.get(id=rid) ts = datetime.utcnow().replace(tzinfo=utc) snap_name = request.data.get('snap_name') rt = ReceiveTrail(rshare=rs, snap_name=snap_name, status='pending', receive_pending=ts) rt.save() return Response(ReceiveTrailSerializer(rt).data)
def post(self, request, rid): rs = ReplicaShare.objects.get(id=rid) snap_name = request.DATA['snap_name'] ts = datetime.utcnow().replace(tzinfo=utc) rt = ReceiveTrail(rshare=rs, snap_name=snap_name, status='pending', receive_pending=ts) rt.save() return Response(ReceiveTrailSerializer(rt).data)
def put(self, request, rtid): with self._handle_exception(request): rt = ReceiveTrail.objects.get(id=rtid) rt.receive_succeeded = request.data.get('receive_succeeded', rt.receive_succeeded) rt.receive_failed = request.data.get('receive_failed', rt.receive_failed) rt.status = request.data.get('status', rt.status) rt.error = request.data.get('error', rt.error) rt.kb_received = request.data.get('kb_received', rt.kb_received) rt.end_ts = request.data.get('end_ts', rt.end_ts) rt.save() return Response(ReceiveTrailSerializer(rt).data)
def put(self, request, rtid): with self._handle_exception(request): rt = ReceiveTrail.objects.get(id=rtid) ts = datetime.utcnow().replace(tzinfo=utc) if ('receive_succeeded' in request.data): rt.receive_succeeded = ts rt.status = request.data.get('status', rt.status) rt.error = request.data.get('error', rt.error) rt.kb_received = request.data.get('kb_received', rt.kb_received) if (rt.status in ('succeeded', 'failed',)): rt.end_ts = ts rt.receive_succeeded = ts if (rt.status == 'failed'): rt.receive_failed = ts rt.save() return Response(ReceiveTrailSerializer(rt).data)
def put(self, request, rtid): with self._handle_exception(request): rt = ReceiveTrail.objects.get(id=rtid) ts = datetime.utcnow().replace(tzinfo=utc) if "receive_succeeded" in request.data: rt.receive_succeeded = ts rt.status = request.data.get("status", rt.status) rt.error = request.data.get("error", rt.error) rt.kb_received = request.data.get("kb_received", rt.kb_received) if rt.status in ( "succeeded", "failed", ): rt.end_ts = ts rt.receive_succeeded = ts if rt.status == "failed": rt.receive_failed = ts rt.save() return Response(ReceiveTrailSerializer(rt).data)
def put(self, request, rtid): rt = ReceiveTrail.objects.get(id=rtid) if ('snapshot_created' in request.DATA): rt.snapshot_created = request.DATA['snapshot_created'] if ('snapshot_failed' in request.DATA): rt.snapshot_failed = request.DATA['snapshot_failed'] if ('receive_succeeded' in request.DATA): rt.receive_succeeded = request.DATA['receive_succeeded'] if ('receive_failed' in request.DATA): rt.receive_failed = request.DATA['receive_failed'] if ('status' in request.DATA): rt.status = request.DATA['status'] if ('error' in request.DATA): rt.error = request.DATA['error'] if ('kb_received' in request.DATA): rt.kb_received = request.DATA['kb_received'] if ('end_ts' in request.DATA): rt.end_ts = request.DATA['end_ts'] rt.save() return Response(ReceiveTrailSerializer(rt).data)
def get(self, request, *args, **kwargs): if "rtid" in self.kwargs: with self._handle_exception(request): data = ReceiveTrail.objects.get(id=self.kwargs["rtid"]) serialized_data = ReceiveTrailSerializer(data) return Response(serialized_data.data)