Commit bb8597e8 authored by Michael Ott's avatar Michael Ott
Browse files

Make start/stop commands in REST API available via POST request

parent 882068de
......@@ -58,10 +58,11 @@ RestAPI::RestAPI(serverSettings_t settings,
addEndpoint("/quit", {http::verb::put, stdBind(PUT_quit)});
addEndpoint("/load", {http::verb::put, stdBind(PUT_load)});
addEndpoint("/unload", {http::verb::put, stdBind(PUT_unload)});
addEndpoint("/start", {http::verb::put, stdBind(PUT_start)});
addEndpoint("/stop", {http::verb::put, stdBind(PUT_stop)});
addEndpoint("/reload", {http::verb::put, stdBind(PUT_reload)});
addEndpoint("/start", {http::verb::post, stdBind(POST_start)});
addEndpoint("/stop", {http::verb::post, stdBind(POST_stop)});
_manager->addRestEndpoints(this);
addEndpoint("/analytics/reload", {http::verb::put, stdBind(PUT_analytics_reload)});
......@@ -285,7 +286,7 @@ void RestAPI::PUT_unload(endpointArgs) {
reloadQueryEngine();
}
void RestAPI::PUT_start(endpointArgs) {
void RestAPI::POST_start(endpointArgs) {
const std::string plugin = getQuery("plugin", queries);
if (!hasPlugin(plugin, res)) {
......@@ -299,7 +300,7 @@ void RestAPI::PUT_start(endpointArgs) {
}
}
void RestAPI::PUT_stop(endpointArgs) {
void RestAPI::POST_stop(endpointArgs) {
const std::string plugin = getQuery("plugin", queries);
if (!hasPlugin(plugin, res)) {
......
......@@ -54,26 +54,26 @@ class RestAPI : public RESTHttpsServer {
// String used as a response for the REST GET /help command
const string restCheatSheet = "dcdbpusher RESTful API cheatsheet:\n"
" -GET: /help This help message.\n"
" /analytics/help An help message for data analytics commands.\n"
" /plugins?[json] D List of currently loaded plugins.\n"
" /sensors?plugin;[json]\n"
" D List of currently running sensors which belong to\n"
" the specified plugin.\n"
" /average?plugin;sensor;[interval]\n"
" Average of last sensor readings from the last\n"
" [interval] seconds or of all cached readings if no\n"
" interval is given.\n"
" -PUT: /load?plugin;[path];[config]\n"
" Load a new plugin. Optionally specify path to the\n"
" shared library and/or the config file for the "
" plugin.\n"
" /unload?plugin Unload a plugin.\n"
" /start?plugin Start the sensors of the plugin.\n"
" /stop?plugin Stop the sensors of the plugin.\n"
" /reload?plugin Reload the plugin configuration.\n"
" /quit?[code] The pusher quits with the specified\n"
" return code.\n"
" -GET: /help This help message.\n"
" /analytics/help An help message for data analytics commands.\n"
" /plugins?[json] D List of currently loaded plugins.\n"
" /sensors?plugin;[json]\n"
" D List of currently running sensors which belong to\n"
" the specified plugin.\n"
" /average?plugin;sensor;[interval]\n"
" Average of last sensor readings from the last\n"
" [interval] seconds or of all cached readings if no\n"
" interval is given.\n"
" -PUT: /load?plugin;[path];[config]\n"
" Load a new plugin. Optionally specify path to the\n"
" shared library and/or the config file for the "
" plugin.\n"
" /unload?plugin Unload a plugin.\n"
" /reload?plugin Reload the plugin configuration.\n"
" /quit?[code] The pusher quits with the specified\n"
" return code.\n"
" -POST: /start?plugin Start the sensors of the plugin.\n"
" /stop?plugin Stop the sensors of the plugin.\n"
"\n";
private:
......@@ -176,7 +176,7 @@ class RestAPI : public RESTHttpsServer {
void PUT_unload(endpointArgs);
/**
* PUT "/start"
* POST "/start"
*
* @brief Start a plugin.
*
......@@ -185,10 +185,10 @@ class RestAPI : public RESTHttpsServer {
* Required | plugin | all plugin names | specify the plugin
* Optional | - | - | -
*/
void PUT_start(endpointArgs);
void POST_start(endpointArgs);
/**
* PUT "/stop"
* POST "/stop"
*
* @brief Stop a plugin.
*
......@@ -197,7 +197,7 @@ class RestAPI : public RESTHttpsServer {
* Required | plugin | all plugin names | specify the plugin
* Optional | - | - | -
*/
void PUT_stop(endpointArgs);
void POST_stop(endpointArgs);
/**
* PUT "/reload"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment