blob: 390b294206ed744cb8643f87a5f55ea13f81ca8a [file] [log] [blame]
Xiaochao Ma29739632021-03-02 15:53:13 +08001#pragma once
2
3#include "app.hpp"
Nan Zhouce05f6c2022-11-09 21:41:18 +00004#include "logging.hpp"
Xiaochao Ma29739632021-03-02 15:53:13 +08005#include "query.hpp"
6#include "registries/privilege_registry.hpp"
7#include "utils/chassis_utils.hpp"
8#include "utils/json_utils.hpp"
9
Nan Zhouce05f6c2022-11-09 21:41:18 +000010#include <optional>
11#include <string>
12
Xiaochao Ma29739632021-03-02 15:53:13 +080013namespace redfish
14{
15
16inline 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
39inline 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
55inline 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