1 // SPDX-License-Identifier: Apache-2.0 2 // SPDX-FileCopyrightText: Copyright OpenBMC Authors 3 // SPDX-FileCopyrightText: Copyright 2018 Intel Corporation 4 #pragma once 5 6 #include "app.hpp" 7 #include "async_resp.hpp" 8 #include "error_messages.hpp" 9 #include "http_request.hpp" 10 #include "query.hpp" 11 #include "registries/privilege_registry.hpp" 12 #include "utils/eventlog_utils.hpp" 13 #include "utils/query_param.hpp" 14 15 #include <boost/beast/http/field.hpp> 16 #include <boost/beast/http/status.hpp> 17 #include <boost/beast/http/verb.hpp> 18 #include <boost/system/linux_error.hpp> 19 #include <boost/url/format.hpp> 20 #include <boost/url/url.hpp> 21 #include <sdbusplus/message.hpp> 22 #include <sdbusplus/message/native_types.hpp> 23 #include <sdbusplus/unpack_properties.hpp> 24 25 #include <string> 26 27 namespace redfish 28 { 29 30 inline void handleManagersLogServiceEventLogLogEntryCollection( 31 crow::App& app, const crow::Request& req, 32 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 33 const std::string& managerId) 34 { 35 query_param::QueryCapabilities capabilities = { 36 .canDelegateTop = true, 37 .canDelegateSkip = true, 38 }; 39 query_param::Query delegatedQuery; 40 if (!redfish::setUpRedfishRouteWithDelegation(app, req, asyncResp, 41 delegatedQuery, capabilities)) 42 { 43 return; 44 } 45 if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) 46 { 47 messages::resourceNotFound(asyncResp->res, "Manager", managerId); 48 return; 49 } 50 51 eventlog_utils:: 52 handleSystemsAndManagersLogServiceEventLogLogEntryCollection( 53 asyncResp, delegatedQuery, 54 eventlog_utils::LogServiceParent::Managers); 55 } 56 57 inline void handleManagersJournalEventLogEntry( 58 crow::App& app, const crow::Request& req, 59 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 60 const std::string& managerId, const std::string& param) 61 { 62 if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 63 { 64 return; 65 } 66 if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) 67 { 68 messages::resourceNotFound(asyncResp->res, "Manager", managerId); 69 return; 70 } 71 eventlog_utils::handleSystemsAndManagersLogServiceEventLogEntriesGet( 72 asyncResp, param, eventlog_utils::LogServiceParent::Managers); 73 } 74 75 inline void handleManagersJournalEventLogClear( 76 77 crow::App& app, const crow::Request& req, 78 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 79 const std::string& managerId) 80 { 81 if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 82 { 83 return; 84 } 85 if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) 86 { 87 messages::resourceNotFound(asyncResp->res, "Manager", managerId); 88 return; 89 } 90 eventlog_utils::handleSystemsAndManagersLogServicesEventLogActionsClearPost( 91 asyncResp); 92 } 93 94 inline void requestRoutesManagersJournalEventLog(App& app) 95 { 96 BMCWEB_ROUTE(app, 97 "/redfish/v1/Managers/<str>/LogServices/EventLog/Entries/") 98 .privileges(redfish::privileges::getLogEntryCollection) 99 .methods(boost::beast::http::verb::get)(std::bind_front( 100 handleManagersLogServiceEventLogLogEntryCollection, std::ref(app))); 101 102 BMCWEB_ROUTE( 103 app, "/redfish/v1/Managers/<str>/LogServices/EventLog/Entries/<str>/") 104 .privileges(redfish::privileges::getLogEntry) 105 .methods(boost::beast::http::verb::get)( 106 std::bind_front(handleManagersJournalEventLogEntry, std::ref(app))); 107 108 BMCWEB_ROUTE( 109 app, 110 "/redfish/v1/Managers/<str>/LogServices/EventLog/Actions/LogService.ClearLog/") 111 .privileges(redfish::privileges:: 112 postLogServiceSubOverComputerSystemLogServiceCollection) 113 .methods(boost::beast::http::verb::post)( 114 std::bind_front(handleManagersJournalEventLogClear, std::ref(app))); 115 } 116 } // namespace redfish 117