1 /*
2 // Copyright (c) 2018 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 #pragma once
17 
18 #include "node.hpp"
19 
20 #include <utils/systemd_utils.hpp>
21 
22 namespace redfish
23 {
24 
25 class ServiceRoot : public Node
26 {
27   public:
28     ServiceRoot(App& app) : Node(app, "/redfish/v1/")
29     {
30         uuid = persistent_data::getConfig().systemUuid;
31         entityPrivileges = {
32             {boost::beast::http::verb::get, {}},
33             {boost::beast::http::verb::head, {}},
34             {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
35             {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
36             {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
37             {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
38     }
39 
40   private:
41     void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
42                const crow::Request&, const std::vector<std::string>&) override
43     {
44         asyncResp->res.jsonValue["@odata.type"] =
45             "#ServiceRoot.v1_5_0.ServiceRoot";
46         asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1";
47         asyncResp->res.jsonValue["Id"] = "RootService";
48         asyncResp->res.jsonValue["Name"] = "Root Service";
49         asyncResp->res.jsonValue["RedfishVersion"] = "1.9.0";
50         asyncResp->res.jsonValue["Links"]["Sessions"] = {
51             {"@odata.id", "/redfish/v1/SessionService/Sessions"}};
52         asyncResp->res.jsonValue["AccountService"] = {
53             {"@odata.id", "/redfish/v1/AccountService"}};
54         asyncResp->res.jsonValue["Chassis"] = {
55             {"@odata.id", "/redfish/v1/Chassis"}};
56         asyncResp->res.jsonValue["JsonSchemas"] = {
57             {"@odata.id", "/redfish/v1/JsonSchemas"}};
58         asyncResp->res.jsonValue["Managers"] = {
59             {"@odata.id", "/redfish/v1/Managers"}};
60         asyncResp->res.jsonValue["SessionService"] = {
61             {"@odata.id", "/redfish/v1/SessionService"}};
62         asyncResp->res.jsonValue["Managers"] = {
63             {"@odata.id", "/redfish/v1/Managers"}};
64         asyncResp->res.jsonValue["Systems"] = {
65             {"@odata.id", "/redfish/v1/Systems"}};
66         asyncResp->res.jsonValue["Registries"] = {
67             {"@odata.id", "/redfish/v1/Registries"}};
68 
69         asyncResp->res.jsonValue["UpdateService"] = {
70             {"@odata.id", "/redfish/v1/UpdateService"}};
71         asyncResp->res.jsonValue["UUID"] = uuid;
72         asyncResp->res.jsonValue["CertificateService"] = {
73             {"@odata.id", "/redfish/v1/CertificateService"}};
74         asyncResp->res.jsonValue["Tasks"] = {
75             {"@odata.id", "/redfish/v1/TaskService"}};
76         asyncResp->res.jsonValue["EventService"] = {
77             {"@odata.id", "/redfish/v1/EventService"}};
78         asyncResp->res.jsonValue["TelemetryService"] = {
79             {"@odata.id", "/redfish/v1/TelemetryService"}};
80     }
81 
82     std::string uuid;
83 };
84 
85 } // namespace redfish
86