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