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. |
| 26 | * |
| 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 | */ |
| 32 | public interface YdtBuilder |
| 33 | extends Ydt { |
| 34 | |
| 35 | /** |
| 36 | * Sets root node tag attributes. This is used by protocol |
| 37 | * to specify tag attributes associated with root resource. |
| 38 | * |
| 39 | * @param attributeTag map of root tags attribute values indexed by root |
| 40 | * tag name. |
| 41 | */ |
| 42 | void setRootTagAttributeMap(Map<String, String> attributeTag); |
| 43 | |
| 44 | /** |
| 45 | * Returns map of tag attribute list associated with root resource. |
| 46 | * |
| 47 | * @return linked hash map of tag name with value |
| 48 | */ |
| 49 | Map<String, String> getRootTagAttributeMap(); |
| 50 | |
| 51 | /** |
| 52 | * Adds a last child to YANG data tree, this method is to be used by |
| 53 | * protocols which are unaware of the nature (single/multiple) of node and |
| 54 | * also unaware of the operation type at every node(Example: RESTCONF). |
| 55 | * |
| 56 | * Add child is used to add module/sub-module nodes also. Request may |
| 57 | * contain revision number corresponding to Module/sub-module in that |
| 58 | * case YMS expect revision number to be appended to module/sub-module |
| 59 | * name in the below mentioned format. |
| 60 | * module-or-submodule-name ['@' date-arg] |
| 61 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 62 | * Example: testModule@2016-10-27. |
| 63 | * |
| 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. |
| 77 | * |
| 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. |
| 82 | * module-or-submodule-name ['@' date-arg] |
| 83 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 84 | * Example: testModule@2016-10-27. |
| 85 | * |
| 86 | * If the revision date is not specified YMS first search for |
| 87 | * registered module/sub-module without revision date, if still can't obtain |
| 88 | * then uses registered module/sub-module with latest revision date. |
| 89 | * |
| 90 | * @param name name of child to be added |
| 91 | * @param namespace namespace of child to be added, if it's null, parent's |
| 92 | * namespace will be applied to child |
| 93 | * @param ydtType type of YDT node to be added |
| 94 | */ |
| 95 | void addChild(String name, String namespace, YdtType ydtType); |
| 96 | |
| 97 | /** |
| 98 | * Adds a last child to YANG data tree, this method is to be used by |
| 99 | * protocols which are unaware of the nature (single/multiple) of node. |
| 100 | * This is an overloaded method with operation type. This method can |
| 101 | * optionally |
| 102 | * be used when protocol doesn't want to specify operation type by |
| 103 | * keeping it null. |
| 104 | * |
| 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. |
| 109 | * module-or-submodule-name ['@' date-arg] |
| 110 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 111 | * Example: testModule@2016-10-27. |
| 112 | * |
| 113 | * If the revision date is not specified YMS first search for |
| 114 | * registered module/sub-module without revision date, if still can't obtain |
| 115 | * then uses registered module/sub-module with latest revision date. |
| 116 | * |
| 117 | * @param name name of child to be added |
| 118 | * @param namespace namespace of child to be added, if it's null, parent's |
| 119 | * namespace will be applied to child |
| 120 | * @param opType type of requested operation over a node |
| 121 | */ |
| 122 | void addChild(String name, String namespace, |
| 123 | YdtContextOperationType opType); |
| 124 | |
| 125 | /** |
| 126 | * Adds a last child to YANG data tree, this method is to be used by |
| 127 | * protocols which are aware of the nature (single/multiple) of node. |
| 128 | * This is an overloaded method with operation type. This method can |
| 129 | * optionally |
| 130 | * be used when protocol doesn't want to specify operation type by |
| 131 | * keeping it null. |
| 132 | * |
| 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. |
| 137 | * module-or-submodule-name ['@' date-arg] |
| 138 | * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT |
| 139 | * Example: testModule@2016-10-27. |
| 140 | * |
| 141 | * If the revision date is not specified YMS first search for |
| 142 | * registered module/sub-module without revision date, if still can't obtain |
| 143 | * then uses registered module/sub-module with latest revision date. |
| 144 | * |
| 145 | * @param name name of child to be added |
| 146 | * @param namespace namespace of child to be added, if it's null, parent's |
| 147 | * namespace will be applied to child |
| 148 | * @param ydtType type of YDT node to be added |
| 149 | * @param opType type of requested operation over a node |
| 150 | */ |
| 151 | void addChild(String name, String namespace, YdtType ydtType, |
| 152 | YdtContextOperationType opType); |
| 153 | |
| 154 | |
| 155 | /** |
| 156 | * Adds a last leaf with value to YANG data tree. Protocols unaware of |
| 157 | * nature |
| 158 | * of leaf (single/multiple) will use it to add both single instance and |
| 159 | * multi instance node. Protocols aware of nature of node will use it for |
| 160 | * single instance value node addition. |
| 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 |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 203 | */ |
VinodKumarS-Huawei | af9c7a7 | 2016-08-30 19:43:39 +0530 | [diff] [blame] | 204 | void addMultiInstanceChild(String name, String namespace, |
| 205 | List<String> valueList); |
Gaurav Agrawal | b102b01 | 2016-08-02 12:52:48 +0530 | [diff] [blame] | 206 | |
| 207 | /** |
| 208 | * Traverses up in YANG data tree to the parent node, it is to be used when |
| 209 | * protocol is using context type "current" and wanted to traverse up the |
| 210 | * tree. |
| 211 | */ |
| 212 | void traverseToParent(); |
| 213 | |
| 214 | /** |
| 215 | * Returns the current context information available in YDT node. |
| 216 | * |
| 217 | * @return current YDT context |
| 218 | */ |
| 219 | YdtContext getCurNode(); |
| 220 | |
| 221 | /** |
| 222 | * Sets default operation type. This operation type is taken if operation |
| 223 | * type is not explicitly specified in request. If default operation type |
| 224 | * is not set, merge will be taken as default operation type. |
| 225 | * |
| 226 | * @param ydtContextOperationType default edit operation type |
| 227 | */ |
| 228 | void setDefaultEditOperationType( |
| 229 | YdtContextOperationType ydtContextOperationType); |
| 230 | } |