blob: feaa0dc0c3a1354c9332e12c613e2a66af9bbfb9 [file] [log] [blame]
Marc De Leenheer57a5af02016-12-02 20:54:41 -08001/*
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.tl1;
17
18import com.google.common.annotations.Beta;
19import org.onosproject.net.DeviceId;
20
21import java.util.Collection;
22import java.util.Optional;
23import java.util.Set;
24import java.util.concurrent.CompletableFuture;
25
26@Beta
27public interface Tl1Controller {
28 /**
29 * Sends the message to the device asynchronously.
30 *
31 * @param deviceId the device to write to
32 * @param msg the message to write
33 * @return the device response
34 */
35 // TODO: return CompletableFuture<Tl1Message> once we have appropriate builders
36 CompletableFuture<String> sendMsg(DeviceId deviceId, Tl1Command msg);
37
38 /**
39 * Returns the device identified by given ID.
40 *
41 * @param deviceId the device ID to lookup
42 * @return optional Tl1Device
43 */
44 Optional<Tl1Device> getDevice(DeviceId deviceId);
45
46 /**
47 /**
48 * Adds a device to the controller.
49 * @param deviceId the device ID to add
50 * @param device the device to add
51 * @return true if device added, false if already known
52 */
53 boolean addDevice(DeviceId deviceId, Tl1Device device);
54
55 /**
56 * Disconnects the device and removes it from the controller.
57 * @param deviceId the device to remove
58 */
59 void removeDevice(DeviceId deviceId);
60
61 /**
62 * Connects the controller to the device.
63 * @param deviceId the device to disconnect to
64 */
65 void connectDevice(DeviceId deviceId);
66
67 /**
68 * Disconnects the device from the controller.
69 * @param deviceId the device to disconnect from
70 */
71 void disconnectDevice(DeviceId deviceId);
72
73 /**
74 * Returns a set of all devices IDs for this TL1 controller.
75 * @return set of device IDs
76 */
77 Set<DeviceId> getDeviceIds();
78
79 /**
80 * Returns a set of all devices for this TL1 controller.
81 * @return collection of TL1 devices
82 */
83 Collection<Tl1Device> getDevices();
84
85 /**
86 * Registers a listener for TL1 events.
87 *
88 * @param listener the listener to notify
89 */
90 void addListener(Tl1Listener listener);
91
92 /**
93 * Unregisters a listener for TL1 events.
94 *
95 * @param listener the listener to unregister
96 */
97 void removeListener(Tl1Listener listener);
98}