blob: bbfe6c3613f3f71d1b8c9ea63a0bc9c982c964db [file] [log] [blame]
Gaurav Agrawalb102b012016-08-02 12:52:48 +05301/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
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
71 */
72 void addChild(String name, String namespace);
73
74 /**
75 * Adds a last child to YANG data tree, this method is to be used by
76 * protocols which are aware of the nature (single/multiple) of node.
sonu gupta1bb37b82016-11-11 16:51:18 +053077 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +053078 * Add child is used to add module/sub-module nodes also. Request may
79 * contain revision number corresponding to Module/sub-module in that
80 * case YMS expect revision number to be appended to module/sub-module
81 * name in the below mentioned format.
sonu gupta1bb37b82016-11-11 16:51:18 +053082 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +053083 * module-or-submodule-name ['@' date-arg]
84 * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
85 * Example: testModule@2016-10-27.
sonu gupta1bb37b82016-11-11 16:51:18 +053086 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +053087 * If the revision date is not specified YMS first search for
88 * registered module/sub-module without revision date, if still can't obtain
89 * then uses registered module/sub-module with latest revision date.
90 *
91 * @param name name of child to be added
92 * @param namespace namespace of child to be added, if it's null, parent's
93 * namespace will be applied to child
94 * @param ydtType type of YDT node to be added
95 */
96 void addChild(String name, String namespace, YdtType ydtType);
97
98 /**
sonu gupta1bb37b82016-11-11 16:51:18 +053099 * Adds a last child to YANG data tree; this method is to be used by
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530100 * protocols which are unaware of the nature (single/multiple) of node.
101 * This is an overloaded method with operation type. This method can
sonu gupta1bb37b82016-11-11 16:51:18 +0530102 * optionally be used when protocol doesn't want to specify operation type
103 * by keeping it null.
104 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530105 * Add child is used to add module/sub-module nodes also. Request may
106 * contain revision number corresponding to Module/sub-module in that
107 * case YMS expect revision number to be appended to module/sub-module
108 * name in the below mentioned format.
sonu gupta1bb37b82016-11-11 16:51:18 +0530109 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530110 * module-or-submodule-name ['@' date-arg]
111 * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
112 * Example: testModule@2016-10-27.
sonu gupta1bb37b82016-11-11 16:51:18 +0530113 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530114 * If the revision date is not specified YMS first search for
115 * registered module/sub-module without revision date, if still can't obtain
116 * then uses registered module/sub-module with latest revision date.
117 *
118 * @param name name of child to be added
119 * @param namespace namespace of child to be added, if it's null, parent's
120 * namespace will be applied to child
121 * @param opType type of requested operation over a node
122 */
123 void addChild(String name, String namespace,
124 YdtContextOperationType opType);
125
126 /**
sonu gupta1bb37b82016-11-11 16:51:18 +0530127 * Adds a last child to YANG data tree; this method is to be used by
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530128 * protocols which are aware of the nature (single/multiple) of node.
129 * This is an overloaded method with operation type. This method can
sonu gupta1bb37b82016-11-11 16:51:18 +0530130 * optionally be used when protocol doesn't want to specify operation type
131 * by keeping it null.
132 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530133 * Add child is used to add module/sub-module nodes also. Request may
134 * contain revision number corresponding to Module/sub-module in that
135 * case YMS expect revision number to be appended to module/sub-module
136 * name in the below mentioned format.
sonu gupta1bb37b82016-11-11 16:51:18 +0530137 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530138 * module-or-submodule-name ['@' date-arg]
139 * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
140 * Example: testModule@2016-10-27.
sonu gupta1bb37b82016-11-11 16:51:18 +0530141 * <p>
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530142 * If the revision date is not specified YMS first search for
143 * registered module/sub-module without revision date, if still can't obtain
144 * then uses registered module/sub-module with latest revision date.
145 *
146 * @param name name of child to be added
147 * @param namespace namespace of child to be added, if it's null, parent's
148 * namespace will be applied to child
149 * @param ydtType type of YDT node to be added
150 * @param opType type of requested operation over a node
151 */
152 void addChild(String name, String namespace, YdtType ydtType,
153 YdtContextOperationType opType);
154
155
156 /**
157 * Adds a last leaf with value to YANG data tree. Protocols unaware of
sonu gupta1bb37b82016-11-11 16:51:18 +0530158 * nature of leaf (single/multiple) will use it to add both single instance
159 * and multi instance node. Protocols aware of nature of node will use it
160 * for single instance value node addition.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530161 * Value of leaf can be null which indicates selection node in get
162 * operation.
163 *
164 * @param name name of child to be added
165 * @param namespace namespace of child to be added, if it's null, parent's
166 * namespace will be applied to child
167 * @param value value of the child
168 */
169 void addLeaf(String name, String namespace, String value);
170
171 /**
172 * Adds a last leaf with list of values to YANG data tree. This method is
173 * used by protocols which knows the nature (single/multiple) of node for
174 * multi instance node addition.
175 * Value of leaf can be null which indicates selection node in get
176 * operation.
177 *
178 * @param name name of child to be added
179 * @param namespace namespace of child to be added, if it's null, parent's
180 * namespace will be applied to child
181 * @param valueSet list of value of the child
182 */
183 void addLeaf(String name, String namespace, Set<String> valueSet);
184
185 /**
VinodKumarS-Huaweiaf9c7a72016-08-30 19:43:39 +0530186 * Adds an instance of a child list node, or adds a child leaf list with
187 * multiple instance.
188 * In case the name and namespace identifies the child list node, then
189 * the values for all the key leaves must be passed in the same order of
190 * schema. Then the effective YANG data tree will be like adding a list
191 * node, followed by adding the key leaves as the child to the list node.
192 * After this operation, the call to getCurNode will return the list node.
193 * In case the name and namespace identifies the child leaf-list, then
194 * the values identifies the instance of leaf list.
195 * After this operation, the call to getCurNode will return the leaf-list
196 * node.
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530197 *
VinodKumarS-Huaweiaf9c7a72016-08-30 19:43:39 +0530198 * @param name name of child to be added
199 * @param namespace namespace of child to be added, if it's null, parent's
200 * namespace will be applied to child
201 * @param valueList values of the keys in URI in the same order
202 * as defined in YANG file
sonu gupta1bb37b82016-11-11 16:51:18 +0530203 * @param opType type of requested operation over a node
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530204 */
VinodKumarS-Huaweiaf9c7a72016-08-30 19:43:39 +0530205 void addMultiInstanceChild(String name, String namespace,
sonu gupta1bb37b82016-11-11 16:51:18 +0530206 List<String> valueList,
207 YdtContextOperationType opType);
Gaurav Agrawalb102b012016-08-02 12:52:48 +0530208
209 /**
210 * Traverses up in YANG data tree to the parent node, it is to be used when
211 * protocol is using context type "current" and wanted to traverse up the
212 * tree.
213 */
214 void traverseToParent();
215
216 /**
217 * Returns the current context information available in YDT node.
218 *
219 * @return current YDT context
220 */
221 YdtContext getCurNode();
222
223 /**
224 * Sets default operation type. This operation type is taken if operation
225 * type is not explicitly specified in request. If default operation type
226 * is not set, merge will be taken as default operation type.
227 *
228 * @param ydtContextOperationType default edit operation type
229 */
230 void setDefaultEditOperationType(
231 YdtContextOperationType ydtContextOperationType);
232}