blob: da8d1c3f5b2efb5bfd1afa1652f9b3054d7bfe13 [file] [log] [blame]
Ray Milkey2d572dd2017-04-14 10:01:24 -07001/*
Shravan Ambati7d199542016-04-22 16:09:05 -07002 * Copyright 2016-present Open Networking Laboratory
Ray Milkey2d572dd2017-04-14 10:01:24 -07003 *
Shravan Ambati7d199542016-04-22 16:09:05 -07004 * 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
Ray Milkey2d572dd2017-04-14 10:01:24 -07007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
Shravan Ambati7d199542016-04-22 16:09:05 -070010 * 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.kafkaintegration.api;
17
Shravan Ambati5a11e172016-07-21 15:55:28 -070018import java.util.List;
19
Shravan Ambati7d199542016-04-22 16:09:05 -070020import org.onosproject.kafkaintegration.api.dto.EventSubscriber;
Sanjana Agarwalcb4a3db2016-07-14 11:42:48 -070021import org.onosproject.kafkaintegration.api.dto.OnosEvent.Type;
Shravan Ambati5a11e172016-07-21 15:55:28 -070022import org.onosproject.kafkaintegration.api.dto.RegistrationResponse;
Shravan Ambati7d199542016-04-22 16:09:05 -070023import org.onosproject.kafkaintegration.errors.InvalidApplicationException;
24import org.onosproject.kafkaintegration.errors.InvalidGroupIdException;
Shravan Ambatibb6b4452016-05-04 13:25:28 -070025
26import com.google.common.annotations.Beta;
Shravan Ambati7d199542016-04-22 16:09:05 -070027
28/**
29 * APIs for subscribing to Onos Event Messages.
30 */
Shravan Ambatibb6b4452016-05-04 13:25:28 -070031@Beta
Sanjana Agarwalcb4a3db2016-07-14 11:42:48 -070032public interface EventSubscriptionService {
Shravan Ambati7d199542016-04-22 16:09:05 -070033
34 /**
35 * Registers the external application to receive events generated in ONOS.
36 *
37 * @param appName Application Name
Shravan Ambati5a11e172016-07-21 15:55:28 -070038 * @return Registration Response DTO.
Shravan Ambati7d199542016-04-22 16:09:05 -070039 */
Shravan Ambati5a11e172016-07-21 15:55:28 -070040 RegistrationResponse registerListener(String appName);
Shravan Ambati7d199542016-04-22 16:09:05 -070041
42 /**
43 * Removes the Registered Listener.
44 *
45 * @param appName Application Name
46 */
47 void unregisterListener(String appName);
48
49 /**
50 * Allows registered listener to subscribe for a specific event type.
51 *
52 * @param subscriber Subscription data containing the event type
Shravan Ambati7d199542016-04-22 16:09:05 -070053 * @throws InvalidGroupIdException
54 * @throws InvalidApplicationException
55 */
56 void subscribe(EventSubscriber subscriber)
Shravan Ambatibb6b4452016-05-04 13:25:28 -070057 throws InvalidGroupIdException, InvalidApplicationException;
Shravan Ambati7d199542016-04-22 16:09:05 -070058
59 /**
60 * Allows the registered listener to unsubscribe for a specific event.
61 *
62 * @param subscriber Subscription data containing the event type
63 * @throws InvalidGroupIdException
64 * @throws InvalidApplicationException
65 */
66 void unsubscribe(EventSubscriber subscriber)
67 throws InvalidGroupIdException, InvalidApplicationException;
Sanjana Agarwalcb4a3db2016-07-14 11:42:48 -070068
69 /**
70 * Returns the event subscriber for various event types.
71 *
72 * @param type ONOS event type.
73 * @return List of event subscribers
74 */
75 List<EventSubscriber> getEventSubscribers(Type type);
Shravan Ambati7d199542016-04-22 16:09:05 -070076}