From 8fed1d9b9f7e5bf3a6e7331da1063185d172b41f Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 14 Mar 2016 20:54:05 +0100 Subject: [PATCH] API for deleting a link --- gns3server/controller/hypervisor.py | 4 ++++ gns3server/handlers/api/controller/link_handler.py | 4 ++-- tests/handlers/api/controller/test_link.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gns3server/controller/hypervisor.py b/gns3server/controller/hypervisor.py index abb05e90..0910bed7 100644 --- a/gns3server/controller/hypervisor.py +++ b/gns3server/controller/hypervisor.py @@ -114,3 +114,7 @@ class Hypervisor: @asyncio.coroutine def post(self, path, data={}): return (yield from self.httpQuery("POST", path, data)) + + @asyncio.coroutine + def delete(self, path): + return (yield from self.httpQuery("DELETE", path)) diff --git a/gns3server/handlers/api/controller/link_handler.py b/gns3server/handlers/api/controller/link_handler.py index 379d53b5..166ef2d1 100644 --- a/gns3server/handlers/api/controller/link_handler.py +++ b/gns3server/handlers/api/controller/link_handler.py @@ -60,7 +60,7 @@ class LinkHandler: "link_id": "UUID of the link" }, status_codes={ - 201: "Link deleted", + 204: "Link deleted", 400: "Invalid request" }, description="Delete a link instance") @@ -70,5 +70,5 @@ class LinkHandler: project = controller.getProject(request.match_info["project_id"]) link = project.getLink(request.match_info["link_id"]) yield from link.delete() - response.set_status(201) + response.set_status(204) response.json(link) diff --git a/tests/handlers/api/controller/test_link.py b/tests/handlers/api/controller/test_link.py index 55ed51a8..0e3a8538 100644 --- a/tests/handlers/api/controller/test_link.py +++ b/tests/handlers/api/controller/test_link.py @@ -79,4 +79,4 @@ def test_delete_link(http_controller, tmpdir, project, hypervisor, async_run): project._links = {link.id: link} with asyncio_patch("gns3server.controller.udp_link.Link.delete"): response = http_controller.delete("/projects/{}/links/{}".format(project.id, link.id), example=True) - assert response.status == 201 + assert response.status == 204