* RESTCONF "insert" and "point" query parameters supported

* Yang Netconf leaf/leaf-list insert support
  * For "ordered-by user" leafs and leaf-lists, the insert and value/key attributes are supported according to RFC7950 Sections 7.7.9 and 7.8.6

* Fixed RESTCONF api-path leaf-list selection was not made properly
This commit is contained in:
Olof hagsand 2019-07-31 14:04:27 +02:00
parent d7a8cf5b0c
commit 2d9d204f69
20 changed files with 740 additions and 105 deletions

View file

@ -625,6 +625,7 @@ xml_child_nr_type(cxobj *xn,
* @retval xml The child xml node
* @retval NULL if no such child, or empty child
* @see xml_child_i_type
* @see xml_child_order
*/
cxobj *
xml_child_i(cxobj *xn,
@ -673,6 +674,29 @@ xml_child_i_set(cxobj *xt,
return 0;
}
/*! Get the order of child
* @param[in] xp xml parent node
* @param[in] xc the xml child to look for
* @retval xml The child xml node
* @retval i The order of the child
* @retval -1 if no such child, or empty child
* @see xml_child_i
*/
int
xml_child_order(cxobj *xp,
cxobj *xc)
{
cxobj *x = NULL;
int i = 0;
while ((x = xml_child_each(xp, x, -1)) != NULL) {
if (x == xc)
return i;
i++;
}
return -1;
}
/*! Iterator over xml children objects
*
* @note Never manipulate the child-list during operation or using the
@ -2375,6 +2399,8 @@ xml_operation(char *opstr,
return 0;
}
/*! Map xml operation from enumeration to string
* @param[in] op enumeration operation, eg OP_MERGE,...
* @retval str String, eg "merge". Static string, no free necessary
@ -2406,6 +2432,32 @@ xml_operation2str(enum operation_type op)
return "none";
}
}
/*! Map xml insert attribute from string to enumeration
* @param[in] instr String, eg "first"
* @param[out] ins Enumeration, eg INS_FIRST
* @code
* enum insert_type ins;
* xml_operation("last", &ins)
* @endcode
*/
int
xml_attr_insert2val(char *instr,
enum insert_type *ins)
{
if (strcmp("first", instr) == 0)
*ins = INS_FIRST;
else if (strcmp("last", instr) == 0)
*ins = INS_LAST;
else if (strcmp("before", instr) == 0)
*ins = INS_BEFORE;
else if (strcmp("after", instr) == 0)
*ins = INS_AFTER;
else{
clicon_err(OE_XML, 0, "Bad-attribute operation: %s", instr);
return -1;
}
return 0;
}
/*! Specialization of clicon_debug with xml tree
* @param[in] level log level, eg LOG_DEBUG,LOG_INFO,...,LOG_EMERG.