+struct desc_apis {
+ struct namelist *names;
+ struct json_object *resu;
+ struct json_object *apis;
+ afb_req_t req;
+};
+
+static void describe_first_api(struct desc_apis *desc);
+
+static void on_api_description(void *closure, struct json_object *apidesc)
+{
+ struct desc_apis *desc = closure;
+ struct namelist *head = desc->names;
+
+ if (apidesc || afb_apiset_lookup(target_set, head->name, 1))
+ json_object_object_add(desc->apis, head->name, apidesc);
+ desc->names = head->next;
+ free(head);
+ describe_first_api(desc);
+}
+
+static void describe_first_api(struct desc_apis *desc)
+{
+ struct namelist *head = desc->names;
+ if (head)
+ afb_apiset_describe(target_set, head->name, on_api_description, desc);
+ else {
+ afb_req_success(desc->req, desc->resu, NULL);
+ afb_req_unref(desc->req);
+ free(desc);
+ }
+}
+
+static void describe_apis(afb_req_t req, struct json_object *resu, struct json_object *spec)
+{
+ struct desc_apis *desc;
+
+ desc = malloc(sizeof *desc);
+ if (!desc)
+ afb_req_fail(req, "out-of-memory", NULL);
+ else {
+ desc->req = afb_req_addref(req);
+ desc->resu = resu;
+ desc->apis = json_object_new_object();
+ json_object_object_add(desc->resu, _apis_, desc->apis);
+ desc->names = get_apis_namelist(spec);
+ describe_first_api(desc);
+ }
+}
+
+/******************************************************************************
+**** Implementation monitoring verbs
+******************************************************************************/