2021-02-25 17:17:11 -05:00
|
|
|
/* Node API Request.
|
|
|
|
*
|
2022-03-15 09:18:01 -04:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2022-07-04 18:20:03 +02:00
|
|
|
* 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;
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
void NodeRequest::prepare() {
|
2021-02-25 17:17:11 -05:00
|
|
|
int ret;
|
|
|
|
|
2021-06-21 16:12:47 -04:00
|
|
|
auto &nodes = session->getSuperNode()->getNodes();
|
2021-02-25 17:17:11 -05:00
|
|
|
|
|
|
|
uuid_t uuid;
|
|
|
|
ret = uuid_parse(matches[1].c_str(), uuid);
|
|
|
|
if (ret) {
|
2021-06-21 16:12:47 -04:00
|
|
|
node = nodes.lookup(matches[1]);
|
2021-02-25 17:17:11 -05:00
|
|
|
if (!node)
|
|
|
|
throw BadRequest("Unknown node", "{ s: s }", "node", matches[1].c_str());
|
|
|
|
} else {
|
2021-06-21 16:12:47 -04:00
|
|
|
node = nodes.lookup(uuid);
|
2021-02-25 17:17:11 -05:00
|
|
|
if (!node)
|
|
|
|
throw BadRequest("No node found with with matching UUID", "{ s: s }",
|
|
|
|
"uuid", matches[1].c_str());
|
|
|
|
}
|
|
|
|
}
|