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 |
| 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 77 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 78 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 82 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 83 | * module-or-submodule-name ['@' date-arg] |
| 84 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 85 | * Example: testModule@2016-10-27. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 86 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 87 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 99 | * 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] | 100 | * protocols which are unaware of the nature (single/multiple) of node. |
| 101 | * This is an overloaded method with operation type. This method can |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 102 | * optionally be used when protocol doesn't want to specify operation type |
| 103 | * by keeping it null. |
| 104 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 105 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 109 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 110 | * module-or-submodule-name ['@' date-arg] |
| 111 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 112 | * Example: testModule@2016-10-27. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 113 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 114 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 127 | * 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] | 128 | * protocols which are aware of the nature (single/multiple) of node. |
| 129 | * This is an overloaded method with operation type. This method can |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 130 | * optionally be used when protocol doesn't want to specify operation type |
| 131 | * by keeping it null. |
| 132 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 133 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 137 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 138 | * module-or-submodule-name ['@' date-arg] |
| 139 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 140 | * Example: testModule@2016-10-27. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 141 | * <p> |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 142 | * 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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 158 | * 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 Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 161 | * 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-Huawei | af9c7a7 | 2016-08-30 19:43:39 +0530 | [diff] [blame] | 186 | * 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 Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 197 | * |
VinodKumarS-Huawei | af9c7a7 | 2016-08-30 19:43:39 +0530 | [diff] [blame] | 198 | * @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 gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 203 | * @param opType type of requested operation over a node |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 204 | */ |
VinodKumarS-Huawei | af9c7a7 | 2016-08-30 19:43:39 +0530 | [diff] [blame] | 205 | void addMultiInstanceChild(String name, String namespace, |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 206 | List<String> valueList, |
| 207 | YdtContextOperationType opType); |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 208 | |
| 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 | } |