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