API CHANGE

Last round of new "action"s for the sysadm/services class,
"action":"[enable/disable]"
Required input arguments:
"services":["service1","service2","etc"]

Exactly the same syntax as the start/stop/restart API calls, just a different action and the output field is "services_[enabled/disabled]" as well.
This commit is contained in:
Ken Moore
2016-08-30 14:22:33 -04:00
parent 0408f61f4c
commit 75f21cfe1b

View File

@@ -1061,6 +1061,32 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmServiceRequest(const QJsonVa
}
out->insert("services_restarted", QJsonArray::fromStringList(success));
}
}else if(action=="enable" && in_args.toObject().contains("services") ){
QJsonValue sval = in_args.toObject().value("services");
QStringList services;
if(sval.isString()){ services << sval.toString(); }
else if(sval.isArray()){ services = JsonArrayToStringList(sval.toArray()); }
if(!services.isEmpty()){
QStringList success;
ok = true;
for(int i=0; i<services.length(); i++){
if( SMGR.Enable( SMGR.GetService(services[i]) ) ){ success << services[i]; }
}
out->insert("services_enabled", QJsonArray::fromStringList(success));
}
}else if(action=="disable" && in_args.toObject().contains("services") ){
QJsonValue sval = in_args.toObject().value("services");
QStringList services;
if(sval.isString()){ services << sval.toString(); }
else if(sval.isArray()){ services = JsonArrayToStringList(sval.toArray()); }
if(!services.isEmpty()){
QStringList success;
ok = true;
for(int i=0; i<services.length(); i++){
if( SMGR.Disable( SMGR.GetService(services[i]) ) ){ success << services[i]; }
}
out->insert("services_disabled", QJsonArray::fromStringList(success));
}
}