blob: bd85b3355a20c3cf255820955367768fb5af906a [file] [log] [blame]
#include "tlbmc/redfish/routes/tlbmc_root.h"
#include <array>
#include <string>
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "nlohmann/json.hpp"
#include "tlbmc/redfish/app.h"
#include "tlbmc/redfish/request.h"
#include "tlbmc/redfish/response.h"
namespace milotic_tlbmc::tlbmc_root {
namespace {
constexpr std::array<const char*, 4> kResources = {"AllSensors", "AllChassis",
"Debug", "Metrics"};
void HandleRedfishV1(const RedfishRequest& req, RedfishResponse& resp) {
resp.SetKeyInJsonBody("/@odata.id", "/redfish/tlbmc");
resp.SetKeyInJsonBody("/Name", "tlBMC Root Service");
for (const auto& resource : kResources) {
nlohmann::json::object_t resource_json;
resource_json["@odata.id"] = absl::StrCat("/redfish/tlbmc/", resource);
resp.SetKeyInJsonBody(absl::StrCat("/", resource), resource_json);
}
}
} // namespace
void RegisterRoutes(RedfishApp& app) {
TLBMC_ROUTE(app, "/redfish/tlbmc/")
.methods(boost::beast::http::verb::get)(HandleRedfishV1);
}
} // namespace milotic_tlbmc::tlbmc_root