xref: /openbmc/bmcweb/features/redfish/lib/aggregation_service.hpp (revision 6c068982d54d20476fd04ae7ef893b153015762e)
1*6c068982SEd Tanous #pragma once
2*6c068982SEd Tanous 
3*6c068982SEd Tanous #include "app.hpp"
4*6c068982SEd Tanous #include "error_messages.hpp"
5*6c068982SEd Tanous #include "http_request.hpp"
6*6c068982SEd Tanous #include "http_response.hpp"
7*6c068982SEd Tanous #include "query.hpp"
8*6c068982SEd Tanous #include "registries/privilege_registry.hpp"
9*6c068982SEd Tanous 
10*6c068982SEd Tanous #include <nlohmann/json.hpp>
11*6c068982SEd Tanous 
12*6c068982SEd Tanous #include <functional>
13*6c068982SEd Tanous #include <memory>
14*6c068982SEd Tanous 
15*6c068982SEd Tanous namespace redfish
16*6c068982SEd Tanous {
17*6c068982SEd Tanous 
18*6c068982SEd Tanous inline void handleAggregationServiceHead(
19*6c068982SEd Tanous     App& app, const crow::Request& req,
20*6c068982SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
21*6c068982SEd Tanous {
22*6c068982SEd Tanous     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
23*6c068982SEd Tanous     {
24*6c068982SEd Tanous         return;
25*6c068982SEd Tanous     }
26*6c068982SEd Tanous     asyncResp->res.addHeader(
27*6c068982SEd Tanous         boost::beast::http::field::link,
28*6c068982SEd Tanous         "</redfish/v1/JsonSchemas/AggregationService/AggregationService.json>; rel=describedby");
29*6c068982SEd Tanous }
30*6c068982SEd Tanous 
31*6c068982SEd Tanous inline void handleAggregationServiceGet(
32*6c068982SEd Tanous     App& app, const crow::Request& req,
33*6c068982SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
34*6c068982SEd Tanous {
35*6c068982SEd Tanous     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
36*6c068982SEd Tanous     {
37*6c068982SEd Tanous         return;
38*6c068982SEd Tanous     }
39*6c068982SEd Tanous     asyncResp->res.addHeader(
40*6c068982SEd Tanous         boost::beast::http::field::link,
41*6c068982SEd Tanous         "</redfish/v1/JsonSchemas/AggregationService/AggregationService.json>; rel=describedby");
42*6c068982SEd Tanous     nlohmann::json& json = asyncResp->res.jsonValue;
43*6c068982SEd Tanous     json["@odata.id"] = "/redfish/v1/AggregationService";
44*6c068982SEd Tanous     json["@odata.type"] = "#AggregationService.v1_0_1.AggregationService";
45*6c068982SEd Tanous     json["Id"] = "AggregationService";
46*6c068982SEd Tanous     json["Name"] = "Aggregation Service";
47*6c068982SEd Tanous     json["Description"] = "Aggregation Service";
48*6c068982SEd Tanous     json["ServiceEnabled"] = true;
49*6c068982SEd Tanous }
50*6c068982SEd Tanous 
51*6c068982SEd Tanous inline void requestAggregationServiceRoutes(App& app)
52*6c068982SEd Tanous {
53*6c068982SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/AggregationService/")
54*6c068982SEd Tanous         .privileges(redfish::privileges::headAggregationService)
55*6c068982SEd Tanous         .methods(boost::beast::http::verb::head)(
56*6c068982SEd Tanous             std::bind_front(handleAggregationServiceHead, std::ref(app)));
57*6c068982SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/AggregationService/")
58*6c068982SEd Tanous         .privileges(redfish::privileges::getAggregationService)
59*6c068982SEd Tanous         .methods(boost::beast::http::verb::get)(
60*6c068982SEd Tanous             std::bind_front(handleAggregationServiceGet, std::ref(app)));
61*6c068982SEd Tanous }
62*6c068982SEd Tanous 
63*6c068982SEd Tanous } // namespace redfish
64