1b6df6dc7SBorawski.Lukasz /* 2b6df6dc7SBorawski.Lukasz // Copyright (c) 2018 Intel Corporation 3b6df6dc7SBorawski.Lukasz // 4b6df6dc7SBorawski.Lukasz // Licensed under the Apache License, Version 2.0 (the "License"); 5b6df6dc7SBorawski.Lukasz // you may not use this file except in compliance with the License. 6b6df6dc7SBorawski.Lukasz // You may obtain a copy of the License at 7b6df6dc7SBorawski.Lukasz // 8b6df6dc7SBorawski.Lukasz // http://www.apache.org/licenses/LICENSE-2.0 9b6df6dc7SBorawski.Lukasz // 10b6df6dc7SBorawski.Lukasz // Unless required by applicable law or agreed to in writing, software 11b6df6dc7SBorawski.Lukasz // distributed under the License is distributed on an "AS IS" BASIS, 12b6df6dc7SBorawski.Lukasz // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b6df6dc7SBorawski.Lukasz // See the License for the specific language governing permissions and 14b6df6dc7SBorawski.Lukasz // limitations under the License. 15b6df6dc7SBorawski.Lukasz */ 16b6df6dc7SBorawski.Lukasz #pragma once 17b6df6dc7SBorawski.Lukasz 183ccb3adbSEd Tanous #include "bmcweb_config.h" 19f4c99e70SEd Tanous 203ccb3adbSEd Tanous #include "app.hpp" 213ccb3adbSEd Tanous #include "async_resp.hpp" 223ccb3adbSEd Tanous #include "http_request.hpp" 233ccb3adbSEd Tanous #include "persistent_data.hpp" 243ccb3adbSEd Tanous #include "query.hpp" 253ccb3adbSEd Tanous #include "registries/privilege_registry.hpp" 263ccb3adbSEd Tanous #include "utils/systemd_utils.hpp" 273ccb3adbSEd Tanous 289629907dSNan Zhou #include <nlohmann/json.hpp> 29b6df6dc7SBorawski.Lukasz 301abe55efSEd Tanous namespace redfish 311abe55efSEd Tanous { 321abe55efSEd Tanous 338338891aSJohn Edward Broadbent inline void 345b224921SEd Tanous handleServiceRootHead(App& app, const crow::Request& req, 355b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 365b224921SEd Tanous { 375b224921SEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 385b224921SEd Tanous { 395b224921SEd Tanous return; 405b224921SEd Tanous } 415b224921SEd Tanous 425b224921SEd Tanous asyncResp->res.addHeader( 435b224921SEd Tanous boost::beast::http::field::link, 445b224921SEd Tanous "</redfish/v1/JsonSchemas/ServiceRoot/ServiceRoot.json>; rel=describedby"); 455b224921SEd Tanous } 465b224921SEd Tanous 475b224921SEd Tanous inline void handleServiceRootGetImpl( 485b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 491abe55efSEd Tanous { 507e860f15SJohn Edward Broadbent std::string uuid = persistent_data::getConfig().systemUuid; 519c929beaSShantappa Teekappanavar asyncResp->res.jsonValue["@odata.type"] = 52e68d1be0SEd Tanous "#ServiceRoot.v1_15_0.ServiceRoot"; 538d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1"; 548d1b46d7Szhanghch05 asyncResp->res.jsonValue["Id"] = "RootService"; 558d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Root Service"; 56*c16e292cSEd Tanous asyncResp->res.jsonValue["RedfishVersion"] = "1.17.0"; 571476687dSEd Tanous asyncResp->res.jsonValue["Links"]["Sessions"]["@odata.id"] = 581476687dSEd Tanous "/redfish/v1/SessionService/Sessions"; 591476687dSEd Tanous asyncResp->res.jsonValue["AccountService"]["@odata.id"] = 601476687dSEd Tanous "/redfish/v1/AccountService"; 616c068982SEd Tanous #ifdef BMCWEB_ENABLE_REDFISH_AGGREGATION 626c068982SEd Tanous asyncResp->res.jsonValue["AggregationService"]["@odata.id"] = 636c068982SEd Tanous "/redfish/v1/AggregationService"; 646c068982SEd Tanous #endif 651476687dSEd Tanous asyncResp->res.jsonValue["Chassis"]["@odata.id"] = "/redfish/v1/Chassis"; 661476687dSEd Tanous asyncResp->res.jsonValue["JsonSchemas"]["@odata.id"] = 671476687dSEd Tanous "/redfish/v1/JsonSchemas"; 681476687dSEd Tanous asyncResp->res.jsonValue["Managers"]["@odata.id"] = "/redfish/v1/Managers"; 691476687dSEd Tanous asyncResp->res.jsonValue["SessionService"]["@odata.id"] = 701476687dSEd Tanous "/redfish/v1/SessionService"; 711476687dSEd Tanous asyncResp->res.jsonValue["Systems"]["@odata.id"] = "/redfish/v1/Systems"; 721476687dSEd Tanous asyncResp->res.jsonValue["Registries"]["@odata.id"] = 731476687dSEd Tanous "/redfish/v1/Registries"; 741476687dSEd Tanous asyncResp->res.jsonValue["UpdateService"]["@odata.id"] = 751476687dSEd Tanous "/redfish/v1/UpdateService"; 768d1b46d7Szhanghch05 asyncResp->res.jsonValue["UUID"] = uuid; 771476687dSEd Tanous asyncResp->res.jsonValue["CertificateService"]["@odata.id"] = 781476687dSEd Tanous "/redfish/v1/CertificateService"; 791476687dSEd Tanous asyncResp->res.jsonValue["Tasks"]["@odata.id"] = "/redfish/v1/TaskService"; 801476687dSEd Tanous asyncResp->res.jsonValue["EventService"]["@odata.id"] = 811476687dSEd Tanous "/redfish/v1/EventService"; 821476687dSEd Tanous asyncResp->res.jsonValue["TelemetryService"]["@odata.id"] = 831476687dSEd Tanous "/redfish/v1/TelemetryService"; 841476687dSEd Tanous asyncResp->res.jsonValue["Cables"]["@odata.id"] = "/redfish/v1/Cables"; 859629907dSNan Zhou 86e68d1be0SEd Tanous asyncResp->res.jsonValue["Links"]["ManagerProvidingService"]["@odata.id"] = 87e68d1be0SEd Tanous "/redfish/v1/Managers/bmc"; 88e68d1be0SEd Tanous 899629907dSNan Zhou nlohmann::json& protocolFeatures = 909629907dSNan Zhou asyncResp->res.jsonValue["ProtocolFeaturesSupported"]; 919629907dSNan Zhou protocolFeatures["ExcerptQuery"] = false; 927cf436c9SEd Tanous 937cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["ExpandAll"] = 947cf436c9SEd Tanous bmcwebInsecureEnableQueryParams; 957cf436c9SEd Tanous // This is the maximum level defined in ServiceRoot.v1_13_0.json 967cf436c9SEd Tanous if (bmcwebInsecureEnableQueryParams) 977cf436c9SEd Tanous { 987cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["MaxLevels"] = 6; 997cf436c9SEd Tanous } 1007cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["Levels"] = bmcwebInsecureEnableQueryParams; 1017cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["Links"] = bmcwebInsecureEnableQueryParams; 1027cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["NoLinks"] = 1037cf436c9SEd Tanous bmcwebInsecureEnableQueryParams; 1049629907dSNan Zhou protocolFeatures["FilterQuery"] = false; 1050553fb57SNan Zhou protocolFeatures["OnlyMemberQuery"] = true; 10607ffa4e8SNan Zhou protocolFeatures["SelectQuery"] = true; 1079629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPOST"] = false; 1089629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPATCH"] = false; 1098338891aSJohn Edward Broadbent } 1105b224921SEd Tanous inline void 1115b224921SEd Tanous handleServiceRootGet(App& app, const crow::Request& req, 1125b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 1135b224921SEd Tanous { 1145b224921SEd Tanous handleServiceRootHead(app, req, asyncResp); 1155b224921SEd Tanous handleServiceRootGetImpl(asyncResp); 1165b224921SEd Tanous } 1178338891aSJohn Edward Broadbent 1188338891aSJohn Edward Broadbent inline void requestRoutesServiceRoot(App& app) 1198338891aSJohn Edward Broadbent { 1208338891aSJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/") 1215b224921SEd Tanous .privileges(redfish::privileges::headServiceRoot) 1225b224921SEd Tanous .methods(boost::beast::http::verb::head)( 1235b224921SEd Tanous std::bind_front(handleServiceRootHead, std::ref(app))); 1245b224921SEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/") 1258338891aSJohn Edward Broadbent .privileges(redfish::privileges::getServiceRoot) 1267cf436c9SEd Tanous .methods(boost::beast::http::verb::get)( 1275b224921SEd Tanous std::bind_front(handleServiceRootGet, std::ref(app))); 128b6df6dc7SBorawski.Lukasz } 1293602e232SEd Tanous 130b6df6dc7SBorawski.Lukasz } // namespace redfish 131