1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-16 00:00:02 +01:00
VILLASnode/lib/api/requests/universal/info.cpp
Steffen Vogel a2d55a9b6e Harmonize descriptions of plugins
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
2024-04-10 09:06:15 +02:00

49 lines
1.5 KiB
C++

/* The Universal Data-exchange API.
*
* Author: Steffen Vogel <post@steffenvogel.de>
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
* SPDX-License-Identifier: Apache-2.0
*/
#include <villas/api/requests/universal.hpp>
#include <villas/api/response.hpp>
#include <villas/node.hpp>
#include <villas/uuid.hpp>
namespace villas {
namespace node {
namespace api {
namespace universal {
class InfoRequest : public UniversalRequest {
public:
using UniversalRequest::UniversalRequest;
virtual Response *execute() {
if (method != Session::Method::GET)
throw InvalidMethod(this);
if (body != nullptr)
throw BadRequest("This endpoint does not accept any body data");
auto *info = json_pack("{ s: s, s: s, s: { s: s, s: s, s: s } }", "id",
node->getNameShort().c_str(), "uuid",
uuid::toString(node->getUuid()).c_str(),
"transport", "type", "villas", "version",
PROJECT_VERSION, "build", PROJECT_BUILD_ID);
return new JsonResponse(session, HTTP_STATUS_OK, info);
}
};
// Register API requests
static char n[] = "universal/info";
static char r[] = "/universal/(" RE_NODE_NAME ")/info";
static char d[] = "Get details of universal data-exchange API";
static RequestPlugin<InfoRequest, n, r, d> p;
} // namespace universal
} // namespace api
} // namespace node
} // namespace villas