CHANGE in module query include RPCs as well
diff --git a/src/README.md b/src/README.md
index cf52829..d30742f 100644
--- a/src/README.md
+++ b/src/README.md
@@ -282,7 +282,7 @@
* key: sessions (array of ints), value: array of SIDs
* key: filters (array of strings with same index order as sessions), value: array of XPath (with "prefix" = module name) values of target node in schema (start with '/') or module names (do not start with '/')
-In module query, the top-nodes array includes only nodes that can appear in data or some descendant can (container, choice, leaf, leaflist, list, anyxml).
+In module query, the top-nodes array includes only nodes that can appear in data or some descendant can (container, choice, leaf, leaflist, list, anyxml). The rpcs array contains all RPCs defined in the module.
Optional:
diff --git a/src/netopeerguid.c b/src/netopeerguid.c
index 69b2f3c..fc2397f 100644
--- a/src/netopeerguid.c
+++ b/src/netopeerguid.c
@@ -1013,7 +1013,7 @@
static void
node_metadata_model(const struct lys_module *module, json_object *parent)
{
- json_object *obj, *array, *item;
+ json_object *obj, *array, *array2, *item;
const struct lys_node *node;
int i;
@@ -1078,22 +1078,34 @@
json_object_object_add(parent, "includes", array);
}
- /* top-nodes */
+ /* top-nodes and RPCs */
node = NULL;
array = NULL;
+ array2 = NULL;
while ((node = lys_getnext(node, NULL, module, LYS_GETNEXT_WITHCHOICE))) {
- if (node->nodetype & (LYS_RPC | LYS_NOTIF)) {
+ if (node->nodetype == LYS_NOTIF) {
continue;
}
- if (!array) {
- array = json_object_new_array();
+ if (node->nodetype == LYS_RPC) {
+ if (!array2) {
+ array2 = json_object_new_array();
+ }
+ item = json_object_new_string(node->name);
+ json_object_array_add(array2, item);
+ } else {
+ if (!array) {
+ array = json_object_new_array();
+ }
+ item = json_object_new_string(node->name);
+ json_object_array_add(array, item);
}
- item = json_object_new_string(node->name);
- json_object_array_add(array, item);
}
if (array) {
json_object_object_add(parent, "top-nodes", array);
}
+ if (array2) {
+ json_object_object_add(parent, "rpcs", array2);
+ }
}
/**