1 #pragma once
2
3 #include "app.hpp"
4 #include "error_messages.hpp"
5 #include "http_request.hpp"
6 #include "http_response.hpp"
7 #include "query.hpp"
8 #include "registries/privilege_registry.hpp"
9 #include "utility.hpp"
10
11 #include <boost/url/format.hpp>
12 #include <nlohmann/json.hpp>
13
14 #include <memory>
15 #include <ranges>
16 #include <string>
17 #include <string_view>
18
19 namespace redfish
20 {
21
redfishOdataGet(const crow::Request &,const std::shared_ptr<bmcweb::AsyncResp> & asyncResp)22 inline void redfishOdataGet(const crow::Request& /*req*/,
23 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
24 {
25 nlohmann::json::object_t obj;
26 obj["@odata.context"] = "/redfish/v1/$metadata";
27 nlohmann::json::array_t value;
28 for (std::string_view service :
29 {"$metadata", "odata", "JsonSchemas", "Service", "ServiceRoot",
30 "Systems", "Chassis", "Managers", "SessionService", "AccountService",
31 "UpdateService"})
32 {
33 nlohmann::json::object_t serviceObj;
34 serviceObj["kind"] = "Singleton";
35 serviceObj["name"] = "$metadata";
36 boost::urls::url url = boost::urls::format("/redfish/v1/{}", service);
37 if (service == "Service")
38 {
39 url = boost::urls::url("/redfish/v1");
40 }
41 serviceObj["url"] = url;
42 value.emplace_back(std::move(serviceObj));
43 }
44
45 obj["value"] = std::move(value);
46
47 asyncResp->res.jsonValue = std::move(obj);
48 }
49
requestRoutesOdata(App & app)50 inline void requestRoutesOdata(App& app)
51 {
52 BMCWEB_ROUTE(app, "/redfish/v1/odata/")
53 .methods(boost::beast::http::verb::get)(redfishOdataGet);
54 }
55
56 } // namespace redfish
57