Add first API call for the "systeminfo" class

This API call will return a list of external mounts
on the system

TYPE: UNKNOWN/USB/HDRIVE/DVD/SDCARD

REST Request:
-------------------------------
PUT /sysadm/systeminfo
{
   "action" : "externalmounts"
}

REST Response:
-------------------------------
{
    "args": {
        "externalmounts": {
            "/dev/fuse": {
                "filesystem": "fusefs",
                "path": "/usr/home/kris/.gvfs",
                "type": "UNKNOWN"
            }
        }
    }
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "namespace" : "sysadm",
   "name" : "systeminfo",
   "args" : {
      "action" : "externalmounts"
   }
}

WebSocket Response:
-------------------------------
{
  "args": {
    "externalmounts": {
      "/dev/fuse": {
        "filesystem": "fusefs",
        "path": "/usr/home/kris/.gvfs",
        "type": "UNKNOWN"
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
This commit is contained in:
Kris Moore
2016-01-20 12:13:25 -05:00
parent 155026aab1
commit 7d839787bd
6 changed files with 107 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
#include "sysadm-general.h"
#include "sysadm-lifepreserver.h"
#include "sysadm-network.h"
#include "sysadm-systeminfo.h"
#include "sysadm-update.h"
#include "syscache-client.h"
@@ -67,6 +68,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=="systeminfo"){
return EvaluateSysadmSystemInfoRequest(IN.args, out);
}else if(namesp=="sysadm" && name=="update"){
return EvaluateSysadmUpdateRequest(IN.args, out);
}else{
@@ -245,6 +248,30 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmLifePreserverRequest(const Q
return RestOutputStruct::OK;
}
//==== SYSADM -- SysInfo ====
RestOutputStruct::ExitCode WebSocket::EvaluateSysadmSystemInfoRequest(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=="externalmounts"){
ok = true;
out->insert("externalmounts", sysadm::SysInfo::ExternalDevicePaths());
}
} //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;
}
//==== SYSADM -- Update ====
RestOutputStruct::ExitCode WebSocket::EvaluateSysadmUpdateRequest(const QJsonValue in_args, QJsonObject *out){
if(in_args.isObject()){