xref: /openbmc/bmcweb/features/redfish/lib/aggregation_service.hpp (revision 5315c1b149b724d0395f42ca75d4660aaecdf351)
16c068982SEd Tanous #pragma once
26c068982SEd Tanous 
36c068982SEd Tanous #include "app.hpp"
46c068982SEd Tanous #include "error_messages.hpp"
56c068982SEd Tanous #include "http_request.hpp"
66c068982SEd Tanous #include "http_response.hpp"
76c068982SEd Tanous #include "query.hpp"
86c068982SEd Tanous #include "registries/privilege_registry.hpp"
96c068982SEd Tanous 
106c068982SEd Tanous #include <nlohmann/json.hpp>
116c068982SEd Tanous 
126c068982SEd Tanous #include <functional>
136c068982SEd Tanous #include <memory>
146c068982SEd Tanous 
156c068982SEd Tanous namespace redfish
166c068982SEd Tanous {
176c068982SEd Tanous 
186c068982SEd Tanous inline void handleAggregationServiceHead(
196c068982SEd Tanous     App& app, const crow::Request& req,
206c068982SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
216c068982SEd Tanous {
226c068982SEd Tanous     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
236c068982SEd Tanous     {
246c068982SEd Tanous         return;
256c068982SEd Tanous     }
266c068982SEd Tanous     asyncResp->res.addHeader(
276c068982SEd Tanous         boost::beast::http::field::link,
286c068982SEd Tanous         "</redfish/v1/JsonSchemas/AggregationService/AggregationService.json>; rel=describedby");
296c068982SEd Tanous }
306c068982SEd Tanous 
316c068982SEd Tanous inline void handleAggregationServiceGet(
326c068982SEd Tanous     App& app, const crow::Request& req,
336c068982SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
346c068982SEd Tanous {
356c068982SEd Tanous     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
366c068982SEd Tanous     {
376c068982SEd Tanous         return;
386c068982SEd Tanous     }
396c068982SEd Tanous     asyncResp->res.addHeader(
406c068982SEd Tanous         boost::beast::http::field::link,
416c068982SEd Tanous         "</redfish/v1/JsonSchemas/AggregationService/AggregationService.json>; rel=describedby");
426c068982SEd Tanous     nlohmann::json& json = asyncResp->res.jsonValue;
436c068982SEd Tanous     json["@odata.id"] = "/redfish/v1/AggregationService";
446c068982SEd Tanous     json["@odata.type"] = "#AggregationService.v1_0_1.AggregationService";
456c068982SEd Tanous     json["Id"] = "AggregationService";
466c068982SEd Tanous     json["Name"] = "Aggregation Service";
476c068982SEd Tanous     json["Description"] = "Aggregation Service";
486c068982SEd Tanous     json["ServiceEnabled"] = true;
49*5315c1b1SCarson Labrado     json["AggregationSources"]["@odata.id"] =
50*5315c1b1SCarson Labrado         "/redfish/v1/AggregationService/AggregationSources";
516c068982SEd Tanous }
526c068982SEd Tanous 
536c068982SEd Tanous inline void requestAggregationServiceRoutes(App& app)
546c068982SEd Tanous {
556c068982SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/AggregationService/")
566c068982SEd Tanous         .privileges(redfish::privileges::headAggregationService)
576c068982SEd Tanous         .methods(boost::beast::http::verb::head)(
586c068982SEd Tanous             std::bind_front(handleAggregationServiceHead, std::ref(app)));
596c068982SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/AggregationService/")
606c068982SEd Tanous         .privileges(redfish::privileges::getAggregationService)
616c068982SEd Tanous         .methods(boost::beast::http::verb::get)(
626c068982SEd Tanous             std::bind_front(handleAggregationServiceGet, std::ref(app)));
636c068982SEd Tanous }
646c068982SEd Tanous 
65*5315c1b1SCarson Labrado inline void handleAggregationSourcesGet(
66*5315c1b1SCarson Labrado     App& app, const crow::Request& req,
67*5315c1b1SCarson Labrado     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
68*5315c1b1SCarson Labrado {
69*5315c1b1SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
70*5315c1b1SCarson Labrado     {
71*5315c1b1SCarson Labrado         return;
72*5315c1b1SCarson Labrado     }
73*5315c1b1SCarson Labrado     asyncResp->res.addHeader(
74*5315c1b1SCarson Labrado         boost::beast::http::field::link,
75*5315c1b1SCarson Labrado         "</redfish/v1/JsonSchemas/AggregationSourceCollection/AggregationSourceCollection.json>; rel=describedby");
76*5315c1b1SCarson Labrado     nlohmann::json& json = asyncResp->res.jsonValue;
77*5315c1b1SCarson Labrado     json["@odata.id"] = "/redfish/v1/AggregationService/AggregationSources";
78*5315c1b1SCarson Labrado     json["@odata.type"] =
79*5315c1b1SCarson Labrado         "#AggregationSourceCollection.AggregationSourceCollection";
80*5315c1b1SCarson Labrado     json["Name"] = "Aggregation Source Collection";
81*5315c1b1SCarson Labrado     json["Members"] = nlohmann::json::array();
82*5315c1b1SCarson Labrado     json["Members@odata.count"] = 0;
83*5315c1b1SCarson Labrado 
84*5315c1b1SCarson Labrado     // TODO: Query D-Bus for satellite configs and add them to the Members array
85*5315c1b1SCarson Labrado }
86*5315c1b1SCarson Labrado 
87*5315c1b1SCarson Labrado inline void requestAggregationSourcesRoutes(App& app)
88*5315c1b1SCarson Labrado {
89*5315c1b1SCarson Labrado     BMCWEB_ROUTE(app, "/redfish/v1/AggregationService/AggregationSources/")
90*5315c1b1SCarson Labrado         .privileges(redfish::privileges::getAggregationService)
91*5315c1b1SCarson Labrado         .methods(boost::beast::http::verb::get)(
92*5315c1b1SCarson Labrado             std::bind_front(handleAggregationSourcesGet, std::ref(app)));
93*5315c1b1SCarson Labrado }
94*5315c1b1SCarson Labrado 
956c068982SEd Tanous } // namespace redfish
96