Added means to administratively remove device via REST API.
Change-Id: If0c0a98d7f36923dad1855a2303789f99882e224
Showing
1 changed file
with
11 additions
and
0 deletions
... | @@ -18,9 +18,11 @@ package org.onosproject.rest.resources; | ... | @@ -18,9 +18,11 @@ package org.onosproject.rest.resources; |
18 | import com.fasterxml.jackson.databind.node.ObjectNode; | 18 | import com.fasterxml.jackson.databind.node.ObjectNode; |
19 | import org.onosproject.net.Device; | 19 | import org.onosproject.net.Device; |
20 | import org.onosproject.net.Port; | 20 | import org.onosproject.net.Port; |
21 | +import org.onosproject.net.device.DeviceAdminService; | ||
21 | import org.onosproject.net.device.DeviceService; | 22 | import org.onosproject.net.device.DeviceService; |
22 | import org.onosproject.rest.AbstractWebResource; | 23 | import org.onosproject.rest.AbstractWebResource; |
23 | 24 | ||
25 | +import javax.ws.rs.DELETE; | ||
24 | import javax.ws.rs.GET; | 26 | import javax.ws.rs.GET; |
25 | import javax.ws.rs.Path; | 27 | import javax.ws.rs.Path; |
26 | import javax.ws.rs.PathParam; | 28 | import javax.ws.rs.PathParam; |
... | @@ -53,6 +55,15 @@ public class DevicesWebResource extends AbstractWebResource { | ... | @@ -53,6 +55,15 @@ public class DevicesWebResource extends AbstractWebResource { |
53 | return ok(codec(Device.class).encode(device, this)).build(); | 55 | return ok(codec(Device.class).encode(device, this)).build(); |
54 | } | 56 | } |
55 | 57 | ||
58 | + @DELETE | ||
59 | + @Path("{id}") | ||
60 | + public Response removeDevice(@PathParam("id") String id) { | ||
61 | + Device device = nullIsNotFound(get(DeviceService.class).getDevice(deviceId(id)), | ||
62 | + DEVICE_NOT_FOUND); | ||
63 | + get(DeviceAdminService.class).removeDevice(deviceId(id)); | ||
64 | + return ok(codec(Device.class).encode(device, this)).build(); | ||
65 | + } | ||
66 | + | ||
56 | @GET | 67 | @GET |
57 | @Path("{id}/ports") | 68 | @Path("{id}/ports") |
58 | public Response getDevicePorts(@PathParam("id") String id) { | 69 | public Response getDevicePorts(@PathParam("id") String id) { | ... | ... |
-
Please register or login to post a comment