Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.yms.ydt; |
| 18 | |
| 19 | import java.util.List; |
| 20 | import java.util.Map; |
| 21 | import 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 26 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 27 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 32 | public interface YdtBuilder extends Ydt { |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 33 | |
| 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 39 | * tag name |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 40 | */ |
| 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 51 | * Adds a last child to YANG data tree; this method is to be used by |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 52 | * protocols which are unaware of the nature (single/multiple) of node and |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 53 | * also unaware of the operation type at every node (Example: RESTCONF). |
| 54 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 55 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 59 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 60 | * module-or-submodule-name ['@' date-arg] |
| 61 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 62 | * Example: testModule@2016-10-27. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 63 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 64 | * 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 gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 71 | * @throws IllegalArgumentException when method has been passed an illegal |
| 72 | * or inappropriate argument. |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 73 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 74 | void addChild(String name, String namespace) |
| 75 | throws IllegalArgumentException; |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 76 | |
| 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 80 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 81 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 85 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 86 | * module-or-submodule-name ['@' date-arg] |
| 87 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 88 | * Example: testModule@2016-10-27. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 89 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 90 | * 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 gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 98 | * @throws IllegalArgumentException when method has been passed an illegal |
| 99 | * or inappropriate argument. |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 100 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 101 | void addChild(String name, String namespace, YdtType ydtType) |
| 102 | throws IllegalArgumentException; |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 103 | |
| 104 | /** |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 105 | * Adds a last child to YANG data tree; this method is to be used by |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 106 | * protocols which are unaware of the nature (single/multiple) of node. |
| 107 | * This is an overloaded method with operation type. This method can |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 108 | * optionally be used when protocol doesn't want to specify operation type |
| 109 | * by keeping it null. |
| 110 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 111 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 115 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 116 | * module-or-submodule-name ['@' date-arg] |
| 117 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 118 | * Example: testModule@2016-10-27. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 119 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 120 | * 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 gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 128 | * @throws IllegalArgumentException when method has been passed an illegal |
| 129 | * or inappropriate argument. |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 130 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 131 | void addChild(String name, String namespace, YdtContextOperationType opType) |
| 132 | throws IllegalArgumentException; |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 133 | |
| 134 | /** |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 135 | * Adds a last child to YANG data tree; this method is to be used by |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 136 | * protocols which are aware of the nature (single/multiple) of node. |
| 137 | * This is an overloaded method with operation type. This method can |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 138 | * optionally be used when protocol doesn't want to specify operation type |
| 139 | * by keeping it null. |
| 140 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 141 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 145 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 146 | * module-or-submodule-name ['@' date-arg] |
| 147 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 148 | * Example: testModule@2016-10-27. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 149 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 150 | * 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 gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 159 | * @throws IllegalArgumentException when method has been passed an illegal |
| 160 | * or inappropriate argument. |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 161 | */ |
| 162 | void addChild(String name, String namespace, YdtType ydtType, |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 163 | YdtContextOperationType opType) |
| 164 | throws IllegalArgumentException; |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 165 | |
| 166 | /** |
| 167 | * Adds a last leaf with value to YANG data tree. Protocols unaware of |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 168 | * 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 Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 171 | * 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 gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 178 | * @throws IllegalArgumentException when method has been passed an illegal |
| 179 | * or inappropriate argument. |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 180 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 181 | void addLeaf(String name, String namespace, String value) |
| 182 | throws IllegalArgumentException; |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 183 | |
| 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 gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 195 | * @throws IllegalArgumentException when method has been passed an illegal |
| 196 | * or inappropriate argument. |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 197 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 198 | void addLeaf(String name, String namespace, Set<String> valueSet) |
| 199 | throws IllegalArgumentException; |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 200 | |
| 201 | /** |
VinodKumarS-Huawei | af9c7a7 | 2016-08-30 19:43:39 +0530 | [diff] [blame] | 202 | * Adds an instance of a child list node, or adds a child leaf list with |
| 203 | * multiple instance. |
| 204 | * In case the name and namespace identifies the child list node, then |
| 205 | * the values for all the key leaves must be passed in the same order of |
| 206 | * schema. Then the effective YANG data tree will be like adding a list |
| 207 | * node, followed by adding the key leaves as the child to the list node. |
| 208 | * After this operation, the call to getCurNode will return the list node. |
| 209 | * In case the name and namespace identifies the child leaf-list, then |
| 210 | * the values identifies the instance of leaf list. |
| 211 | * After this operation, the call to getCurNode will return the leaf-list |
| 212 | * node. |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 213 | * |
VinodKumarS-Huawei | af9c7a7 | 2016-08-30 19:43:39 +0530 | [diff] [blame] | 214 | * @param name name of child to be added |
| 215 | * @param namespace namespace of child to be added, if it's null, parent's |
| 216 | * namespace will be applied to child |
| 217 | * @param valueList values of the keys in URI in the same order |
| 218 | * as defined in YANG file |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 219 | * @param opType type of requested operation over a node |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 220 | * @throws IllegalArgumentException when method has been passed an illegal |
| 221 | * or inappropriate argument. |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 222 | */ |
VinodKumarS-Huawei | af9c7a7 | 2016-08-30 19:43:39 +0530 | [diff] [blame] | 223 | void addMultiInstanceChild(String name, String namespace, |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 224 | List<String> valueList, |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 225 | YdtContextOperationType opType) |
| 226 | throws IllegalArgumentException; |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 227 | |
| 228 | /** |
| 229 | * Traverses up in YANG data tree to the parent node, it is to be used when |
| 230 | * protocol is using context type "current" and wanted to traverse up the |
| 231 | * tree. |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 232 | * |
| 233 | * @throws IllegalStateException when application is not in an appropriate |
| 234 | * state for the requested operation. |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 235 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 236 | void traverseToParent() throws IllegalStateException; |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 237 | |
| 238 | /** |
| 239 | * Returns the current context information available in YDT node. |
| 240 | * |
| 241 | * @return current YDT context |
| 242 | */ |
| 243 | YdtContext getCurNode(); |
| 244 | |
| 245 | /** |
| 246 | * Sets default operation type. This operation type is taken if operation |
| 247 | * type is not explicitly specified in request. If default operation type |
| 248 | * is not set, merge will be taken as default operation type. |
| 249 | * |
| 250 | * @param ydtContextOperationType default edit operation type |
| 251 | */ |
| 252 | void setDefaultEditOperationType( |
| 253 | YdtContextOperationType ydtContextOperationType); |
| 254 | } |