data FEATURE add lyd_new_ext_inner()
diff --git a/doc/transition.dox b/doc/transition.dox
index aac54cc..2699d4f 100644
--- a/doc/transition.dox
+++ b/doc/transition.dox
@@ -354,7 +354,7 @@
* lyd_new(), lyd_new_output() | ::lyd_new_inner(), ::lyd_new_list(), ::lyd_new_list2() | Redesigned functionality to better fit new lyd_node structures, creating RPC's output data is now done via a flag parameter of the functions.
* lyd_new_leaf(), lyd_new_output_leaf() | ::lyd_new_term() | ^
* lyd_new_anydata(), lyd_new_output_anydata() | ::lyd_new_any() | ^
- * - | ::lyd_new_ext_term() | Additional functionality to lyd_new_* functions to cover top-level nodes in extension instances.
+ * lyd_new_yangdata() | ::lyd_new_ext_inner(), ::lyd_new_ext_term() | Additional functionality to lyd_new_* functions to cover top-level nodes in extension instances.
* lyd_insert_attr() | ::lyd_new_meta() | Unify naming used in other functions with the similar functionality.
* - | ::lyd_new_attr() | Added functionality to store the data (temporarily) not connected with schema definitions.
* - | ::lyd_new_attr2() | ^
@@ -362,7 +362,6 @@
* - | ::lyd_new_opaq2() | ^
* - | ::lyd_new_path2() | Supplement functionality to ::lyd_new_path().
* lyd_insert() | ::lyd_insert_child() | Renamed to better distinguish from ::lyd_insert_sibling().
- * lyd_new_yangdata() | TBD | Not yet implemented feature.
* lyd_change_leaf() | ::lyd_change_term() | Align naming with changed names of data structures.
* - | ::lyd_change_meta() | Transferred functionality of ::lyd_change_term() to metadata.
* - | ::lyd_any_copy_value() | Added functionality.
diff --git a/src/tree_data.c b/src/tree_data.c
index 069d94c..f611481 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -855,7 +855,7 @@
schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0,
LYS_CONTAINER | LYS_NOTIF | LYS_RPC | LYS_ACTION, output ? LYS_GETNEXT_OUTPUT : 0);
- LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Inner node (and not a list) \"%s\" not found.", name), LY_ENOTFOUND);
+ LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Inner node (not a list) \"%s\" not found.", name), LY_ENOTFOUND);
LY_CHECK_RET(lyd_create_inner(schema, &ret));
if (parent) {
@@ -869,6 +869,33 @@
}
API LY_ERR
+lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node)
+{
+ struct lyd_node *ret = NULL;
+ const struct lysc_node *schema;
+ struct ly_ctx *ctx = ext ? ext->module->ctx : NULL;
+
+ LY_CHECK_ARG_RET(ctx, ext, node, name, LY_EINVAL);
+
+ schema = lysc_ext_find_node(ext, NULL, name, 0, LYS_CONTAINER | LYS_NOTIF | LYS_RPC | LYS_ACTION, 0);
+ if (!schema) {
+ if (ext->argument) {
+ LOGERR(ctx, LY_EINVAL, "Inner node (not a list) \"%s\" not found in instance \"%s\" of extension %s.",
+ name, ext->argument, ext->def->name);
+ } else {
+ LOGERR(ctx, LY_EINVAL, "Inner node (not a list) \"%s\" not found in instance of extension %s.",
+ name, ext->def->name);
+ }
+ return LY_ENOTFOUND;
+ }
+ LY_CHECK_RET(lyd_create_inner(schema, &ret));
+
+ *node = ret;
+
+ return LY_SUCCESS;
+}
+
+API LY_ERR
lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
struct lyd_node **node, ...)
{
diff --git a/src/tree_data.h b/src/tree_data.h
index 83b4729..4d8b985 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -128,7 +128,7 @@
* Note, that in case the node is defined in an extension instance, the functions mentioned above do not work until you
* provide parent where the new node is supposed to be inserted. The reason is that all the functions searches for the
* top-level nodes directly inside modules. To create a top-level node defined in an extension instance, use
- * ::lyd_new_ext_term() function.
+ * ::lyd_new_ext_inner() and ::lyd_new_ext_term() functions.
*
* The [metadata](@ref howtoPluginsExtensionsMetadata) (and attributes in opaq nodes) can be created with ::lyd_new_meta()
* and ::lyd_new_attr().
@@ -173,6 +173,7 @@
* - ::lyd_new_path()
* - ::lyd_new_path2()
*
+ * - ::lyd_new_ext_inner()
* - ::lyd_new_ext_term()
*
* - ::lyd_dup_single()
@@ -907,6 +908,10 @@
/**
* @brief Create a new inner node in the data tree.
*
+ * To create list, use ::lyd_new_list() or ::lyd_new_list2().
+ *
+ * To create a top-level inner node defined in an extension instance, use ::lyd_new_ext_inner().
+ *
* @param[in] parent Parent node for the node being created. NULL in case of creating a top level element.
* @param[in] module Module of the node being created. If NULL, @p parent module will be used.
* @param[in] name Schema node name of the new data node. The node can be #LYS_CONTAINER, #LYS_NOTIF, #LYS_RPC, or #LYS_ACTION.
@@ -919,6 +924,21 @@
struct lyd_node **node);
/**
+ * @brief Create a new top-level inner node defined in the given extension instance.
+ *
+ * To create list, use ::lyd_new_list() or ::lyd_new_list2().
+ *
+ * To create an inner node with parent (no matter if defined inside extension instance or a standard tree) or a top-level
+ * node of a standard module's tree, use ::lyd_new_inner().
+ *
+ * @param[in] ext Extension instance where the inner node being created is defined.
+ * @param[in] name Schema node name of the new data node. The node can be #LYS_CONTAINER, #LYS_NOTIF, #LYS_RPC, or #LYS_ACTION.
+ * @param[out] node The created node.
+ * @return LY_ERR value.
+ */
+LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node);
+
+/**
* @brief Create a new list node in the data tree.
*
* @param[in] parent Parent node for the node being created. NULL in case of creating a top level element.