diff options
author | Nikhil Namjoshi <nikhilnamjoshi@google.com> | 2022-11-11 04:52:32 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-11-14 21:07:51 +0300 |
commit | 71a24ca4a67de451e4bcae0b8bdb579b9648e970 (patch) | |
tree | acfbaac29640ee698e5943488b6566bc806c9507 /redfish-core/lib | |
parent | ce05f6c443944f7243e7a134990e7ce689c61f49 (diff) | |
download | bmcweb-71a24ca4a67de451e4bcae0b8bdb579b9648e970.tar.xz |
Processor: Implement links and HEAD
Adds Links and Head handler for Processor and
ProcessorCollection
Tested:
All of the below return a link header
HEAD /redfish/v1/Systems/system/Processors
HEAD /redfish/v1/Systems/system/Processors/cpu0
GET /redfish/v1/Systems/system/Processors
GET /redfish/v1/Systems/system/Processors/cpu0
Change-Id: Iad19d577afb7cd9d5e652bed2d5884b6ea8260da
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
Diffstat (limited to 'redfish-core/lib')
-rw-r--r-- | redfish-core/lib/processor.hpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp index ecf1c654fb..b6c500e814 100644 --- a/redfish-core/lib/processor.hpp +++ b/redfish-core/lib/processor.hpp @@ -1026,6 +1026,34 @@ inline void patchAppliedOperatingConfig( "AppliedConfig", dbus::utility::DbusVariantType(std::move(configPath))); } +inline void handleProcessorHead(crow::App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& aResp, + const std::string& /* systemName */, + const std::string& /* processorId */) +{ + if (!redfish::setUpRedfishRoute(app, req, aResp)) + { + return; + } + aResp->res.addHeader( + boost::beast::http::field::link, + "</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby"); +} + +inline void handleProcessorCollectionHead( + crow::App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& aResp, + const std::string& /* systemName */) +{ + if (!redfish::setUpRedfishRoute(app, req, aResp)) + { + return; + } + aResp->res.addHeader( + boost::beast::http::field::link, + "</redfish/v1/JsonSchemas/ProcessorCollection/ProcessorCollection.json>; rel=describedby"); +} + inline void requestRoutesOperatingConfigCollection(App& app) { @@ -1158,6 +1186,11 @@ inline void requestRoutesProcessorCollection(App& app) * Functions triggers appropriate requests on DBus */ BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/") + .privileges(redfish::privileges::headProcessorCollection) + .methods(boost::beast::http::verb::head)( + std::bind_front(handleProcessorCollectionHead, std::ref(app))); + + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/") .privileges(redfish::privileges::getProcessorCollection) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, @@ -1174,6 +1207,10 @@ inline void requestRoutesProcessorCollection(App& app) return; } + asyncResp->res.addHeader( + boost::beast::http::field::link, + "</redfish/v1/JsonSchemas/ProcessorCollection/ProcessorCollection.json>; rel=describedby"); + asyncResp->res.jsonValue["@odata.type"] = "#ProcessorCollection.ProcessorCollection"; asyncResp->res.jsonValue["Name"] = "Processor Collection"; @@ -1196,6 +1233,11 @@ inline void requestRoutesProcessor(App& app) */ BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/<str>/") + .privileges(redfish::privileges::headProcessor) + .methods(boost::beast::http::verb::head)( + std::bind_front(handleProcessorHead, std::ref(app))); + + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/<str>/") .privileges(redfish::privileges::getProcessor) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, @@ -1213,6 +1255,9 @@ inline void requestRoutesProcessor(App& app) return; } + asyncResp->res.addHeader( + boost::beast::http::field::link, + "</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby"); asyncResp->res.jsonValue["@odata.type"] = "#Processor.v1_11_0.Processor"; asyncResp->res.jsonValue["@odata.id"] = |