blob: 98ebf3fbc5455acb2370cb7f8ff184b88103d85a [file] [log] [blame]
Andrea Campanella101417d2015-12-11 17:58:07 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Andrea Campanella101417d2015-12-11 17:58:07 -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 */
16
17package org.onosproject.netconf.ctl;
18
helenyrwu0407c642016-06-09 12:01:30 -070019import com.google.common.annotations.Beta;
Andrea Campanella101417d2015-12-11 17:58:07 -080020import org.onosproject.netconf.NetconfDeviceOutputEventListener;
21
22import java.util.concurrent.CompletableFuture;
23
24/**
25 * Interface to represent an objects that does all the IO on a NETCONF session
26 * with a device.
27 */
28public interface NetconfStreamHandler {
29 /**
30 * Sends the request on the stream that is used to communicate to and from the device.
31 *
Sean Condond2c8d472017-02-17 17:09:39 +000032 * If this request does not contain a messageId then this will throw a NoSuchElementException
33 *
Andrea Campanella101417d2015-12-11 17:58:07 -080034 * @param request request to send to the physical device
35 * @return a CompletableFuture of type String that will contain the response for the request.
Sean Condond2c8d472017-02-17 17:09:39 +000036 * @deprecated - use method with messageId parameter instead
Andrea Campanella101417d2015-12-11 17:58:07 -080037 */
Sean Condond2c8d472017-02-17 17:09:39 +000038 @Deprecated
Andrea Campanella101417d2015-12-11 17:58:07 -080039 CompletableFuture<String> sendMessage(String request);
40
41 /**
Sean Condond2c8d472017-02-17 17:09:39 +000042 * Sends the request on the stream that is used to communicate to and from the device.
43 *
44 * @param request request to send to the physical device
45 * @param messageId The identifier of the message - should be unique for the session
46 * @return a CompletableFuture of type String that will contain the response for the request.
47 */
48 CompletableFuture<String> sendMessage(String request, int messageId);
49
50 /**
Andrea Campanella101417d2015-12-11 17:58:07 -080051 * Adds a listener for netconf events on the handled stream.
52 *
53 * @param listener Netconf device event listener
54 */
55 void addDeviceEventListener(NetconfDeviceOutputEventListener listener);
56
57 /**
58 * Removes a listener for netconf events on the handled stream.
59 *
60 * @param listener Netconf device event listener
61 */
62 void removeDeviceEventListener(NetconfDeviceOutputEventListener listener);
helenyrwu0407c642016-06-09 12:01:30 -070063
64 @Beta
65 /**
66 * Sets instance variable that when true allows receipt of notifications.
67 *
68 * @param enableNotifications if true, allows action based off notifications
69 * else, stops action based off notifications
70 */
71 void setEnableNotifications(boolean enableNotifications);
Andrea Campanella101417d2015-12-11 17:58:07 -080072}