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>
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index ecf1c65..b6c500e 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -1026,6 +1026,34 @@
"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 @@
* 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 @@
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 @@
*/
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 @@
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"] =