// SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright OpenBMC Authors // SPDX-FileCopyrightText: Copyright 2018 Intel Corporation #pragma once #include "app.hpp" #include "async_resp.hpp" #include "error_messages.hpp" #include "http_request.hpp" #include "query.hpp" #include "registries/privilege_registry.hpp" #include "utils/eventlog_utils.hpp" #include #include #include #include #include #include #include #include #include #include #include namespace redfish { inline void handleManagersDBusEventLogEntryCollection( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& managerId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) { messages::resourceNotFound(asyncResp->res, "Manager", managerId); return; } eventlog_utils::dBusEventLogEntryCollection( asyncResp, eventlog_utils::LogServiceParent::Managers); } inline void handleManagersDBusEventLogEntryGet( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& managerId, const std::string& entryId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) { messages::resourceNotFound(asyncResp->res, "Manager", managerId); return; } eventlog_utils::dBusEventLogEntryGet( asyncResp, eventlog_utils::LogServiceParent::Managers, entryId); } inline void handleManagersDBusEventLogEntryPatch( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& managerId, const std::string& entryId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) { messages::resourceNotFound(asyncResp->res, "Manager", managerId); return; } eventlog_utils::dBusEventLogEntryPatch(req, asyncResp, entryId); } inline void handleManagersDBusEventLogEntryDelete( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& managerId, const std::string& entryId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) { messages::resourceNotFound(asyncResp->res, "Manager", managerId); return; } eventlog_utils::dBusEventLogEntryDelete(asyncResp, entryId); } inline void handleManagersDBusLogServiceActionsClear( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& managerId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (!http_helpers::isContentTypeAllowed( req.getHeaderValue("Accept"), http_helpers::ContentType::OctetStream, true)) { asyncResp->res.result(boost::beast::http::status::bad_request); } if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) { messages::resourceNotFound(asyncResp->res, "Manager", managerId); return; } eventlog_utils::dBusLogServiceActionsClear(asyncResp); } inline void handleManagersDBusEventLogEntryDownload( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& managerId, const std::string& entryId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (!http_helpers::isContentTypeAllowed( req.getHeaderValue("Accept"), http_helpers::ContentType::OctetStream, true)) { asyncResp->res.result(boost::beast::http::status::bad_request); } if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) { messages::resourceNotFound(asyncResp->res, "Manager", managerId); return; } eventlog_utils::downloadEventLogEntry(asyncResp, entryId, "System"); } inline void requestRoutesManagersDBusEventLogEntryCollection(App& app) { BMCWEB_ROUTE(app, "/redfish/v1/Managers//LogServices/EventLog/Entries/") .privileges(redfish::privileges::getLogEntryCollection) .methods(boost::beast::http::verb::get)(std::bind_front( handleManagersDBusEventLogEntryCollection, std::ref(app))); } inline void requestRoutesManagersDBusEventLogEntry(App& app) { BMCWEB_ROUTE( app, "/redfish/v1/Managers//LogServices/EventLog/Entries//") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)( std::bind_front(handleManagersDBusEventLogEntryGet, std::ref(app))); BMCWEB_ROUTE( app, "/redfish/v1/Managers//LogServices/EventLog/Entries//") .privileges(redfish::privileges::patchLogEntry) .methods(boost::beast::http::verb::patch)(std::bind_front( handleManagersDBusEventLogEntryPatch, std::ref(app))); BMCWEB_ROUTE( app, "/redfish/v1/Managers//LogServices/EventLog/Entries//") .privileges( redfish::privileges:: deleteLogEntrySubOverComputerSystemLogServiceCollectionLogServiceLogEntryCollection) .methods(boost::beast::http::verb::delete_)(std::bind_front( handleManagersDBusEventLogEntryDelete, std::ref(app))); } /** * DBusLogServiceActionsClear class supports POST method for ClearLog action. */ inline void requestRoutesManagersDBusLogServiceActionsClear(App& app) { /** * Function handles POST method request. * The Clear Log actions does not require any parameter.The action deletes * all entries found in the Entries collection for this Log Service. */ BMCWEB_ROUTE( app, "/redfish/v1/Managers//LogServices/EventLog/Actions/LogService.ClearLog/") .privileges(redfish::privileges:: postLogServiceSubOverComputerSystemLogServiceCollection) .methods(boost::beast::http::verb::post)(std::bind_front( handleManagersDBusLogServiceActionsClear, std::ref(app))); } inline void requestRoutesManagersDBusEventLogEntryDownload(App& app) { BMCWEB_ROUTE( app, "/redfish/v1/Managers//LogServices/EventLog/Entries//attachment/") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)(std::bind_front( handleManagersDBusEventLogEntryDownload, std::ref(app))); } } // namespace redfish