2022-03-28 18:06:47 +02:00
|
|
|
/** The Universal Data-exchange API.
|
|
|
|
*
|
|
|
|
* @author Steffen Vogel <svogel2@eonerc.rwth-aachen.de>
|
|
|
|
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
|
2022-07-04 18:20:03 +02:00
|
|
|
* @license Apache 2.0
|
2022-03-28 18:06:47 +02:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#include <villas/api/requests/universal.hpp>
|
|
|
|
#include <villas/api/response.hpp>
|
|
|
|
#include <villas/node.hpp>
|
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
namespace api {
|
|
|
|
namespace universal {
|
|
|
|
|
2022-12-14 17:39:50 +01:00
|
|
|
class StatusRequest : public UniversalRequest {
|
2022-03-28 18:06:47 +02:00
|
|
|
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");
|
|
|
|
|
2022-12-14 17:39:50 +01:00
|
|
|
auto *json_response = json_pack("{ s: s }",
|
|
|
|
// TODO: Add connectivity check or heuristic here.
|
|
|
|
"connected", "unknown"
|
|
|
|
);
|
|
|
|
|
|
|
|
return new JsonResponse(session, HTTP_STATUS_OK, json_response);
|
2022-03-28 18:06:47 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Register API requests */
|
2022-12-14 17:39:50 +01:00
|
|
|
static char n[] = "universal/status";
|
|
|
|
static char r[] = "/universal/(" RE_NODE_NAME ")/status";
|
|
|
|
static char d[] = "get status of universal data-exchange API";
|
|
|
|
static RequestPlugin<StatusRequest, n, r, d> p;
|
2022-03-28 18:06:47 +02:00
|
|
|
|
|
|
|
} /* namespace universal */
|
|
|
|
} /* namespace api */
|
|
|
|
} /* namespace node */
|
|
|
|
} /* namespace villas */
|