mirror of
https://github.com/arcan1s/queued.git
synced 2025-07-14 14:25:48 +00:00
implement support of new commands to clients
This commit is contained in:
@ -84,6 +84,8 @@ QueuedTcpServerResponseHelper::pathToEnum(const QString &_path)
|
||||
return RequestPath::Option;
|
||||
else if (_path == "permissions")
|
||||
return RequestPath::Permissions;
|
||||
else if (_path == "plugin")
|
||||
return RequestPath::Plugin;
|
||||
else if (_path == "plugins")
|
||||
return RequestPath::Plugins;
|
||||
else if (_path == "reports")
|
||||
|
@ -27,6 +27,7 @@ enum class RequestPath {
|
||||
Auth,
|
||||
Option,
|
||||
Permissions,
|
||||
Plugin,
|
||||
Plugins,
|
||||
Reports,
|
||||
Status,
|
||||
|
@ -68,6 +68,13 @@ QVariantHash QueuedTcpServerResponseHelperApi1::getData(
|
||||
else
|
||||
output = {{"code", 405}};
|
||||
break;
|
||||
case QueuedTcpServerResponseHelper::RequestPath::Plugin:
|
||||
if (_type == "GET")
|
||||
output
|
||||
= QueuedTcpServerResponseHelperPlugins::getPlugin(_arg, _token);
|
||||
else
|
||||
output = {{"code", 405}};
|
||||
break;
|
||||
case QueuedTcpServerResponseHelper::RequestPath::Plugins:
|
||||
if (_type == "DELETE")
|
||||
output = QueuedTcpServerResponseHelperPlugins::removePlugin(_arg,
|
||||
|
@ -30,7 +30,8 @@ QueuedTcpServerResponseHelperOption::getOption(const QString &_option,
|
||||
QVariantHash output;
|
||||
res.match(
|
||||
[&output](const QVariant &val) {
|
||||
output = {{"code", 200}, {"token", val}};
|
||||
QVariantHash opt = {{"_option", val}};
|
||||
output = {{"code", 200}, {"properties", opt}};
|
||||
},
|
||||
[&output](const QueuedError &) {
|
||||
output = {{"code", 404}, {"message", "Option not found"}};
|
||||
|
@ -40,6 +40,29 @@ QueuedTcpServerResponseHelperPlugins::addPlugin(const QString &_name,
|
||||
}
|
||||
|
||||
|
||||
QVariantHash
|
||||
QueuedTcpServerResponseHelperPlugins::getPlugin(const QString &_name,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_SERV) << "Get plugin" << _name;
|
||||
|
||||
auto res = QueuedCoreAdaptor::getPlugin(_name, _token);
|
||||
|
||||
QVariantHash output;
|
||||
res.match(
|
||||
[&output](const QueuedPluginSpecification::Plugin &val) {
|
||||
auto dump = QueuedPluginSpecification::dumpSpecification(val);
|
||||
QVariantList plugins = {dump};
|
||||
output = {{"code", 200}, {"plugins", plugins}};
|
||||
},
|
||||
[&output](const QueuedError &err) {
|
||||
output = {{"code", 500}, {"message", err.message().c_str()}};
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
QVariantHash QueuedTcpServerResponseHelperPlugins::listPlugins()
|
||||
{
|
||||
auto res = QueuedCoreAdaptor::getOption(
|
||||
|
@ -23,6 +23,7 @@
|
||||
namespace QueuedTcpServerResponseHelperPlugins
|
||||
{
|
||||
QVariantHash addPlugin(const QString &_name, const QString &_token);
|
||||
QVariantHash getPlugin(const QString &_name, const QString &_token);
|
||||
QVariantHash listPlugins();
|
||||
QVariantHash removePlugin(const QString &_name, const QString &_token);
|
||||
};
|
||||
|
Reference in New Issue
Block a user