From 75f21cfe1b1ad96340209a50424f81cbd684d581 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 30 Aug 2016 14:22:33 -0400 Subject: [PATCH] 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. --- src/server/WebBackend.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/server/WebBackend.cpp b/src/server/WebBackend.cpp index 53fb0d9..3bb35aa 100644 --- a/src/server/WebBackend.cpp +++ b/src/server/WebBackend.cpp @@ -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; iinsert("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; iinsert("services_disabled", QJsonArray::fromStringList(success)); + } }