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 <app.hpp>
19 #include <persistent_data.hpp>
20 #include <registries/privilege_registry.hpp>
21 #include <utils/systemd_utils.hpp>
22 
23 namespace redfish
24 {
25 
26 inline void
27     handleServiceRootGet(const crow::Request&,
28                          const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
29 {
30 
31     std::string uuid = persistent_data::getConfig().systemUuid;
32     asyncResp->res.jsonValue["@odata.type"] = "#ServiceRoot.v1_5_0.ServiceRoot";
33     asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1";
34     asyncResp->res.jsonValue["Id"] = "RootService";
35     asyncResp->res.jsonValue["Name"] = "Root Service";
36     asyncResp->res.jsonValue["RedfishVersion"] = "1.9.0";
37     asyncResp->res.jsonValue["Links"]["Sessions"] = {
38         {"@odata.id", "/redfish/v1/SessionService/Sessions"}};
39     asyncResp->res.jsonValue["AccountService"] = {
40         {"@odata.id", "/redfish/v1/AccountService"}};
41     asyncResp->res.jsonValue["Chassis"] = {
42         {"@odata.id", "/redfish/v1/Chassis"}};
43     asyncResp->res.jsonValue["JsonSchemas"] = {
44         {"@odata.id", "/redfish/v1/JsonSchemas"}};
45     asyncResp->res.jsonValue["Managers"] = {
46         {"@odata.id", "/redfish/v1/Managers"}};
47     asyncResp->res.jsonValue["SessionService"] = {
48         {"@odata.id", "/redfish/v1/SessionService"}};
49     asyncResp->res.jsonValue["Systems"] = {
50         {"@odata.id", "/redfish/v1/Systems"}};
51     asyncResp->res.jsonValue["Registries"] = {
52         {"@odata.id", "/redfish/v1/Registries"}};
53 
54     asyncResp->res.jsonValue["UpdateService"] = {
55         {"@odata.id", "/redfish/v1/UpdateService"}};
56     asyncResp->res.jsonValue["UUID"] = uuid;
57     asyncResp->res.jsonValue["CertificateService"] = {
58         {"@odata.id", "/redfish/v1/CertificateService"}};
59     asyncResp->res.jsonValue["Tasks"] = {
60         {"@odata.id", "/redfish/v1/TaskService"}};
61     asyncResp->res.jsonValue["EventService"] = {
62         {"@odata.id", "/redfish/v1/EventService"}};
63     asyncResp->res.jsonValue["TelemetryService"] = {
64         {"@odata.id", "/redfish/v1/TelemetryService"}};
65 }
66 
67 inline void requestRoutesServiceRoot(App& app)
68 {
69     BMCWEB_ROUTE(app, "/redfish/v1/")
70         .privileges(redfish::privileges::getServiceRoot)
71         .methods(boost::beast::http::verb::get)(handleServiceRootGet);
72 }
73 
74 } // namespace redfish
75