Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

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

Add /version query to REST API

parent 923d8efd
......@@ -26,6 +26,9 @@
//================================================================================
#include "CARestAPI.h"
#include <dcdb/version.h>
#include "version.h"
#include <boost/beast/http/field.hpp>
#define stdBind(fun) std::bind(&CARestAPI::fun, \
......@@ -48,7 +51,8 @@ CARestAPI::CARestAPI(serverSettings_t settings,
_mqttServer(mqttServer) {
addEndpoint("/help", {http::verb::get, stdBind(GET_help)});
addEndpoint("/hosts", {http::verb::get, stdBind(GET_hosts)});
addEndpoint("/version", {http::verb::get, stdBind(GET_version)});
addEndpoint("/hosts", {http::verb::get, stdBind(GET_hosts)});
addEndpoint("/average", {http::verb::get, stdBind(GET_average)});
addEndpoint("/quit", {http::verb::put, stdBind(PUT_quit)});
......@@ -69,6 +73,11 @@ void CARestAPI::GET_help(endpointArgs) {
res.result(http::status::ok);
}
void CARestAPI::GET_version(endpointArgs) {
res.body() = "CollectAgent " + std::string(VERSION) + " (libdcdb " + DCDB::Version::getVersion() + ")";
res.result(http::status::ok);
}
void CARestAPI::GET_hosts(endpointArgs) {
if (!_mqttServer) {
res.body() = "The MQTT server is not initialized!";
......
......@@ -82,6 +82,18 @@ private:
*/
void GET_help(endpointArgs);
/**
* GET "/version"
*
* @brief Return version number.
*
* Queries | key | possible values | explanation
* -------------------------------------------------------------------------
* Required | - | - | -
* Optional | - | - | -
*/
void GET_version(endpointArgs);
/**
* GET "/hosts"
*
......
......@@ -259,8 +259,8 @@ bool RESTHttpsServer::validateUser(const http::request<Body>& req, Send&& send)
res.body() = "Unauthorized access!\n";
res.prepare_payload();
//GET /help does not need any authorization
if (req.target() == "/help" && req.method() == http::verb::get) {
//GET /help and /version do not need any authorization
if ((req.method() == http::verb::get) && ((req.target() == "/help") || (req.target() == "/version"))) {
return true;
}
......
......@@ -30,6 +30,7 @@
#include <sstream>
#include <string>
#include <signal.h>
#include "version.h"
#include <boost/property_tree/ptree.hpp>
......@@ -51,6 +52,7 @@ RestAPI::RestAPI(serverSettings_t settings,
_io(io) {
addEndpoint("/help", {http::verb::get, stdBind(GET_help)});
addEndpoint("/version", {http::verb::get, stdBind(GET_version)});
addEndpoint("/plugins", {http::verb::get, stdBind(GET_plugins)});
addEndpoint("/sensors", {http::verb::get, stdBind(GET_sensors)});
addEndpoint("/average", {http::verb::get, stdBind(GET_average)});
......@@ -76,6 +78,11 @@ void RestAPI::GET_help(endpointArgs) {
res.result(http::status::ok);
}
void RestAPI::GET_version(endpointArgs) {
res.body() = "dcdbpusher " + std::string(VERSION);
res.result(http::status::ok);
}
void RestAPI::GET_plugins(endpointArgs) {
std::ostringstream data;
if (getQuery("json", queries) == "true") {
......
......@@ -89,6 +89,18 @@ class RestAPI : public RESTHttpsServer {
*/
void GET_help(endpointArgs);
/**
* GET "/version"
*
* @brief Return version number
*
* Queries | key | possible values | explanation
* -------------------------------------------------------------------------
* Required | - | - | -
* Optional | - | - | -
*/
void GET_version(endpointArgs);
/**
* GET "/plugins"
*
......
Markdown is supported
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