ecb6267f5f033018b1021e376c3734e276402285
[ccsdk/cds.git] /
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  * Modifications Copyright (c) 2019 IBM, Bell Canada
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api
18
19 import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.ModifyAction
20 import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.NetconfDatastore
21
22 interface NetconfRpcService {
23
24     /**
25      * Lock
26      *
27      * @param configTarget running or candidate, default candidate
28      * @return Device response
29      */
30     fun lock(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
31
32     /**
33      * Get-config
34      *
35      * @param filter filter content, default empty
36      * @param configTarget running or candidate, default running
37      * @return Device response
38      */
39     fun getConfig(filter: String = "", configTarget: String = NetconfDatastore.RUNNING.datastore): DeviceResponse
40
41     /**
42      * Delete config
43      *
44      * @param configTarget running or candidate, default candidate
45      * @return Device response
46      */
47     fun deleteConfig(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
48
49     /**
50      * Edit-config
51      *
52      * @param messageContent edit config content.
53      * @param configTarget running or candidate, default candidate
54      * @param editDefaultOperation, default set to none. Valid values: merge, replace, create, delete, none
55      * @return Device response
56      */
57     fun editConfig(messageContent: String, configTarget: String = NetconfDatastore.CANDIDATE.datastore,
58                    editDefaultOperation: String = ModifyAction.NONE.action): DeviceResponse
59
60     /**
61      * Invoke custom RPC as provided as input.
62      *
63      * Some use cases might required one to directly invoke a device
64      * specific RPC. The RPC must be correctly formatted.
65      *
66      * Ex: in order to rollback last submitted configuration
67      * for JUNOS devices, such RPC can be use:
68      * <code>
69      *  &lt;rpc>
70      *      &lt;load-configuration rollback="1"/>
71      *  &lt;/rpc>
72      * </code>
73      *
74      * @param rpc the rpc content.
75      */
76     fun invokeRpc(rpc: String): DeviceResponse
77
78     /**
79      * Validate
80      *
81      * @param configTarget running or candidate, default candidate
82      * @return Device response
83      */
84     fun validate(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
85
86     /**
87      * Commit
88      *
89      * @param confirmed Perform a confirmed <commit> operation. If flag set to true,
90      * then it is expected to have a follow-up <commit> operation to confirm the request
91      * @param confirmTimeout Timeout period for confirmed commit, in seconds.
92      * @param persist Make the confirmed commit survive a session termination, and
93      * set a token on the ongoing confirmed commit.
94      * @param persistId Used to issue a follow-up confirmed commit or a confirming
95      * commit from any session, with the token from the previous <commit> operation.
96      * If unspecified, the confirm timeout defaults to 600 seconds.
97      * @return Device response
98      */
99     fun commit(confirmed: Boolean = false, confirmTimeout: Int = 60, persist: String = "",
100                persistId: String = ""): DeviceResponse
101
102     /**
103      * Cancels an ongoing confirmed commit.  If the <persist-id> parameter is not given,
104      * the <cancel-commit> operation MUST be issued on the same session that issued
105      * the confirmed commit.
106      *
107      * @param persistId Cancels a persistent confirmed commit.  The value MUST be equal
108      * to the value given in the <persist> parameter to the <commit> operation.
109      * If the value does not match, the operation fails with an "invalid-value" error.
110      */
111     fun cancelCommit(persistId: String = ""): DeviceResponse
112
113     /**
114      * Unlock
115      *
116      * @param configTarget running or candidate, default candidate
117      * @return Device response
118      */
119     fun unLock(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
120
121     /**
122      * Discard config
123      *
124      * @return Device response
125      */
126     fun discardConfig(): DeviceResponse
127
128     /**
129      * Close session
130      *
131      * @param force force closeSession
132      * @return Device response
133      */
134     fun closeSession(force: Boolean): DeviceResponse
135
136     /**
137      * Executes an RPC request to the netconf server.
138      *
139      * @param request the XML containing the RPC request for the server.
140      * @return Device response
141      */
142     fun asyncRpc(request: String, messageId: String): DeviceResponse
143
144     /**
145      * Get
146      *
147      * @param filter filter content for operational command
148      * @return Device response
149      */
150     fun get(filter: String): DeviceResponse
151 }