2025-01-14 14:42:39 +00:00
|
|
|
/* Node API Request.
|
2021-02-25 17:17:11 -05:00
|
|
|
*
|
2025-01-14 14:42:39 +00:00
|
|
|
* 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
|
|
|
|
*/
|
2021-02-25 17:17:11 -05:00
|
|
|
|
2022-03-25 17:27:16 +01:00
|
|
|
#include <villas/api/requests/node.hpp>
|
2021-02-25 17:17:11 -05:00
|
|
|
|
|
|
|
using namespace villas::node::api;
|
|
|
|
|
2025-01-14 14:42:39 +00:00
|
|
|
void NodeRequest::prepare() {
|
|
|
|
int ret;
|
2021-02-25 17:17:11 -05:00
|
|
|
|
2025-01-14 14:42:39 +00:00
|
|
|
auto &nodes = session->getSuperNode()->getNodes();
|
2021-02-25 17:17:11 -05:00
|
|
|
|
2025-01-14 14:42:39 +00:00
|
|
|
uuid_t uuid;
|
|
|
|
ret = uuid_parse(matches[1].c_str(), uuid);
|
|
|
|
if (ret) {
|
|
|
|
node = nodes.lookup(matches[1]);
|
|
|
|
if (!node)
|
|
|
|
throw BadRequest("Unknown node", "{ s: s }", "node", matches[1].c_str());
|
|
|
|
} else {
|
|
|
|
node = nodes.lookup(uuid);
|
|
|
|
if (!node)
|
|
|
|
throw BadRequest("No node found with with matching UUID", "{ s: s }",
|
|
|
|
"uuid", matches[1].c_str());
|
|
|
|
}
|
2021-02-25 17:17:11 -05:00
|
|
|
}
|