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(CrowApp& app) : Node(app, "/redfish/v1/") 29 { 30 uuid = app.template getMiddleware<crow::persistent_data::Middleware>() 31 .systemUuid; 32 entityPrivileges = { 33 {boost::beast::http::verb::get, {}}, 34 {boost::beast::http::verb::head, {}}, 35 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, 36 {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, 37 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, 38 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; 39 } 40 41 private: 42 void doGet(crow::Response& res, const crow::Request& req, 43 const std::vector<std::string>& params) override 44 { 45 res.jsonValue["@odata.type"] = "#ServiceRoot.v1_5_0.ServiceRoot"; 46 res.jsonValue["@odata.id"] = "/redfish/v1"; 47 res.jsonValue["Id"] = "RootService"; 48 res.jsonValue["Name"] = "Root Service"; 49 res.jsonValue["RedfishVersion"] = "1.9.0"; 50 res.jsonValue["Links"]["Sessions"] = { 51 {"@odata.id", "/redfish/v1/SessionService/Sessions"}}; 52 res.jsonValue["AccountService"] = { 53 {"@odata.id", "/redfish/v1/AccountService"}}; 54 res.jsonValue["Chassis"] = {{"@odata.id", "/redfish/v1/Chassis"}}; 55 res.jsonValue["JsonSchemas"] = { 56 {"@odata.id", "/redfish/v1/JsonSchemas"}}; 57 res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}}; 58 res.jsonValue["SessionService"] = { 59 {"@odata.id", "/redfish/v1/SessionService"}}; 60 res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}}; 61 res.jsonValue["Systems"] = {{"@odata.id", "/redfish/v1/Systems"}}; 62 res.jsonValue["Registries"] = {{"@odata.id", "/redfish/v1/Registries"}}; 63 64 res.jsonValue["UpdateService"] = { 65 {"@odata.id", "/redfish/v1/UpdateService"}}; 66 res.jsonValue["UUID"] = uuid; 67 res.jsonValue["CertificateService"] = { 68 {"@odata.id", "/redfish/v1/CertificateService"}}; 69 res.jsonValue["Tasks"] = {{"@odata.id", "/redfish/v1/TaskService"}}; 70 res.jsonValue["EventService"] = { 71 {"@odata.id", "/redfish/v1/EventService"}}; 72 res.end(); 73 } 74 75 std::string uuid; 76 }; 77 78 } // namespace redfish 79