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(crow::Response& res, const crow::Request&,
42                const std::vector<std::string>&) override
43     {
44         res.jsonValue["@odata.type"] = "#ServiceRoot.v1_5_0.ServiceRoot";
45         res.jsonValue["@odata.id"] = "/redfish/v1";
46         res.jsonValue["Id"] = "RootService";
47         res.jsonValue["Name"] = "Root Service";
48         res.jsonValue["RedfishVersion"] = "1.9.0";
49         res.jsonValue["Links"]["Sessions"] = {
50             {"@odata.id", "/redfish/v1/SessionService/Sessions"}};
51         res.jsonValue["AccountService"] = {
52             {"@odata.id", "/redfish/v1/AccountService"}};
53         res.jsonValue["Chassis"] = {{"@odata.id", "/redfish/v1/Chassis"}};
54         res.jsonValue["JsonSchemas"] = {
55             {"@odata.id", "/redfish/v1/JsonSchemas"}};
56         res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}};
57         res.jsonValue["SessionService"] = {
58             {"@odata.id", "/redfish/v1/SessionService"}};
59         res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}};
60         res.jsonValue["Systems"] = {{"@odata.id", "/redfish/v1/Systems"}};
61         res.jsonValue["Registries"] = {{"@odata.id", "/redfish/v1/Registries"}};
62 
63         res.jsonValue["UpdateService"] = {
64             {"@odata.id", "/redfish/v1/UpdateService"}};
65         res.jsonValue["UUID"] = uuid;
66         res.jsonValue["CertificateService"] = {
67             {"@odata.id", "/redfish/v1/CertificateService"}};
68         res.jsonValue["Tasks"] = {{"@odata.id", "/redfish/v1/TaskService"}};
69         res.jsonValue["EventService"] = {
70             {"@odata.id", "/redfish/v1/EventService"}};
71         res.jsonValue["TelemetryService"] = {
72             {"@odata.id", "/redfish/v1/TelemetryService"}};
73         res.end();
74     }
75 
76     std::string uuid;
77 };
78 
79 } // namespace redfish
80