Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
bb8597e8
Commit
bb8597e8
authored
Jun 15, 2020
by
Michael Ott
Browse files
Make start/stop commands in REST API available via POST request
parent
882068de
Changes
2
Hide whitespace changes
Inline
Side-by-side
dcdbpusher/RestAPI.cpp
View file @
bb8597e8
...
...
@@ -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
::
P
U
T_start
(
endpointArgs
)
{
void
RestAPI
::
P
OS
T_start
(
endpointArgs
)
{
const
std
::
string
plugin
=
getQuery
(
"plugin"
,
queries
);
if
(
!
hasPlugin
(
plugin
,
res
))
{
...
...
@@ -299,7 +300,7 @@ void RestAPI::PUT_start(endpointArgs) {
}
}
void
RestAPI
::
P
U
T_stop
(
endpointArgs
)
{
void
RestAPI
::
P
OS
T_stop
(
endpointArgs
)
{
const
std
::
string
plugin
=
getQuery
(
"plugin"
,
queries
);
if
(
!
hasPlugin
(
plugin
,
res
))
{
...
...
dcdbpusher/RestAPI.h
View file @
bb8597e8
...
...
@@ -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 plugi
n.
\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 configuratio
n.
\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
);
/**
* P
U
T "/start"
* P
OS
T "/start"
*
* @brief Start a plugin.
*
...
...
@@ -185,10 +185,10 @@ class RestAPI : public RESTHttpsServer {
* Required | plugin | all plugin names | specify the plugin
* Optional | - | - | -
*/
void
P
U
T_start
(
endpointArgs
);
void
P
OS
T_start
(
endpointArgs
);
/**
* P
U
T "/stop"
* P
OS
T "/stop"
*
* @brief Stop a plugin.
*
...
...
@@ -197,7 +197,7 @@ class RestAPI : public RESTHttpsServer {
* Required | plugin | all plugin names | specify the plugin
* Optional | - | - | -
*/
void
P
U
T_stop
(
endpointArgs
);
void
P
OS
T_stop
(
endpointArgs
);
/**
* PUT "/reload"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment