Ray Milkey | 1748141 | 2015-12-09 09:16:26 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | d6a135a | 2017-08-03 22:46:05 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Ray Milkey | 1748141 | 2015-12-09 09:16:26 -0800 | [diff] [blame] | 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 | */ |
alshabib | 36a4d73 | 2016-06-01 16:03:59 -0700 | [diff] [blame] | 16 | package org.opencord.olt.rest; |
Ray Milkey | 1748141 | 2015-12-09 09:16:26 -0800 | [diff] [blame] | 17 | |
| 18 | import javax.ws.rs.DELETE; |
| 19 | import javax.ws.rs.POST; |
| 20 | import javax.ws.rs.Path; |
| 21 | import javax.ws.rs.PathParam; |
| 22 | import javax.ws.rs.Produces; |
| 23 | import javax.ws.rs.core.MediaType; |
| 24 | import javax.ws.rs.core.Response; |
| 25 | |
| 26 | import org.onlab.packet.VlanId; |
| 27 | import org.onosproject.net.ConnectPoint; |
| 28 | import org.onosproject.net.DeviceId; |
| 29 | import org.onosproject.net.PortNumber; |
alshabib | 36a4d73 | 2016-06-01 16:03:59 -0700 | [diff] [blame] | 30 | import org.opencord.olt.AccessDeviceService; |
Ray Milkey | 1748141 | 2015-12-09 09:16:26 -0800 | [diff] [blame] | 31 | import org.onosproject.rest.AbstractWebResource; |
| 32 | |
| 33 | /** |
| 34 | * OLT REST APIs. |
| 35 | */ |
| 36 | |
| 37 | @Path("oltapp") |
| 38 | public class OltWebResource extends AbstractWebResource { |
| 39 | |
| 40 | /** |
| 41 | * Provision a subscriber. |
| 42 | * |
Jian Li | d8bca08 | 2016-01-22 16:46:58 -0800 | [diff] [blame] | 43 | * @param device device id |
| 44 | * @param port port number |
| 45 | * @param vlan vlan id |
Ray Milkey | 1748141 | 2015-12-09 09:16:26 -0800 | [diff] [blame] | 46 | * @return 200 OK |
| 47 | */ |
| 48 | @POST |
| 49 | @Produces(MediaType.APPLICATION_JSON) |
| 50 | @Path("{device}/{port}/{vlan}") |
| 51 | public Response provisionSubscriber( |
| 52 | @PathParam("device")String device, |
| 53 | @PathParam("port")long port, |
| 54 | @PathParam("vlan")short vlan) { |
| 55 | AccessDeviceService service = get(AccessDeviceService.class); |
| 56 | DeviceId deviceId = DeviceId.deviceId(device); |
| 57 | PortNumber portNumber = PortNumber.portNumber(port); |
| 58 | VlanId vlanId = VlanId.vlanId(vlan); |
| 59 | ConnectPoint connectPoint = new ConnectPoint(deviceId, portNumber); |
| 60 | service.provisionSubscriber(connectPoint, vlanId); |
| 61 | return ok("").build(); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Remove the provisioning for a subscriber. |
Jian Li | d8bca08 | 2016-01-22 16:46:58 -0800 | [diff] [blame] | 66 | * |
| 67 | * @param device device id |
| 68 | * @param port port number |
Jian Li | c39f08d | 2016-05-10 11:48:19 -0700 | [diff] [blame] | 69 | * @return 204 NO CONTENT |
Ray Milkey | 1748141 | 2015-12-09 09:16:26 -0800 | [diff] [blame] | 70 | */ |
| 71 | @DELETE |
Ray Milkey | 1748141 | 2015-12-09 09:16:26 -0800 | [diff] [blame] | 72 | @Path("{device}/{port}") |
| 73 | public Response removeSubscriber( |
| 74 | @PathParam("device")String device, |
| 75 | @PathParam("port")long port) { |
| 76 | AccessDeviceService service = get(AccessDeviceService.class); |
| 77 | DeviceId deviceId = DeviceId.deviceId(device); |
| 78 | PortNumber portNumber = PortNumber.portNumber(port); |
| 79 | ConnectPoint connectPoint = new ConnectPoint(deviceId, portNumber); |
| 80 | service.removeSubscriber(connectPoint); |
Jian Li | c39f08d | 2016-05-10 11:48:19 -0700 | [diff] [blame] | 81 | return Response.noContent().build(); |
Ray Milkey | 1748141 | 2015-12-09 09:16:26 -0800 | [diff] [blame] | 82 | } |
| 83 | } |