blob: cc75b27ed5a4ed04d32b148689d30e0e6db6e566 [file] [log] [blame]
Ray Milkey17481412015-12-09 09:16:26 -08001/*
Brian O'Connord6a135a2017-08-03 22:46:05 -07002 * Copyright 2016-present Open Networking Foundation
Ray Milkey17481412015-12-09 09:16:26 -08003 *
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 */
alshabib36a4d732016-06-01 16:03:59 -070016package org.opencord.olt.rest;
Ray Milkey17481412015-12-09 09:16:26 -080017
Amit Ghosh1ed9aef2018-07-17 17:08:16 +010018import org.onosproject.net.ConnectPoint;
19import org.onosproject.net.DeviceId;
20import org.onosproject.net.PortNumber;
21import org.onosproject.rest.AbstractWebResource;
22import org.opencord.olt.AccessDeviceService;
23
Ray Milkey17481412015-12-09 09:16:26 -080024import javax.ws.rs.DELETE;
25import javax.ws.rs.POST;
26import javax.ws.rs.Path;
27import javax.ws.rs.PathParam;
28import javax.ws.rs.Produces;
29import javax.ws.rs.core.MediaType;
30import javax.ws.rs.core.Response;
31
Ray Milkey17481412015-12-09 09:16:26 -080032/**
33 * OLT REST APIs.
34 */
35
36@Path("oltapp")
37public class OltWebResource extends AbstractWebResource {
38
39 /**
40 * Provision a subscriber.
41 *
Jian Lid8bca082016-01-22 16:46:58 -080042 * @param device device id
43 * @param port port number
Ray Milkey17481412015-12-09 09:16:26 -080044 * @return 200 OK
45 */
46 @POST
47 @Produces(MediaType.APPLICATION_JSON)
Amit Ghosh1ed9aef2018-07-17 17:08:16 +010048 @Path("{device}/{port}")
Ray Milkey17481412015-12-09 09:16:26 -080049 public Response provisionSubscriber(
50 @PathParam("device")String device,
Amit Ghosh1ed9aef2018-07-17 17:08:16 +010051 @PathParam("port")long port) {
Ray Milkey17481412015-12-09 09:16:26 -080052 AccessDeviceService service = get(AccessDeviceService.class);
53 DeviceId deviceId = DeviceId.deviceId(device);
54 PortNumber portNumber = PortNumber.portNumber(port);
Ray Milkey17481412015-12-09 09:16:26 -080055 ConnectPoint connectPoint = new ConnectPoint(deviceId, portNumber);
Amit Ghosh1ed9aef2018-07-17 17:08:16 +010056 service.provisionSubscriber(connectPoint);
Ray Milkey17481412015-12-09 09:16:26 -080057 return ok("").build();
58 }
59
60 /**
61 * Remove the provisioning for a subscriber.
Jian Lid8bca082016-01-22 16:46:58 -080062 *
63 * @param device device id
64 * @param port port number
Jian Lic39f08d2016-05-10 11:48:19 -070065 * @return 204 NO CONTENT
Ray Milkey17481412015-12-09 09:16:26 -080066 */
67 @DELETE
Ray Milkey17481412015-12-09 09:16:26 -080068 @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 Lic39f08d2016-05-10 11:48:19 -070077 return Response.noContent().build();
Ray Milkey17481412015-12-09 09:16:26 -080078 }
79}