summaryrefslogtreecommitdiffstats
path: root/src/afb-apiset.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-08-11 11:08:56 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-08-11 16:50:43 +0200
commit53c7b44e96e6015a4da4f88f22e98b13cfa2e056 (patch)
treec6063d881e53866871845fda199e12a7d14ae3b3 /src/afb-apiset.c
parentec68c44857603c9f5bb77a44d8163d837ac5a55a (diff)
afb-apiset: add a wrapper for 'describe'
And use it in monitor. Change-Id: I9efbd19cfbdc665d1d686831b529ebaa7bd917a2 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-apiset.c')
-rw-r--r--src/afb-apiset.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/afb-apiset.c b/src/afb-apiset.c
index 13d806ef..18104a93 100644
--- a/src/afb-apiset.c
+++ b/src/afb-apiset.c
@@ -307,6 +307,17 @@ int afb_apiset_lookup(struct afb_apiset *set, const char *name, struct afb_api *
}
/**
+ * Check whether the 'set' has the API of 'name'
+ * @param set the set of API
+ * @param name the name of the API to get
+ * @return 1 if the api exist or 0 otherwise
+ */
+int afb_apiset_has(struct afb_apiset *set, const char *name)
+{
+ return !!search(set, name);
+}
+
+/**
* Get from the 'set' the API of 'name' in 'api' with fallback to subset or default api
* @param set the set of API
* @param name the name of the API to get
@@ -494,9 +505,10 @@ void afb_apiset_set_verbosity(struct afb_apiset *set, const char *name, int leve
}
/**
- * Set the verbosity level of the 'api'
+ * Get the verbosity level of the 'api'
* @param set the api set
- * @param name the api to set (NULL set all)
+ * @param name the api to get
+ * @return the verbosity level or -1 in case of error
*/
int afb_apiset_get_verbosity(struct afb_apiset *set, const char *name)
{
@@ -507,6 +519,7 @@ int afb_apiset_get_verbosity(struct afb_apiset *set, const char *name)
errno = ENOENT;
return -1;
}
+
if (!i->api.itf->get_verbosity)
return verbosity;
@@ -514,6 +527,20 @@ int afb_apiset_get_verbosity(struct afb_apiset *set, const char *name)
}
/**
+ * Get the description of the API of 'name'
+ * @param set the api set
+ * @param name the api whose description is required
+ * @return the description or NULL
+ */
+struct json_object *afb_apiset_describe(struct afb_apiset *set, const char *name)
+{
+ const struct api_desc *i;
+
+ i = name ? search(set, name) : NULL;
+ return i && i->api.itf->describe ? i->api.itf->describe(i->api.closure) : NULL;
+}
+
+/**
* Get the list of api names
* @param set the api set
* @return a NULL terminated array of api names. Must be freed.