blob: 06b14339b762e463a2eab4765f457442ca6f3bc5 [file] [log] [blame]
#include "tlbmc/redfish/routes/tlbmc_metrics.h"
#include <functional>
#include "absl/functional/bind_front.h"
#include "tlbmc/hal/shared_mem/metrics.h"
#include "tlbmc/hal/shared_mem/server.h"
#include "tlbmc/redfish/app.h"
#include "tlbmc/redfish/request.h"
#include "tlbmc/redfish/response.h"
namespace milotic_tlbmc::redfish_metrics {
namespace {
void HandleTlbmcMetrics(const RedfishApp& app, const RedfishRequest& req,
RedfishResponse& resp) {
resp.SetKeyInJsonBody("/@odata.id", "/redfish/tlbmc/Metrics");
resp.SetKeyInJsonBody("/@odata.type", "#TlbmcMetrics.v1_0_0.TlbmcMetrics");
resp.SetKeyInJsonBody("/Name", "TlbmcMetrics");
resp.SetKeyInJsonBody("/Description", "Tlbmc Metrics");
resp.SetKeyInJsonBody(
"/Metrics", SharedMemoryServer::GetInstance().GetMetrics()->ToJson());
resp.SetKeyInJsonBody("/BootupMetrics",
app.GetStore()->GetMetrics().ToJson());
}
} // namespace
void RegisterRoutes(RedfishApp& app) {
TLBMC_ROUTE(app, "/redfish/tlbmc/Metrics/")
.methods(boost::beast::http::verb::get)(
absl::bind_front(HandleTlbmcMetrics, std::cref(app)));
}
} // namespace milotic_tlbmc::redfish_metrics