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 18*3ccb3adbSEd Tanous #include "bmcweb_config.h" 19f4c99e70SEd Tanous 20*3ccb3adbSEd Tanous #include "app.hpp" 21*3ccb3adbSEd Tanous #include "async_resp.hpp" 22*3ccb3adbSEd Tanous #include "http_request.hpp" 23*3ccb3adbSEd Tanous #include "persistent_data.hpp" 24*3ccb3adbSEd Tanous #include "query.hpp" 25*3ccb3adbSEd Tanous #include "registries/privilege_registry.hpp" 26*3ccb3adbSEd Tanous #include "utils/systemd_utils.hpp" 27*3ccb3adbSEd 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"] = 529c929beaSShantappa Teekappanavar "#ServiceRoot.v1_11_0.ServiceRoot"; 538d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1"; 548d1b46d7Szhanghch05 asyncResp->res.jsonValue["Id"] = "RootService"; 558d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Root Service"; 568d1b46d7Szhanghch05 asyncResp->res.jsonValue["RedfishVersion"] = "1.9.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"; 611476687dSEd Tanous asyncResp->res.jsonValue["Chassis"]["@odata.id"] = "/redfish/v1/Chassis"; 621476687dSEd Tanous asyncResp->res.jsonValue["JsonSchemas"]["@odata.id"] = 631476687dSEd Tanous "/redfish/v1/JsonSchemas"; 641476687dSEd Tanous asyncResp->res.jsonValue["Managers"]["@odata.id"] = "/redfish/v1/Managers"; 651476687dSEd Tanous asyncResp->res.jsonValue["SessionService"]["@odata.id"] = 661476687dSEd Tanous "/redfish/v1/SessionService"; 671476687dSEd Tanous asyncResp->res.jsonValue["Systems"]["@odata.id"] = "/redfish/v1/Systems"; 681476687dSEd Tanous asyncResp->res.jsonValue["Registries"]["@odata.id"] = 691476687dSEd Tanous "/redfish/v1/Registries"; 701476687dSEd Tanous asyncResp->res.jsonValue["UpdateService"]["@odata.id"] = 711476687dSEd Tanous "/redfish/v1/UpdateService"; 728d1b46d7Szhanghch05 asyncResp->res.jsonValue["UUID"] = uuid; 731476687dSEd Tanous asyncResp->res.jsonValue["CertificateService"]["@odata.id"] = 741476687dSEd Tanous "/redfish/v1/CertificateService"; 751476687dSEd Tanous asyncResp->res.jsonValue["Tasks"]["@odata.id"] = "/redfish/v1/TaskService"; 761476687dSEd Tanous asyncResp->res.jsonValue["EventService"]["@odata.id"] = 771476687dSEd Tanous "/redfish/v1/EventService"; 781476687dSEd Tanous asyncResp->res.jsonValue["TelemetryService"]["@odata.id"] = 791476687dSEd Tanous "/redfish/v1/TelemetryService"; 801476687dSEd Tanous asyncResp->res.jsonValue["Cables"]["@odata.id"] = "/redfish/v1/Cables"; 819629907dSNan Zhou 829629907dSNan Zhou nlohmann::json& protocolFeatures = 839629907dSNan Zhou asyncResp->res.jsonValue["ProtocolFeaturesSupported"]; 849629907dSNan Zhou protocolFeatures["ExcerptQuery"] = false; 857cf436c9SEd Tanous 867cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["ExpandAll"] = 877cf436c9SEd Tanous bmcwebInsecureEnableQueryParams; 887cf436c9SEd Tanous // This is the maximum level defined in ServiceRoot.v1_13_0.json 897cf436c9SEd Tanous if (bmcwebInsecureEnableQueryParams) 907cf436c9SEd Tanous { 917cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["MaxLevels"] = 6; 927cf436c9SEd Tanous } 937cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["Levels"] = bmcwebInsecureEnableQueryParams; 947cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["Links"] = bmcwebInsecureEnableQueryParams; 957cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["NoLinks"] = 967cf436c9SEd Tanous bmcwebInsecureEnableQueryParams; 979629907dSNan Zhou protocolFeatures["FilterQuery"] = false; 980553fb57SNan Zhou protocolFeatures["OnlyMemberQuery"] = true; 9907ffa4e8SNan Zhou protocolFeatures["SelectQuery"] = true; 1009629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPOST"] = false; 1019629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPATCH"] = false; 1028338891aSJohn Edward Broadbent } 1035b224921SEd Tanous inline void 1045b224921SEd Tanous handleServiceRootGet(App& app, const crow::Request& req, 1055b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 1065b224921SEd Tanous { 1075b224921SEd Tanous handleServiceRootHead(app, req, asyncResp); 1085b224921SEd Tanous handleServiceRootGetImpl(asyncResp); 1095b224921SEd Tanous } 1108338891aSJohn Edward Broadbent 1118338891aSJohn Edward Broadbent inline void requestRoutesServiceRoot(App& app) 1128338891aSJohn Edward Broadbent { 1138338891aSJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/") 1145b224921SEd Tanous .privileges(redfish::privileges::headServiceRoot) 1155b224921SEd Tanous .methods(boost::beast::http::verb::head)( 1165b224921SEd Tanous std::bind_front(handleServiceRootHead, std::ref(app))); 1175b224921SEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/") 1188338891aSJohn Edward Broadbent .privileges(redfish::privileges::getServiceRoot) 1197cf436c9SEd Tanous .methods(boost::beast::http::verb::get)( 1205b224921SEd Tanous std::bind_front(handleServiceRootGet, std::ref(app))); 121b6df6dc7SBorawski.Lukasz } 1223602e232SEd Tanous 123b6df6dc7SBorawski.Lukasz } // namespace redfish 124