2 * Copyright © 2017-2018 AT&T Intellectual Property.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.data
19 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
20 import java.io.IOException
23 class NetconfExecutionRequest {
24 lateinit var requestId: String
25 val action: String? = null
26 val source: String? = null
27 val loginKey: String? = null
28 val loginAccount: String? = null
29 val targetIP: String? = null
31 val connectionTimeoutSec: Int = 0
32 val implementationScript: String? = null
33 val context: MutableMap<String, Any> = mutableMapOf()
36 class DeviceResponse {
37 lateinit var deviceInfo: DeviceInfo
38 lateinit var status: String
39 var errorMessage: String? = null
40 var responseMessage: String? = null
41 var requestMessage: String? = null
42 var subDeviceResponse: MutableMap<Any, Any>? = null
44 fun addSubDeviceResponse(key: String, subDeviceResponse: DeviceResponse) {
45 if (this.subDeviceResponse == null) {
46 this.subDeviceResponse = hashMapOf()
48 this.subDeviceResponse!![key] = subDeviceResponse
52 class NetconfExecutionResponse {
53 val status: String? = null
54 val errorMessage: String? = null
55 val responseData: Any = Any()
58 open class NetconfException(message: String) : IOException(message)
60 class NetconfDeviceOutputEvent {
61 private var type: NetconfDeviceOutputEvent.Type
62 private var messagePayload: String? = null
63 private var messageID: String? = null
64 private var deviceInfo: DeviceInfo? = null
65 private var subject: Any? = null
66 private var time: Long = 0
69 * Type of device related events.
80 * Creates an event of a given type and for the specified subject and the current time.
82 * @param type event type
83 * @param subject event subject
84 * @param payload message from the device
85 * @param msgID id of the message related to the event
86 * @param netconfDeviceInfo device of event
88 constructor(type: Type, subject: String, payload: String, msgID: Optional<String>, netconfDeviceInfo: DeviceInfo) {
90 this.subject = subject
91 this.messagePayload = payload
92 this.deviceInfo = netconfDeviceInfo
93 this.messageID = msgID.get()
97 * Creates an event of a given type and for the specified subject and time.
99 * @param type event type
100 * @param subject event subject
101 * @param payload message from the device
102 * @param msgID id of the message related to the event
103 * @param netconfDeviceInfo device of event
104 * @param time occurrence time
106 constructor(type: Type, subject: Any, payload: String, msgID: String, netconfDeviceInfo: DeviceInfo, time: Long) {
108 this.subject = subject
110 this.messagePayload = payload
111 this.deviceInfo = netconfDeviceInfo
112 this.messageID = msgID