blob: 4cf9fe03ca3f64629e12e5c139e4c27b8c4257e7 [file] [log] [blame]
Hesam Rahimi4a409b42016-08-12 18:37:33 -04001/*
2 * Copyright 2016-present 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 */
16package org.onosproject.protocol.restconf;
17
18import org.onosproject.net.DeviceId;
19import 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 */
25public 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 Yu05c2c762017-01-30 12:11:08 -050034 * @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 Rahimi4a409b42016-08-12 18:37:33 -040037 * @param callBackListener method to call when notifications arrives
38 */
39 void enableNotifications(DeviceId device, String request, String mediaType,
Henry Yu05c2c762017-01-30 12:11:08 -050040 RestconfNotificationEventListener callBackListener);
41
42 //TODO: To be removed once the caller to this API is updated.
43 @Deprecated void enableNotifications(DeviceId device, String request, String mediaType,
44 RestConfNotificationEventListener callBackListener);
Hesam Rahimi4a409b42016-08-12 18:37:33 -040045
46 /**
Henry Yu05c2c762017-01-30 12:11:08 -050047 * Registers a listener for notification events that occur to restconf
Hesam Rahimi4a409b42016-08-12 18:37:33 -040048 * devices.
49 *
Henry Yu05c2c762017-01-30 12:11:08 -050050 * @param deviceId identifier of the device to which the listener is attached
Hesam Rahimi4a409b42016-08-12 18:37:33 -040051 * @param listener the listener to notify
52 */
53 void addNotificationListener(DeviceId deviceId,
Henry Yu05c2c762017-01-30 12:11:08 -050054 RestconfNotificationEventListener listener);
Hesam Rahimi4a409b42016-08-12 18:37:33 -040055
56 /**
Henry Yu05c2c762017-01-30 12:11:08 -050057 * Unregisters the listener for the device.
Hesam Rahimi4a409b42016-08-12 18:37:33 -040058 *
Henry Yu05c2c762017-01-30 12:11:08 -050059 * @param deviceId identifier of the device for which the listener
60 * is to be removed
61 * @param listener listener to be removed
Hesam Rahimi4a409b42016-08-12 18:37:33 -040062 */
Henry Yu05c2c762017-01-30 12:11:08 -050063 void removeNotificationListener(DeviceId deviceId,
64 RestconfNotificationEventListener listener);
65
66 //TODO: temporarily keep this API for backward compatibility.
67 @Deprecated void removeNotificationListener(DeviceId deviceId);
68
69 /**
70 * Returns true if a listener has been installed to listen to RESTCONF
71 * notifications sent from a particular device.
72 *
73 * @param deviceId identifier of the device from which the notifications
74 * are generated
75 * @return true if listener is installed; false otherwise
76 */
77 boolean isNotificationEnabled(DeviceId deviceId);
Hesam Rahimi4a409b42016-08-12 18:37:33 -040078}