def get_backup_details(request):
"""
Returns the details of a backup
:Example: curl -X GET http://localhost:8082/foglamp/backup/1
"""
backup_id = request.match_info.get('backup_id', None)
if not backup_id:
raise web.HTTPBadRequest(reason='Backup id is required')
else:
try:
backup_id = int(backup_id)
except ValueError:
raise web.HTTPBadRequest(reason='Invalid backup id')
try:
# TODO : Fix after actual implementation
Backup.get_backup_details.return_value = \
{"date": '2017-08-30 04:05:10.382', "status": "running"}
except Backup.DoesNotExist:
raise web.HTTPNotFound(reason='Backup with {} does not exist'.format(backup_id))
_resp = Backup.get_backup_details(id=backup_id)
_resp["id"] = backup_id
return web.json_response(_resp)
评论列表
文章目录