Add new "update" API class with the first "checkupdates" action for

testing. We will add an API call for doc'ing once we troubleshoot
some issues
This commit is contained in:
Kris Moore
2016-01-18 15:07:57 -05:00
parent ae054b759a
commit 766305dcdf
6 changed files with 139 additions and 8 deletions

View File

@@ -10,8 +10,9 @@
//sysadm library interface classes
#include "sysadm-general.h"
#include "sysadm-network.h"
#include "sysadm-lifepreserver.h"
#include "sysadm-network.h"
#include "sysadm-update.h"
#include "syscache-client.h"
#include "dispatcher-client.h"
@@ -66,6 +67,8 @@ RestOutputStruct::ExitCode WebSocket::EvaluateBackendRequest(const RestInputStru
return EvaluateSysadmNetworkRequest(IN.args, out);
}else if(namesp=="sysadm" && name=="lifepreserver"){
return EvaluateSysadmLifePreserverRequest(IN.args, out);
}else if(namesp=="sysadm" && name=="update"){
return EvaluateSysadmUpdateRequest(IN.args, out);
}else{
return RestOutputStruct::BADREQUEST;
}
@@ -241,3 +244,27 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmLifePreserverRequest(const Q
}
return RestOutputStruct::OK;
}
//==== SYSADM -- Update ====
RestOutputStruct::ExitCode WebSocket::EvaluateSysadmUpdateRequest(const QJsonValue in_args, QJsonObject *out){
if(in_args.isObject()){
QStringList keys = in_args.toObject().keys();
bool ok = false;
if(keys.contains("action")){
QString act = JsonValueToString(in_args.toObject().value("action"));
if(act=="checkupdates"){
ok = true;
out->insert("checkupdates", sysadm::Update::checkUpdates());
}
} //end of "action" key usage
//If nothing done - return the proper code
if(!ok){
return RestOutputStruct::BADREQUEST;
}
}else{ // if(in_args.isArray()){
return RestOutputStruct::BADREQUEST;
}
return RestOutputStruct::OK;
}