Thomas Vachuska | b81c278 | 2015-08-21 14:21:50 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.dhcpserver.rest; |
| 17 | |
| 18 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 19 | import org.onosproject.dhcpserver.DHCPService; |
| 20 | import org.onosproject.rest.AbstractWebResource; |
| 21 | |
| 22 | import javax.ws.rs.GET; |
| 23 | import javax.ws.rs.Path; |
| 24 | import javax.ws.rs.core.Response; |
| 25 | |
| 26 | /** |
| 27 | * Manage DHCP address assignments. |
| 28 | */ |
| 29 | @Path("/") |
| 30 | public class DHCPWebResource extends AbstractWebResource { |
| 31 | |
| 32 | /** |
| 33 | * Get DHCP server configuration data. |
| 34 | * Shows lease, renewal and rebinding times in seconds. |
| 35 | * |
| 36 | * @return 200 OK |
| 37 | */ |
| 38 | @GET |
| 39 | @Path("config") |
| 40 | public Response getConfigs() { |
| 41 | DHCPService service = get(DHCPService.class); |
| 42 | ObjectNode node = mapper().createObjectNode() |
| 43 | .put("leaseTime", service.getLeaseTime()) |
| 44 | .put("renewalTime", service.getRenewalTime()) |
| 45 | .put("rebindingTime", service.getRebindingTime()); |
| 46 | return ok(node.toString()).build(); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | // POST should accept a single mac/ip binding with |
| 51 | /* |
| 52 | { |
| 53 | "mac": "00:......00", |
| 54 | "ip": "12.34.56.78" |
| 55 | } |
| 56 | */ |
| 57 | |
| 58 | // @POST |
| 59 | // @Path("mappings") |
| 60 | |
| 61 | |
| 62 | |
| 63 | // GET all mappings should look like this: |
| 64 | /* |
| 65 | { |
| 66 | "mappings": [ |
| 67 | { |
| 68 | "mac": "00:......00", |
| 69 | "ip": "12.34.56.78", |
| 70 | ... |
| 71 | } |
| 72 | ] |
| 73 | } |
| 74 | */ |
| 75 | } |