140e9b92eSEd Tanous // SPDX-License-Identifier: Apache-2.0 240e9b92eSEd Tanous // SPDX-FileCopyrightText: Copyright OpenBMC Authors 340e9b92eSEd Tanous // SPDX-FileCopyrightText: Copyright 2018 Intel Corporation 4b6df6dc7SBorawski.Lukasz #pragma once 5b6df6dc7SBorawski.Lukasz 63ccb3adbSEd Tanous #include "bmcweb_config.h" 7f4c99e70SEd Tanous 83ccb3adbSEd Tanous #include "app.hpp" 93ccb3adbSEd Tanous #include "async_resp.hpp" 103ccb3adbSEd Tanous #include "http_request.hpp" 113ccb3adbSEd Tanous #include "persistent_data.hpp" 123ccb3adbSEd Tanous #include "query.hpp" 133ccb3adbSEd Tanous #include "registries/privilege_registry.hpp" 14*e30d3345SCorey Ethington #include "utils/manager_utils.hpp" 153ccb3adbSEd Tanous 16d7857201SEd Tanous #include <boost/beast/http/field.hpp> 17d7857201SEd Tanous #include <boost/beast/http/verb.hpp> 18d7857201SEd Tanous #include <boost/url/format.hpp> 199629907dSNan Zhou #include <nlohmann/json.hpp> 20b6df6dc7SBorawski.Lukasz 21d7857201SEd Tanous #include <functional> 22d7857201SEd Tanous #include <memory> 23d7857201SEd Tanous #include <string> 24d7857201SEd Tanous 251abe55efSEd Tanous namespace redfish 261abe55efSEd Tanous { 271abe55efSEd Tanous 28504af5a0SPatrick Williams inline void handleServiceRootHead( 29504af5a0SPatrick Williams App& app, const crow::Request& req, 305b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 315b224921SEd Tanous { 325b224921SEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 335b224921SEd Tanous { 345b224921SEd Tanous return; 355b224921SEd Tanous } 365b224921SEd Tanous 375b224921SEd Tanous asyncResp->res.addHeader( 385b224921SEd Tanous boost::beast::http::field::link, 395b224921SEd Tanous "</redfish/v1/JsonSchemas/ServiceRoot/ServiceRoot.json>; rel=describedby"); 405b224921SEd Tanous } 415b224921SEd Tanous 425b224921SEd Tanous inline void handleServiceRootGetImpl( 435b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 441abe55efSEd Tanous { 4501a89a1fSEd Tanous asyncResp->res.addHeader( 4601a89a1fSEd Tanous boost::beast::http::field::link, 4701a89a1fSEd Tanous "</redfish/v1/JsonSchemas/ServiceRoot/ServiceRoot.json>; rel=describedby"); 4801a89a1fSEd Tanous 497e860f15SJohn Edward Broadbent std::string uuid = persistent_data::getConfig().systemUuid; 509c929beaSShantappa Teekappanavar asyncResp->res.jsonValue["@odata.type"] = 51e68d1be0SEd Tanous "#ServiceRoot.v1_15_0.ServiceRoot"; 528d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1"; 538d1b46d7Szhanghch05 asyncResp->res.jsonValue["Id"] = "RootService"; 548d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Root Service"; 55c16e292cSEd Tanous asyncResp->res.jsonValue["RedfishVersion"] = "1.17.0"; 561476687dSEd Tanous asyncResp->res.jsonValue["Links"]["Sessions"]["@odata.id"] = 571476687dSEd Tanous "/redfish/v1/SessionService/Sessions"; 581476687dSEd Tanous asyncResp->res.jsonValue["AccountService"]["@odata.id"] = 591476687dSEd Tanous "/redfish/v1/AccountService"; 6025b54dbaSEd Tanous if constexpr (BMCWEB_REDFISH_AGGREGATION) 6125b54dbaSEd Tanous { 626c068982SEd Tanous asyncResp->res.jsonValue["AggregationService"]["@odata.id"] = 636c068982SEd Tanous "/redfish/v1/AggregationService"; 6425b54dbaSEd Tanous } 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"; 84*e30d3345SCorey Ethington manager_utils::getServiceIdentification(asyncResp, true); 851476687dSEd Tanous asyncResp->res.jsonValue["Cables"]["@odata.id"] = "/redfish/v1/Cables"; 869629907dSNan Zhou 87e68d1be0SEd Tanous asyncResp->res.jsonValue["Links"]["ManagerProvidingService"]["@odata.id"] = 88253f11b8SEd Tanous boost::urls::format("/redfish/v1/Managers/{}", 89253f11b8SEd Tanous BMCWEB_REDFISH_MANAGER_URI_NAME); 90e68d1be0SEd Tanous 919629907dSNan Zhou nlohmann::json& protocolFeatures = 929629907dSNan Zhou asyncResp->res.jsonValue["ProtocolFeaturesSupported"]; 939629907dSNan Zhou protocolFeatures["ExcerptQuery"] = false; 947cf436c9SEd Tanous 957cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["ExpandAll"] = 9625b54dbaSEd Tanous BMCWEB_INSECURE_ENABLE_REDFISH_QUERY; 977cf436c9SEd Tanous // This is the maximum level defined in ServiceRoot.v1_13_0.json 9825b54dbaSEd Tanous if constexpr (BMCWEB_INSECURE_ENABLE_REDFISH_QUERY) 997cf436c9SEd Tanous { 1007cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["MaxLevels"] = 6; 1017cf436c9SEd Tanous } 10225b54dbaSEd Tanous protocolFeatures["ExpandQuery"]["Levels"] = 10325b54dbaSEd Tanous BMCWEB_INSECURE_ENABLE_REDFISH_QUERY; 10425b54dbaSEd Tanous protocolFeatures["ExpandQuery"]["Links"] = 10525b54dbaSEd Tanous BMCWEB_INSECURE_ENABLE_REDFISH_QUERY; 1067cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["NoLinks"] = 10725b54dbaSEd Tanous BMCWEB_INSECURE_ENABLE_REDFISH_QUERY; 10825991f7dSEd Tanous protocolFeatures["FilterQuery"] = BMCWEB_INSECURE_ENABLE_REDFISH_QUERY; 1090553fb57SNan Zhou protocolFeatures["OnlyMemberQuery"] = true; 11007ffa4e8SNan Zhou protocolFeatures["SelectQuery"] = true; 1119629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPOST"] = false; 1129629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPATCH"] = false; 1138338891aSJohn Edward Broadbent } 114504af5a0SPatrick Williams inline void handleServiceRootGet( 115504af5a0SPatrick Williams App& app, const crow::Request& req, 1165b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 1175b224921SEd Tanous { 11801a89a1fSEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 11901a89a1fSEd Tanous { 12001a89a1fSEd Tanous return; 12101a89a1fSEd Tanous } 12201a89a1fSEd Tanous 1235b224921SEd Tanous handleServiceRootGetImpl(asyncResp); 1245b224921SEd Tanous } 1258338891aSJohn Edward Broadbent 1268338891aSJohn Edward Broadbent inline void requestRoutesServiceRoot(App& app) 1278338891aSJohn Edward Broadbent { 1288338891aSJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/") 1295b224921SEd Tanous .privileges(redfish::privileges::headServiceRoot) 1305b224921SEd Tanous .methods(boost::beast::http::verb::head)( 1315b224921SEd Tanous std::bind_front(handleServiceRootHead, std::ref(app))); 1325b224921SEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/") 1338338891aSJohn Edward Broadbent .privileges(redfish::privileges::getServiceRoot) 1347cf436c9SEd Tanous .methods(boost::beast::http::verb::get)( 1355b224921SEd Tanous std::bind_front(handleServiceRootGet, std::ref(app))); 136b6df6dc7SBorawski.Lukasz } 1373602e232SEd Tanous 138b6df6dc7SBorawski.Lukasz } // namespace redfish 139