blob: 2c4b4c54f580d3a09670d44edca4a57aca83351b [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;
18
19import org.onosproject.event.AbstractEvent;
20
Andreas Papazoisd4712e22016-02-10 15:59:55 +020021import java.util.Optional;
22
Andrea Campanella101417d2015-12-11 17:58:07 -080023/**
24 * Describes network configuration event.
25 */
26public final class NetconfDeviceOutputEvent extends
27 AbstractEvent<NetconfDeviceOutputEvent.Type, Object> {
28
29 private final String messagePayload;
Andreas Papazoisd4712e22016-02-10 15:59:55 +020030 private final Optional<Integer> messageID;
Andrea Campanella101417d2015-12-11 17:58:07 -080031 private final NetconfDeviceInfo deviceInfo;
32
33 /**
34 * Type of network configuration events.
35 */
36 public enum Type {
37 /**
38 * Signifies that sent a reply to a request.
39 */
40 DEVICE_REPLY,
41
42 /**
43 * Signifies that the device sent a notification.
44 */
45 DEVICE_NOTIFICATION,
46
47 /**
48 * Signifies that the device is not reachable.
49 */
50 DEVICE_UNREGISTERED,
51
52 /**
53 * Signifies that the device has encountered an error.
54 */
55 DEVICE_ERROR,
56
57 }
58
59 /**
60 * Creates an event of a given type and for the specified subject and the
61 * current time.
62 *
63 * @param type event type
64 * @param subject event subject
65 * @param payload message from the device
66 * @param msgID id of the message related to the event
67 * @param netconfDeviceInfo device of event
68 */
Andreas Papazoisd4712e22016-02-10 15:59:55 +020069 public NetconfDeviceOutputEvent(Type type, Object subject, String payload,
70 Optional<Integer> msgID,
Andrea Campanella101417d2015-12-11 17:58:07 -080071 NetconfDeviceInfo netconfDeviceInfo) {
72 super(type, subject);
73 messagePayload = payload;
74 this.messageID = msgID;
75 deviceInfo = netconfDeviceInfo;
76 }
77
78 /**
79 * Creates an event of a given type and for the specified subject and time.
80 *
81 * @param type event type
82 * @param subject event subject
83 * @param payload message from the device
84 * @param msgID id of the message related to the event
85 * @param netconfDeviceInfo device of event
Andrea Campanella101417d2015-12-11 17:58:07 -080086 * @param time occurrence time
87 */
Andreas Papazoisd4712e22016-02-10 15:59:55 +020088 public NetconfDeviceOutputEvent(Type type, Object subject, String payload,
89 Optional<Integer> msgID,
90 NetconfDeviceInfo netconfDeviceInfo,
91 long time) {
Andrea Campanella101417d2015-12-11 17:58:07 -080092 super(type, subject, time);
93 messagePayload = payload;
94 deviceInfo = netconfDeviceInfo;
95 this.messageID = msgID;
96 }
97
Andrea Campanellab029b9e2016-01-29 11:05:36 -080098 /**
99 * return the message payload of the reply form the device.
100 * @return reply
101 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800102 public String getMessagePayload() {
103 return messagePayload;
104 }
105
Andrea Campanellab029b9e2016-01-29 11:05:36 -0800106 /**
107 * Event-related device information.
108 * @return information about the device
109 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800110 public NetconfDeviceInfo getDeviceInfo() {
111 return deviceInfo;
112 }
113
Andrea Campanellab029b9e2016-01-29 11:05:36 -0800114 /**
115 * Reply messageId.
116 * @return messageId
117 */
Andreas Papazoisd4712e22016-02-10 15:59:55 +0200118 public Optional<Integer> getMessageID() {
Andrea Campanella101417d2015-12-11 17:58:07 -0800119 return messageID;
120 }
121}