blob: 4c6d50a84689a3df0619c190506c8c46e8c30a33 [file] [log] [blame]
Shravan Ambati7d199542016-04-22 16:09:05 -07001/**
2 * Copyright 2016-present Open Networking Laboratory
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6
7 * http://www.apache.org/licenses/LICENSE-2.0
8
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15package org.onosproject.kafkaintegration.api;
16
Shravan Ambati5a11e172016-07-21 15:55:28 -070017import java.util.List;
18
Shravan Ambati7d199542016-04-22 16:09:05 -070019import org.onosproject.kafkaintegration.api.dto.EventSubscriber;
Sanjana Agarwalcb4a3db2016-07-14 11:42:48 -070020import org.onosproject.kafkaintegration.api.dto.OnosEvent.Type;
Shravan Ambati5a11e172016-07-21 15:55:28 -070021import org.onosproject.kafkaintegration.api.dto.RegistrationResponse;
Shravan Ambati7d199542016-04-22 16:09:05 -070022import org.onosproject.kafkaintegration.errors.InvalidApplicationException;
23import org.onosproject.kafkaintegration.errors.InvalidGroupIdException;
Shravan Ambatibb6b4452016-05-04 13:25:28 -070024
25import com.google.common.annotations.Beta;
Shravan Ambati7d199542016-04-22 16:09:05 -070026
27/**
28 * APIs for subscribing to Onos Event Messages.
29 */
Shravan Ambatibb6b4452016-05-04 13:25:28 -070030@Beta
Sanjana Agarwalcb4a3db2016-07-14 11:42:48 -070031public interface EventSubscriptionService {
Shravan Ambati7d199542016-04-22 16:09:05 -070032
33 /**
34 * Registers the external application to receive events generated in ONOS.
35 *
36 * @param appName Application Name
Shravan Ambati5a11e172016-07-21 15:55:28 -070037 * @return Registration Response DTO.
Shravan Ambati7d199542016-04-22 16:09:05 -070038 */
Shravan Ambati5a11e172016-07-21 15:55:28 -070039 RegistrationResponse registerListener(String appName);
Shravan Ambati7d199542016-04-22 16:09:05 -070040
41 /**
42 * Removes the Registered Listener.
43 *
44 * @param appName Application Name
45 */
46 void unregisterListener(String appName);
47
48 /**
49 * Allows registered listener to subscribe for a specific event type.
50 *
51 * @param subscriber Subscription data containing the event type
Shravan Ambati7d199542016-04-22 16:09:05 -070052 * @throws InvalidGroupIdException
53 * @throws InvalidApplicationException
54 */
55 void subscribe(EventSubscriber subscriber)
Shravan Ambatibb6b4452016-05-04 13:25:28 -070056 throws InvalidGroupIdException, InvalidApplicationException;
Shravan Ambati7d199542016-04-22 16:09:05 -070057
58 /**
59 * Allows the registered listener to unsubscribe for a specific event.
60 *
61 * @param subscriber Subscription data containing the event type
62 * @throws InvalidGroupIdException
63 * @throws InvalidApplicationException
64 */
65 void unsubscribe(EventSubscriber subscriber)
66 throws InvalidGroupIdException, InvalidApplicationException;
Sanjana Agarwalcb4a3db2016-07-14 11:42:48 -070067
68 /**
69 * Returns the event subscriber for various event types.
70 *
71 * @param type ONOS event type.
72 * @return List of event subscribers
73 */
74 List<EventSubscriber> getEventSubscribers(Type type);
Shravan Ambati7d199542016-04-22 16:09:05 -070075}