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 namespace redfish { 21 22 class ServiceRoot : public Node { 23 public: 24 template <typename CrowApp, typename PrivilegeProvider> 25 ServiceRoot(CrowApp& app, PrivilegeProvider& provider) 26 : Node(app, provider, "#ServiceRoot.v1_1_1.ServiceRoot", "/redfish/v1/") { 27 nodeJson["@odata.type"] = Node::odataType; 28 nodeJson["@odata.id"] = Node::odataId; 29 nodeJson["@odata.context"] = 30 "/redfish/v1/$metadata#ServiceRoot.ServiceRoot"; 31 nodeJson["Id"] = "RootService"; 32 nodeJson["Name"] = "Root Service"; 33 nodeJson["RedfishVersion"] = "1.1.0"; 34 nodeJson["Links"]["Sessions"] = { 35 {"@odata.id", "/redfish/v1/SessionService/Sessions/"}}; 36 nodeJson["UUID"] = 37 app.template get_middleware<crow::PersistentData::Middleware>() 38 .system_uuid; 39 getRedfishSubRoutes(app, "/redfish/v1/", nodeJson); 40 } 41 42 private: 43 void doGet(crow::response& res, const crow::request& req, 44 const std::vector<std::string>& params) override { 45 res.add_header("Content-Type", "application/json"); 46 res.body = nodeJson.dump(); 47 res.end(); 48 } 49 50 nlohmann::json nodeJson; 51 }; 52 53 } // namespace redfish 54