1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

API for deleting a link

This commit is contained in:
Julien Duponchelle 2016-03-14 20:54:05 +01:00
parent ed291da566
commit 8fed1d9b9f
No known key found for this signature in database
GPG Key ID: F1E2485547D4595D
3 changed files with 7 additions and 3 deletions

View File

@ -114,3 +114,7 @@ class Hypervisor:
@asyncio.coroutine @asyncio.coroutine
def post(self, path, data={}): def post(self, path, data={}):
return (yield from self.httpQuery("POST", path, data)) return (yield from self.httpQuery("POST", path, data))
@asyncio.coroutine
def delete(self, path):
return (yield from self.httpQuery("DELETE", path))

View File

@ -60,7 +60,7 @@ class LinkHandler:
"link_id": "UUID of the link" "link_id": "UUID of the link"
}, },
status_codes={ status_codes={
201: "Link deleted", 204: "Link deleted",
400: "Invalid request" 400: "Invalid request"
}, },
description="Delete a link instance") description="Delete a link instance")
@ -70,5 +70,5 @@ class LinkHandler:
project = controller.getProject(request.match_info["project_id"]) project = controller.getProject(request.match_info["project_id"])
link = project.getLink(request.match_info["link_id"]) link = project.getLink(request.match_info["link_id"])
yield from link.delete() yield from link.delete()
response.set_status(201) response.set_status(204)
response.json(link) response.json(link)

View File

@ -79,4 +79,4 @@ def test_delete_link(http_controller, tmpdir, project, hypervisor, async_run):
project._links = {link.id: link} project._links = {link.id: link}
with asyncio_patch("gns3server.controller.udp_link.Link.delete"): with asyncio_patch("gns3server.controller.udp_link.Link.delete"):
response = http_controller.delete("/projects/{}/links/{}".format(project.id, link.id), example=True) response = http_controller.delete("/projects/{}/links/{}".format(project.id, link.id), example=True)
assert response.status == 201 assert response.status == 204