Hesam Rahimi | 4a409b4 | 2016-08-12 18:37:33 -0400 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Hesam Rahimi | 4a409b4 | 2016-08-12 18:37:33 -0400 | [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 | */ |
| 16 | package org.onosproject.protocol.restconf; |
| 17 | |
| 18 | import org.onosproject.net.DeviceId; |
| 19 | import org.onosproject.protocol.http.HttpSBController; |
| 20 | |
| 21 | /** |
| 22 | * Abstraction of a RESTCONF controller. Serves as a one stop shop for obtaining |
| 23 | * RESTCONF southbound devices and (un)register listeners. |
| 24 | */ |
| 25 | public interface RestConfSBController extends HttpSBController { |
| 26 | |
| 27 | /** |
| 28 | * This method is to be called by whoever is interested to receive |
| 29 | * Notifications from a specific device. It does a REST GET request |
| 30 | * with specified parameters to the device, and calls the provided |
| 31 | * callBackListener upon receiving notifications to notify the requester |
| 32 | * about notifications. |
| 33 | * |
Henry Yu | 05dcc21 | 2017-01-05 16:05:26 -0500 | [diff] [blame] | 34 | * @param device device to make the request to |
| 35 | * @param request url of the request |
| 36 | * @param mediaType format to retrieve the content in |
Hesam Rahimi | 4a409b4 | 2016-08-12 18:37:33 -0400 | [diff] [blame] | 37 | * @param callBackListener method to call when notifications arrives |
| 38 | */ |
| 39 | void enableNotifications(DeviceId device, String request, String mediaType, |
Henry Yu | 05dcc21 | 2017-01-05 16:05:26 -0500 | [diff] [blame] | 40 | RestconfNotificationEventListener callBackListener); |
Hesam Rahimi | 4a409b4 | 2016-08-12 18:37:33 -0400 | [diff] [blame] | 41 | |
| 42 | /** |
Henry Yu | 05dcc21 | 2017-01-05 16:05:26 -0500 | [diff] [blame] | 43 | * Registers a listener for notification events that occur to restconf |
Hesam Rahimi | 4a409b4 | 2016-08-12 18:37:33 -0400 | [diff] [blame] | 44 | * devices. |
| 45 | * |
Henry Yu | 05dcc21 | 2017-01-05 16:05:26 -0500 | [diff] [blame] | 46 | * @param deviceId identifier of the device to which the listener is attached |
Hesam Rahimi | 4a409b4 | 2016-08-12 18:37:33 -0400 | [diff] [blame] | 47 | * @param listener the listener to notify |
| 48 | */ |
| 49 | void addNotificationListener(DeviceId deviceId, |
Henry Yu | 05dcc21 | 2017-01-05 16:05:26 -0500 | [diff] [blame] | 50 | RestconfNotificationEventListener listener); |
Hesam Rahimi | 4a409b4 | 2016-08-12 18:37:33 -0400 | [diff] [blame] | 51 | |
| 52 | /** |
Henry Yu | 05dcc21 | 2017-01-05 16:05:26 -0500 | [diff] [blame] | 53 | * Unregisters the listener for the device. |
Hesam Rahimi | 4a409b4 | 2016-08-12 18:37:33 -0400 | [diff] [blame] | 54 | * |
Henry Yu | 05dcc21 | 2017-01-05 16:05:26 -0500 | [diff] [blame] | 55 | * @param deviceId identifier of the device for which the listener |
| 56 | * is to be removed |
| 57 | * @param listener listener to be removed |
Hesam Rahimi | 4a409b4 | 2016-08-12 18:37:33 -0400 | [diff] [blame] | 58 | */ |
Henry Yu | 05dcc21 | 2017-01-05 16:05:26 -0500 | [diff] [blame] | 59 | void removeNotificationListener(DeviceId deviceId, |
| 60 | RestconfNotificationEventListener listener); |
| 61 | |
| 62 | /** |
| 63 | * Returns true if a listener has been installed to listen to RESTCONF |
| 64 | * notifications sent from a particular device. |
| 65 | * |
| 66 | * @param deviceId identifier of the device from which the notifications |
| 67 | * are generated |
| 68 | * @return true if listener is installed; false otherwise |
| 69 | */ |
| 70 | boolean isNotificationEnabled(DeviceId deviceId); |
Hesam Rahimi | 4a409b4 | 2016-08-12 18:37:33 -0400 | [diff] [blame] | 71 | } |