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