Delete request for non-existent ID will be 404.
When trying to delete a non-existent backup, action, client, job, session it will raise exception with HTTP response 404. Change-Id: I06d7261f40e36e46c2743d531f5673907a7263a3 Closes-Bug: #1596935
This commit is contained in:
parent
206321471c
commit
a4a68b3936
|
@ -76,9 +76,16 @@ class ActionsResource(resource.BaseResource):
|
|||
def on_delete(self, req, resp, action_id):
|
||||
# DELETE /v1/actions/{action_id} Deletes the specified action
|
||||
user_id = req.get_header('X-User-ID')
|
||||
self.db.delete_action(user_id=user_id, action_id=action_id)
|
||||
resp.body = {'action_id': action_id}
|
||||
resp.status = falcon.HTTP_204
|
||||
obj = self.db.get_action(user_id=user_id,
|
||||
action_id=action_id)
|
||||
if not obj:
|
||||
raise freezer_api_exc.DocumentNotFound(
|
||||
message='No action found with ID:{0}'.
|
||||
format(action_id))
|
||||
else:
|
||||
self.db.delete_action(user_id=user_id, action_id=action_id)
|
||||
resp.body = {'action_id': action_id}
|
||||
resp.status = falcon.HTTP_204
|
||||
|
||||
@policy.enforce('actions:update')
|
||||
def on_patch(self, req, resp, action_id):
|
||||
|
|
|
@ -76,7 +76,14 @@ class BackupsResource(resource.BaseResource):
|
|||
def on_delete(self, req, resp, backup_id):
|
||||
# DELETE /v1/backups/{backup_id} Deletes the specified backup
|
||||
user_id = req.get_header('X-User-ID')
|
||||
self.db.delete_backup(
|
||||
user_id=user_id, backup_id=backup_id)
|
||||
resp.body = {'backup_id': backup_id}
|
||||
resp.status = falcon.HTTP_204
|
||||
obj = self.db.get_backup(user_id=user_id,
|
||||
backup_id=backup_id)
|
||||
if not obj:
|
||||
raise freezer_api_exc.DocumentNotFound(
|
||||
message='No Backup found with ID:{0}'.
|
||||
format(backup_id))
|
||||
else:
|
||||
self.db.delete_backup(
|
||||
user_id=user_id, backup_id=backup_id)
|
||||
resp.body = {'backup_id': backup_id}
|
||||
resp.status = falcon.HTTP_204
|
||||
|
|
|
@ -76,7 +76,14 @@ class ClientsResource(resource.BaseResource):
|
|||
def on_delete(self, req, resp, client_id):
|
||||
# DELETE /v1/clients/{client_id} Deletes the specified backup
|
||||
user_id = req.get_header('X-User-ID')
|
||||
self.db.delete_client(
|
||||
user_id=user_id, client_id=client_id)
|
||||
resp.body = {'client_id': client_id}
|
||||
resp.status = falcon.HTTP_204
|
||||
obj = self.db.get_client(user_id=user_id,
|
||||
client_id=client_id)
|
||||
if not obj:
|
||||
raise freezer_api_exc.DocumentNotFound(
|
||||
message='No Client found with ID:{0}'.
|
||||
format(client_id))
|
||||
else:
|
||||
self.db.delete_client(
|
||||
user_id=user_id, client_id=client_id)
|
||||
resp.body = {'client_id': client_id}
|
||||
resp.status = falcon.HTTP_204
|
||||
|
|
|
@ -115,9 +115,15 @@ class JobsResource(JobsBaseResource):
|
|||
def on_delete(self, req, resp, job_id):
|
||||
# DELETE /v1/jobs/{job_id} Deletes the specified job
|
||||
user_id = req.get_header('X-User-ID')
|
||||
self.db.delete_job(user_id=user_id, job_id=job_id)
|
||||
resp.body = {'job_id': job_id}
|
||||
resp.status = falcon.HTTP_204
|
||||
obj = self.db.get_job(user_id=user_id, job_id=job_id)
|
||||
if not obj:
|
||||
raise freezer_api_exc.DocumentNotFound(
|
||||
message='No Job found with ID:{0}'.
|
||||
format(job_id))
|
||||
else:
|
||||
self.db.delete_job(user_id=user_id, job_id=job_id)
|
||||
resp.body = {'job_id': job_id}
|
||||
resp.status = falcon.HTTP_204
|
||||
|
||||
@policy.enforce('jobs:update')
|
||||
def on_patch(self, req, resp, job_id):
|
||||
|
|
|
@ -78,9 +78,16 @@ class SessionsResource(resource.BaseResource):
|
|||
def on_delete(self, req, resp, session_id):
|
||||
# DELETE /v1/sessions/{session_id} Deletes the specified session
|
||||
user_id = req.get_header('X-User-ID')
|
||||
self.db.delete_session(user_id=user_id, session_id=session_id)
|
||||
resp.body = {'session_id': session_id}
|
||||
resp.status = falcon.HTTP_204
|
||||
obj = self.db.get_session(user_id=user_id,
|
||||
session_id=session_id)
|
||||
if not obj:
|
||||
raise freezer_api_exc.DocumentNotFound(
|
||||
message='No session found with ID:{0}'.
|
||||
format(session_id))
|
||||
else:
|
||||
self.db.delete_session(user_id=user_id, session_id=session_id)
|
||||
resp.body = {'session_id': session_id}
|
||||
resp.status = falcon.HTTP_204
|
||||
|
||||
@policy.enforce('sessions:update')
|
||||
def on_patch(self, req, resp, session_id):
|
||||
|
|
Loading…
Reference in New Issue