xref: /openbmc/bmcweb/features/redfish/lib/manager_diagnostic_data.hpp (revision 3ccb3adb9a14783f6bef601506de9f8bcae22d51)
1a51fc2d2SSui Chen #pragma once
2a51fc2d2SSui Chen 
3*3ccb3adbSEd Tanous #include "app.hpp"
4*3ccb3adbSEd Tanous #include "async_resp.hpp"
5*3ccb3adbSEd Tanous #include "http_request.hpp"
6*3ccb3adbSEd Tanous #include "privileges.hpp"
7*3ccb3adbSEd Tanous #include "query.hpp"
8*3ccb3adbSEd Tanous #include "registries/privilege_registry.hpp"
9*3ccb3adbSEd Tanous #include "routing.hpp"
10*3ccb3adbSEd Tanous 
11a51fc2d2SSui Chen #include <nlohmann/json.hpp>
12a51fc2d2SSui Chen 
13a51fc2d2SSui Chen #include <string>
14a51fc2d2SSui Chen 
15a51fc2d2SSui Chen namespace redfish
16a51fc2d2SSui Chen {
17a51fc2d2SSui Chen 
18a51fc2d2SSui Chen /**
19a51fc2d2SSui Chen  * handleManagerDiagnosticData supports ManagerDiagnosticData.
20a51fc2d2SSui Chen  * It retrieves BMC health information from various DBus resources and returns
21a51fc2d2SSui Chen  * the information through the response.
22a51fc2d2SSui Chen  */
23a51fc2d2SSui Chen inline void handleManagerDiagnosticDataGet(
24a51fc2d2SSui Chen     crow::App& app, const crow::Request& req,
25a51fc2d2SSui Chen     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
26a51fc2d2SSui Chen {
27a51fc2d2SSui Chen     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
28a51fc2d2SSui Chen     {
29a51fc2d2SSui Chen         return;
30a51fc2d2SSui Chen     }
31a51fc2d2SSui Chen     asyncResp->res.jsonValue["@odata.type"] =
32a51fc2d2SSui Chen         "#ManagerDiagnosticData.v1_0_0.ManagerDiagnosticData";
33a51fc2d2SSui Chen     asyncResp->res.jsonValue["@odata.id"] =
34a51fc2d2SSui Chen         "/redfish/v1/Managers/bmc/ManagerDiagnosticData";
35a51fc2d2SSui Chen     asyncResp->res.jsonValue["Id"] = "ManagerDiagnosticData";
36a51fc2d2SSui Chen     asyncResp->res.jsonValue["Name"] = "Manager Diagnostic Data";
37a51fc2d2SSui Chen }
38a51fc2d2SSui Chen 
39a51fc2d2SSui Chen inline void requestRoutesManagerDiagnosticData(App& app)
40a51fc2d2SSui Chen {
41a51fc2d2SSui Chen     BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/ManagerDiagnosticData")
42a51fc2d2SSui Chen         .privileges(redfish::privileges::getManagerDiagnosticData)
43a51fc2d2SSui Chen         .methods(boost::beast::http::verb::get)(
44a51fc2d2SSui Chen             std::bind_front(handleManagerDiagnosticDataGet, std::ref(app)));
45a51fc2d2SSui Chen }
46a51fc2d2SSui Chen 
47a51fc2d2SSui Chen } // namespace redfish
48