blob: 0d5b88b49f641faa09f8fb27ad846eaac049b0c6 [file] [log] [blame]
Xiaochao Ma29739632021-03-02 15:53:13 +08001#pragma once
2
3#include "app.hpp"
4#include "query.hpp"
5#include "registries/privilege_registry.hpp"
6#include "utils/chassis_utils.hpp"
7#include "utils/json_utils.hpp"
8
9namespace redfish
10{
11
12inline void doThermalSubsystemCollection(
13 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
14 const std::string& chassisId,
15 const std::optional<std::string>& validChassisPath)
16{
17 if (!validChassisPath)
18 {
19 BMCWEB_LOG_ERROR << "Not a valid chassis ID" << chassisId;
20 messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
21 return;
22 }
23 asyncResp->res.jsonValue["@odata.type"] =
24 "#ThermalSubsystem.v1_0_0.ThermalSubsystem";
25 asyncResp->res.jsonValue["Name"] = "Thermal Subsystem";
26 asyncResp->res.jsonValue["Id"] = "ThermalSubsystem";
27
28 asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
29 "redfish", "v1", "Chassis", chassisId, "ThermalSubsystem");
30
31 asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
32 asyncResp->res.jsonValue["Status"]["Health"] = "OK";
33}
34
35inline void handleThermalSubsystemCollectionGet(
36 App& app, const crow::Request& req,
37 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
38 const std::string& param)
39{
40 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
41 {
42 return;
43 }
44 const std::string& chassisId = param;
45
46 redfish::chassis_utils::getValidChassisPath(
47 asyncResp, chassisId,
48 std::bind_front(doThermalSubsystemCollection, asyncResp, chassisId));
49}
50
51inline void requestRoutesThermalSubsystem(App& app)
52{
53 BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/ThermalSubsystem/")
54 .privileges(redfish::privileges::getThermalSubsystem)
55 .methods(boost::beast::http::verb::get)(std::bind_front(
56 handleThermalSubsystemCollectionGet, std::ref(app)));
57}
58
59} // namespace redfish