blob: 9cfc6950098141f2fdec5bc711ea503c7868118a [file] [log] [blame]
Gaurav Agrawalb102b012016-08-02 12:52:48 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Gaurav Agrawalb102b012016-08-02 12:52:48 +05303 *
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.yms.ydt;
18
19import java.util.List;
20import java.util.Map;
21import java.util.Set;
22
23/**
24 * Abstraction of an entity which provides interfaces to build and obtain YANG
25 * data tree which is data (sub)instance representation, abstract of protocol.
sonu gupta1bb37b82016-11-11 16:51:18 +053026 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +053027 * NBI protocols need to translate the protocol operation request, into a
28 * protocol independent abstract tree called the YANG data tree (YDT). In order
29 * to enable the protocol in building these abstract data tree, YANG
30 * management system provides a utility called the YANG data tree builder.
31 */
sonu gupta1bb37b82016-11-11 16:51:18 +053032public interface YdtBuilder extends Ydt {
Gaurav Agrawalb102b012016-08-02 12:52:48 +053033
34 /**
35 * Sets root node tag attributes. This is used by protocol
36 * to specify tag attributes associated with root resource.
37 *
38 * @param attributeTag map of root tags attribute values indexed by root
sonu gupta1bb37b82016-11-11 16:51:18 +053039 * tag name
Gaurav Agrawalb102b012016-08-02 12:52:48 +053040 */
41 void setRootTagAttributeMap(Map<String, String> attributeTag);
42
43 /**
44 * Returns map of tag attribute list associated with root resource.
45 *
46 * @return linked hash map of tag name with value
47 */
48 Map<String, String> getRootTagAttributeMap();
49
50 /**
sonu gupta1bb37b82016-11-11 16:51:18 +053051 * Adds a last child to YANG data tree; this method is to be used by
Gaurav Agrawalb102b012016-08-02 12:52:48 +053052 * protocols which are unaware of the nature (single/multiple) of node and
sonu gupta1bb37b82016-11-11 16:51:18 +053053 * also unaware of the operation type at every node (Example: RESTCONF).
54 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +053055 * Add child is used to add module/sub-module nodes also. Request may
56 * contain revision number corresponding to Module/sub-module in that
57 * case YMS expect revision number to be appended to module/sub-module
58 * name in the below mentioned format.
sonu gupta1bb37b82016-11-11 16:51:18 +053059 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +053060 * module-or-submodule-name ['@' date-arg]
61 * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
62 * Example: testModule@2016-10-27.
sonu gupta1bb37b82016-11-11 16:51:18 +053063 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +053064 * If the revision date is not specified YMS first search for
65 * registered module/sub-module without revision date, if still can't obtain
66 * then uses registered module/sub-module with latest revision date.
67 *
68 * @param name name of child to be added
69 * @param namespace namespace of child to be added, if it's null, parent's
70 * namespace will be applied to child
sonu guptaeff184b2016-11-24 12:43:49 +053071 * @throws IllegalArgumentException when method has been passed an illegal
72 * or inappropriate argument.
Gaurav Agrawalb102b012016-08-02 12:52:48 +053073 */
sonu guptaeff184b2016-11-24 12:43:49 +053074 void addChild(String name, String namespace)
75 throws IllegalArgumentException;
Gaurav Agrawalb102b012016-08-02 12:52:48 +053076
77 /**
78 * Adds a last child to YANG data tree, this method is to be used by
79 * protocols which are aware of the nature (single/multiple) of node.
sonu gupta1bb37b82016-11-11 16:51:18 +053080 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +053081 * Add child is used to add module/sub-module nodes also. Request may
82 * contain revision number corresponding to Module/sub-module in that
83 * case YMS expect revision number to be appended to module/sub-module
84 * name in the below mentioned format.
sonu gupta1bb37b82016-11-11 16:51:18 +053085 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +053086 * module-or-submodule-name ['@' date-arg]
87 * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
88 * Example: testModule@2016-10-27.
sonu gupta1bb37b82016-11-11 16:51:18 +053089 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +053090 * If the revision date is not specified YMS first search for
91 * registered module/sub-module without revision date, if still can't obtain
92 * then uses registered module/sub-module with latest revision date.
93 *
94 * @param name name of child to be added
95 * @param namespace namespace of child to be added, if it's null, parent's
96 * namespace will be applied to child
97 * @param ydtType type of YDT node to be added
sonu guptaeff184b2016-11-24 12:43:49 +053098 * @throws IllegalArgumentException when method has been passed an illegal
99 * or inappropriate argument.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530100 */
sonu guptaeff184b2016-11-24 12:43:49 +0530101 void addChild(String name, String namespace, YdtType ydtType)
102 throws IllegalArgumentException;
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530103
104 /**
sonu gupta1bb37b82016-11-11 16:51:18 +0530105 * Adds a last child to YANG data tree; this method is to be used by
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530106 * protocols which are unaware of the nature (single/multiple) of node.
107 * This is an overloaded method with operation type. This method can
sonu gupta1bb37b82016-11-11 16:51:18 +0530108 * optionally be used when protocol doesn't want to specify operation type
109 * by keeping it null.
110 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530111 * Add child is used to add module/sub-module nodes also. Request may
112 * contain revision number corresponding to Module/sub-module in that
113 * case YMS expect revision number to be appended to module/sub-module
114 * name in the below mentioned format.
sonu gupta1bb37b82016-11-11 16:51:18 +0530115 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530116 * module-or-submodule-name ['@' date-arg]
117 * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
118 * Example: testModule@2016-10-27.
sonu gupta1bb37b82016-11-11 16:51:18 +0530119 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530120 * If the revision date is not specified YMS first search for
121 * registered module/sub-module without revision date, if still can't obtain
122 * then uses registered module/sub-module with latest revision date.
123 *
124 * @param name name of child to be added
125 * @param namespace namespace of child to be added, if it's null, parent's
126 * namespace will be applied to child
127 * @param opType type of requested operation over a node
sonu guptaeff184b2016-11-24 12:43:49 +0530128 * @throws IllegalArgumentException when method has been passed an illegal
129 * or inappropriate argument.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530130 */
sonu guptaeff184b2016-11-24 12:43:49 +0530131 void addChild(String name, String namespace, YdtContextOperationType opType)
132 throws IllegalArgumentException;
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530133
134 /**
sonu gupta1bb37b82016-11-11 16:51:18 +0530135 * Adds a last child to YANG data tree; this method is to be used by
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530136 * protocols which are aware of the nature (single/multiple) of node.
137 * This is an overloaded method with operation type. This method can
sonu gupta1bb37b82016-11-11 16:51:18 +0530138 * optionally be used when protocol doesn't want to specify operation type
139 * by keeping it null.
140 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530141 * Add child is used to add module/sub-module nodes also. Request may
142 * contain revision number corresponding to Module/sub-module in that
143 * case YMS expect revision number to be appended to module/sub-module
144 * name in the below mentioned format.
sonu gupta1bb37b82016-11-11 16:51:18 +0530145 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530146 * module-or-submodule-name ['@' date-arg]
147 * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
148 * Example: testModule@2016-10-27.
sonu gupta1bb37b82016-11-11 16:51:18 +0530149 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530150 * If the revision date is not specified YMS first search for
151 * registered module/sub-module without revision date, if still can't obtain
152 * then uses registered module/sub-module with latest revision date.
153 *
154 * @param name name of child to be added
155 * @param namespace namespace of child to be added, if it's null, parent's
156 * namespace will be applied to child
157 * @param ydtType type of YDT node to be added
158 * @param opType type of requested operation over a node
sonu guptaeff184b2016-11-24 12:43:49 +0530159 * @throws IllegalArgumentException when method has been passed an illegal
160 * or inappropriate argument.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530161 */
162 void addChild(String name, String namespace, YdtType ydtType,
sonu guptaeff184b2016-11-24 12:43:49 +0530163 YdtContextOperationType opType)
164 throws IllegalArgumentException;
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530165
166 /**
167 * Adds a last leaf with value to YANG data tree. Protocols unaware of
sonu gupta1bb37b82016-11-11 16:51:18 +0530168 * nature of leaf (single/multiple) will use it to add both single instance
169 * and multi instance node. Protocols aware of nature of node will use it
170 * for single instance value node addition.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530171 * Value of leaf can be null which indicates selection node in get
172 * operation.
173 *
174 * @param name name of child to be added
175 * @param namespace namespace of child to be added, if it's null, parent's
176 * namespace will be applied to child
177 * @param value value of the child
sonu guptaeff184b2016-11-24 12:43:49 +0530178 * @throws IllegalArgumentException when method has been passed an illegal
179 * or inappropriate argument.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530180 */
sonu guptaeff184b2016-11-24 12:43:49 +0530181 void addLeaf(String name, String namespace, String value)
182 throws IllegalArgumentException;
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530183
184 /**
185 * Adds a last leaf with list of values to YANG data tree. This method is
186 * used by protocols which knows the nature (single/multiple) of node for
187 * multi instance node addition.
188 * Value of leaf can be null which indicates selection node in get
189 * operation.
190 *
191 * @param name name of child to be added
192 * @param namespace namespace of child to be added, if it's null, parent's
193 * namespace will be applied to child
194 * @param valueSet list of value of the child
sonu guptaeff184b2016-11-24 12:43:49 +0530195 * @throws IllegalArgumentException when method has been passed an illegal
196 * or inappropriate argument.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530197 */
sonu guptaeff184b2016-11-24 12:43:49 +0530198 void addLeaf(String name, String namespace, Set<String> valueSet)
199 throws IllegalArgumentException;
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530200
201 /**
Sean Condonfe6ceba2017-02-26 16:40:03 +0000202 * Adds a child node or leaf node based on schema.
203 *
204 * @param name name of child/leaf to be added
205 * @param namespace namespace of child/leaf to be added, if it's null, parent's
206 * namespace will be applied to child
207 * @throws IllegalArgumentException when method has been passed an illegal
208 * or inappropriate argument.
209 */
210 void addNode(String name, String namespace)
211 throws IllegalArgumentException;
212
213 /**
VinodKumarS-Huaweiaf9c7a72016-08-30 19:43:39 +0530214 * Adds an instance of a child list node, or adds a child leaf list with
215 * multiple instance.
216 * In case the name and namespace identifies the child list node, then
217 * the values for all the key leaves must be passed in the same order of
218 * schema. Then the effective YANG data tree will be like adding a list
219 * node, followed by adding the key leaves as the child to the list node.
220 * After this operation, the call to getCurNode will return the list node.
221 * In case the name and namespace identifies the child leaf-list, then
222 * the values identifies the instance of leaf list.
223 * After this operation, the call to getCurNode will return the leaf-list
224 * node.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530225 *
VinodKumarS-Huaweiaf9c7a72016-08-30 19:43:39 +0530226 * @param name name of child to be added
227 * @param namespace namespace of child to be added, if it's null, parent's
228 * namespace will be applied to child
229 * @param valueList values of the keys in URI in the same order
230 * as defined in YANG file
sonu gupta1bb37b82016-11-11 16:51:18 +0530231 * @param opType type of requested operation over a node
sonu guptaeff184b2016-11-24 12:43:49 +0530232 * @throws IllegalArgumentException when method has been passed an illegal
233 * or inappropriate argument.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530234 */
VinodKumarS-Huaweiaf9c7a72016-08-30 19:43:39 +0530235 void addMultiInstanceChild(String name, String namespace,
sonu gupta1bb37b82016-11-11 16:51:18 +0530236 List<String> valueList,
sonu guptaeff184b2016-11-24 12:43:49 +0530237 YdtContextOperationType opType)
238 throws IllegalArgumentException;
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530239
240 /**
241 * Traverses up in YANG data tree to the parent node, it is to be used when
242 * protocol is using context type "current" and wanted to traverse up the
243 * tree.
sonu guptaeff184b2016-11-24 12:43:49 +0530244 *
245 * @throws IllegalStateException when application is not in an appropriate
246 * state for the requested operation.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530247 */
sonu guptaeff184b2016-11-24 12:43:49 +0530248 void traverseToParent() throws IllegalStateException;
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530249
250 /**
251 * Returns the current context information available in YDT node.
252 *
253 * @return current YDT context
254 */
255 YdtContext getCurNode();
256
257 /**
258 * Sets default operation type. This operation type is taken if operation
259 * type is not explicitly specified in request. If default operation type
260 * is not set, merge will be taken as default operation type.
261 *
262 * @param ydtContextOperationType default edit operation type
263 */
264 void setDefaultEditOperationType(
265 YdtContextOperationType ydtContextOperationType);
266}