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 { 5001a89a1fSEd Tanous asyncResp->res.addHeader( 5101a89a1fSEd Tanous boost::beast::http::field::link, 5201a89a1fSEd Tanous "</redfish/v1/JsonSchemas/ServiceRoot/ServiceRoot.json>; rel=describedby"); 5301a89a1fSEd Tanous 547e860f15SJohn Edward Broadbent std::string uuid = persistent_data::getConfig().systemUuid; 559c929beaSShantappa Teekappanavar asyncResp->res.jsonValue["@odata.type"] = 56e68d1be0SEd Tanous "#ServiceRoot.v1_15_0.ServiceRoot"; 578d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1"; 588d1b46d7Szhanghch05 asyncResp->res.jsonValue["Id"] = "RootService"; 598d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Root Service"; 60c16e292cSEd Tanous asyncResp->res.jsonValue["RedfishVersion"] = "1.17.0"; 611476687dSEd Tanous asyncResp->res.jsonValue["Links"]["Sessions"]["@odata.id"] = 621476687dSEd Tanous "/redfish/v1/SessionService/Sessions"; 631476687dSEd Tanous asyncResp->res.jsonValue["AccountService"]["@odata.id"] = 641476687dSEd Tanous "/redfish/v1/AccountService"; 65*25b54dbaSEd Tanous if constexpr (BMCWEB_REDFISH_AGGREGATION) 66*25b54dbaSEd Tanous { 676c068982SEd Tanous asyncResp->res.jsonValue["AggregationService"]["@odata.id"] = 686c068982SEd Tanous "/redfish/v1/AggregationService"; 69*25b54dbaSEd Tanous } 701476687dSEd Tanous asyncResp->res.jsonValue["Chassis"]["@odata.id"] = "/redfish/v1/Chassis"; 711476687dSEd Tanous asyncResp->res.jsonValue["JsonSchemas"]["@odata.id"] = 721476687dSEd Tanous "/redfish/v1/JsonSchemas"; 731476687dSEd Tanous asyncResp->res.jsonValue["Managers"]["@odata.id"] = "/redfish/v1/Managers"; 741476687dSEd Tanous asyncResp->res.jsonValue["SessionService"]["@odata.id"] = 751476687dSEd Tanous "/redfish/v1/SessionService"; 761476687dSEd Tanous asyncResp->res.jsonValue["Systems"]["@odata.id"] = "/redfish/v1/Systems"; 771476687dSEd Tanous asyncResp->res.jsonValue["Registries"]["@odata.id"] = 781476687dSEd Tanous "/redfish/v1/Registries"; 791476687dSEd Tanous asyncResp->res.jsonValue["UpdateService"]["@odata.id"] = 801476687dSEd Tanous "/redfish/v1/UpdateService"; 818d1b46d7Szhanghch05 asyncResp->res.jsonValue["UUID"] = uuid; 821476687dSEd Tanous asyncResp->res.jsonValue["CertificateService"]["@odata.id"] = 831476687dSEd Tanous "/redfish/v1/CertificateService"; 841476687dSEd Tanous asyncResp->res.jsonValue["Tasks"]["@odata.id"] = "/redfish/v1/TaskService"; 851476687dSEd Tanous asyncResp->res.jsonValue["EventService"]["@odata.id"] = 861476687dSEd Tanous "/redfish/v1/EventService"; 871476687dSEd Tanous asyncResp->res.jsonValue["TelemetryService"]["@odata.id"] = 881476687dSEd Tanous "/redfish/v1/TelemetryService"; 891476687dSEd Tanous asyncResp->res.jsonValue["Cables"]["@odata.id"] = "/redfish/v1/Cables"; 909629907dSNan Zhou 91e68d1be0SEd Tanous asyncResp->res.jsonValue["Links"]["ManagerProvidingService"]["@odata.id"] = 92e68d1be0SEd Tanous "/redfish/v1/Managers/bmc"; 93e68d1be0SEd Tanous 949629907dSNan Zhou nlohmann::json& protocolFeatures = 959629907dSNan Zhou asyncResp->res.jsonValue["ProtocolFeaturesSupported"]; 969629907dSNan Zhou protocolFeatures["ExcerptQuery"] = false; 977cf436c9SEd Tanous 987cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["ExpandAll"] = 99*25b54dbaSEd Tanous BMCWEB_INSECURE_ENABLE_REDFISH_QUERY; 1007cf436c9SEd Tanous // This is the maximum level defined in ServiceRoot.v1_13_0.json 101*25b54dbaSEd Tanous if constexpr (BMCWEB_INSECURE_ENABLE_REDFISH_QUERY) 1027cf436c9SEd Tanous { 1037cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["MaxLevels"] = 6; 1047cf436c9SEd Tanous } 105*25b54dbaSEd Tanous protocolFeatures["ExpandQuery"]["Levels"] = 106*25b54dbaSEd Tanous BMCWEB_INSECURE_ENABLE_REDFISH_QUERY; 107*25b54dbaSEd Tanous protocolFeatures["ExpandQuery"]["Links"] = 108*25b54dbaSEd Tanous BMCWEB_INSECURE_ENABLE_REDFISH_QUERY; 1097cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["NoLinks"] = 110*25b54dbaSEd Tanous BMCWEB_INSECURE_ENABLE_REDFISH_QUERY; 1119629907dSNan Zhou protocolFeatures["FilterQuery"] = false; 1120553fb57SNan Zhou protocolFeatures["OnlyMemberQuery"] = true; 11307ffa4e8SNan Zhou protocolFeatures["SelectQuery"] = true; 1149629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPOST"] = false; 1159629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPATCH"] = false; 1168338891aSJohn Edward Broadbent } 1175b224921SEd Tanous inline void 1185b224921SEd Tanous handleServiceRootGet(App& app, const crow::Request& req, 1195b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 1205b224921SEd Tanous { 12101a89a1fSEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 12201a89a1fSEd Tanous { 12301a89a1fSEd Tanous return; 12401a89a1fSEd Tanous } 12501a89a1fSEd Tanous 1265b224921SEd Tanous handleServiceRootGetImpl(asyncResp); 1275b224921SEd Tanous } 1288338891aSJohn Edward Broadbent 1298338891aSJohn Edward Broadbent inline void requestRoutesServiceRoot(App& app) 1308338891aSJohn Edward Broadbent { 1318338891aSJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/") 1325b224921SEd Tanous .privileges(redfish::privileges::headServiceRoot) 1335b224921SEd Tanous .methods(boost::beast::http::verb::head)( 1345b224921SEd Tanous std::bind_front(handleServiceRootHead, std::ref(app))); 1355b224921SEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/") 1368338891aSJohn Edward Broadbent .privileges(redfish::privileges::getServiceRoot) 1377cf436c9SEd Tanous .methods(boost::beast::http::verb::get)( 1385b224921SEd Tanous std::bind_front(handleServiceRootGet, std::ref(app))); 139b6df6dc7SBorawski.Lukasz } 1403602e232SEd Tanous 141b6df6dc7SBorawski.Lukasz } // namespace redfish 142