summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-05-23 20:32:52 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:51:00 +0200
commit7013c6de6bd016a5d30d73958a9b484e458ef23f (patch)
treef460bef502efee63a98dd5ec42486a7bb205984c
parent3026b78b990e26aec9bf53d5c6579f116fd06b6b (diff)
Change how to request all loaded api info
Instead of receiving all info about api by passing request arg : { "option" : "metadata" } api info will be obtained by passing this request arg : { "verbose" : 1 } Change-Id: I26a14d61ffefbb7f4630f4a3199ee5238008263a Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
index 2f9fc9f..704838f 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
@@ -65,9 +65,8 @@ void HalMgrPing(afb_request *request)
void HalMgrLoaded(afb_request *request)
{
- int requestJsonErr;
+ int requestJsonErr, requestOptionValue;
uint64_t cpt, numberOfLoadedApi;
- char *requestOption;
afb_dynapi *apiHandle;
struct HalMgrData *HalMgrGlobalData;
@@ -77,8 +76,6 @@ void HalMgrLoaded(afb_request *request)
struct json_object *requestAnswer;
struct json_object *apiObject;
- AFB_REQUEST_WARNING(request, "JAI :%s not completelly implemented yet", __func__);
-
apiHandle = (afb_dynapi *) afb_request_get_dynapi(request);
if(! apiHandle) {
afb_request_fail(request, "ERROR", "Can't get HalManager Api handle");
@@ -112,20 +109,10 @@ void HalMgrLoaded(afb_request *request)
currentHalData = HalMgrGlobalData->first;
// Get request option
- requestJsonErr = wrap_json_unpack(requestJson, "{s:s}", "option", &requestOption);
-
- if(! requestJsonErr && ! strcmp(requestOption, "status")) { // Case if request option is 'status'
- for(cpt = 0; cpt < numberOfLoadedApi; cpt++) {
- wrap_json_pack(&apiObject,
- "{s:i}",
- currentHalData->apiName,
- (unsigned int) currentHalData->status);
- json_object_array_add(requestAnswer, apiObject);
+ requestJsonErr = wrap_json_unpack(requestJson, "{s:i}", "verbose", &requestOptionValue);
- currentHalData = currentHalData->next;
- }
- }
- else if(! requestJsonErr && ! strcmp(requestOption, "metadata")) { // Case if request option is 'metadata'
+ // Case if request key is 'verbose' and value is bigger than 0
+ if(! requestJsonErr && requestOptionValue > 0) {
for(cpt = 0; cpt < numberOfLoadedApi; cpt++) {
wrap_json_pack(&apiObject,
"{s:s s:i s:s s:i s:s s:s s:s}",
@@ -141,7 +128,8 @@ void HalMgrLoaded(afb_request *request)
currentHalData = currentHalData->next;
}
}
- else { // Case if request option is empty or not valid
+ // Case if request option is empty or not handled
+ else {
for(cpt = 0; cpt < numberOfLoadedApi; cpt++) {
json_object_array_add(requestAnswer, json_object_new_string(currentHalData->apiName));