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 18f4c99e70SEd Tanous #include <bmcweb_config.h> 19f4c99e70SEd Tanous 207e860f15SJohn Edward Broadbent #include <app.hpp> 219629907dSNan Zhou #include <async_resp.hpp> 229629907dSNan Zhou #include <http_request.hpp> 239629907dSNan Zhou #include <nlohmann/json.hpp> 248338891aSJohn Edward Broadbent #include <persistent_data.hpp> 257cf436c9SEd Tanous #include <query.hpp> 26ed398213SEd Tanous #include <registries/privilege_registry.hpp> 277bffdb7eSBernard Wong #include <utils/systemd_utils.hpp> 28b6df6dc7SBorawski.Lukasz 291abe55efSEd Tanous namespace redfish 301abe55efSEd Tanous { 311abe55efSEd Tanous 328338891aSJohn Edward Broadbent inline void 335b224921SEd Tanous handleServiceRootHead(App& app, const crow::Request& req, 345b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 355b224921SEd Tanous { 365b224921SEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 375b224921SEd Tanous { 385b224921SEd Tanous return; 395b224921SEd Tanous } 405b224921SEd Tanous 415b224921SEd Tanous asyncResp->res.addHeader( 425b224921SEd Tanous boost::beast::http::field::link, 435b224921SEd Tanous "</redfish/v1/JsonSchemas/ServiceRoot/ServiceRoot.json>; rel=describedby"); 445b224921SEd Tanous } 455b224921SEd Tanous 465b224921SEd Tanous inline void handleServiceRootGetImpl( 475b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 481abe55efSEd Tanous { 497e860f15SJohn Edward Broadbent std::string uuid = persistent_data::getConfig().systemUuid; 509c929beaSShantappa Teekappanavar asyncResp->res.jsonValue["@odata.type"] = 519c929beaSShantappa Teekappanavar "#ServiceRoot.v1_11_0.ServiceRoot"; 528d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1"; 538d1b46d7Szhanghch05 asyncResp->res.jsonValue["Id"] = "RootService"; 548d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Root Service"; 558d1b46d7Szhanghch05 asyncResp->res.jsonValue["RedfishVersion"] = "1.9.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"; 601476687dSEd Tanous asyncResp->res.jsonValue["Chassis"]["@odata.id"] = "/redfish/v1/Chassis"; 611476687dSEd Tanous asyncResp->res.jsonValue["JsonSchemas"]["@odata.id"] = 621476687dSEd Tanous "/redfish/v1/JsonSchemas"; 631476687dSEd Tanous asyncResp->res.jsonValue["Managers"]["@odata.id"] = "/redfish/v1/Managers"; 641476687dSEd Tanous asyncResp->res.jsonValue["SessionService"]["@odata.id"] = 651476687dSEd Tanous "/redfish/v1/SessionService"; 661476687dSEd Tanous asyncResp->res.jsonValue["Systems"]["@odata.id"] = "/redfish/v1/Systems"; 671476687dSEd Tanous asyncResp->res.jsonValue["Registries"]["@odata.id"] = 681476687dSEd Tanous "/redfish/v1/Registries"; 691476687dSEd Tanous asyncResp->res.jsonValue["UpdateService"]["@odata.id"] = 701476687dSEd Tanous "/redfish/v1/UpdateService"; 718d1b46d7Szhanghch05 asyncResp->res.jsonValue["UUID"] = uuid; 721476687dSEd Tanous asyncResp->res.jsonValue["CertificateService"]["@odata.id"] = 731476687dSEd Tanous "/redfish/v1/CertificateService"; 741476687dSEd Tanous asyncResp->res.jsonValue["Tasks"]["@odata.id"] = "/redfish/v1/TaskService"; 751476687dSEd Tanous asyncResp->res.jsonValue["EventService"]["@odata.id"] = 761476687dSEd Tanous "/redfish/v1/EventService"; 771476687dSEd Tanous asyncResp->res.jsonValue["TelemetryService"]["@odata.id"] = 781476687dSEd Tanous "/redfish/v1/TelemetryService"; 791476687dSEd Tanous asyncResp->res.jsonValue["Cables"]["@odata.id"] = "/redfish/v1/Cables"; 809629907dSNan Zhou 819629907dSNan Zhou nlohmann::json& protocolFeatures = 829629907dSNan Zhou asyncResp->res.jsonValue["ProtocolFeaturesSupported"]; 839629907dSNan Zhou protocolFeatures["ExcerptQuery"] = false; 847cf436c9SEd Tanous 857cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["ExpandAll"] = 867cf436c9SEd Tanous bmcwebInsecureEnableQueryParams; 877cf436c9SEd Tanous // This is the maximum level defined in ServiceRoot.v1_13_0.json 887cf436c9SEd Tanous if (bmcwebInsecureEnableQueryParams) 897cf436c9SEd Tanous { 907cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["MaxLevels"] = 6; 917cf436c9SEd Tanous } 927cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["Levels"] = bmcwebInsecureEnableQueryParams; 937cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["Links"] = bmcwebInsecureEnableQueryParams; 947cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["NoLinks"] = 957cf436c9SEd Tanous bmcwebInsecureEnableQueryParams; 969629907dSNan Zhou protocolFeatures["FilterQuery"] = false; 97*0553fb57SNan Zhou protocolFeatures["OnlyMemberQuery"] = true; 98f252a6a7SEd Tanous protocolFeatures["SelectQuery"] = bmcwebInsecureEnableQueryParams; 999629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPOST"] = false; 1009629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPATCH"] = false; 1018338891aSJohn Edward Broadbent } 1025b224921SEd Tanous inline void 1035b224921SEd Tanous handleServiceRootGet(App& app, const crow::Request& req, 1045b224921SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 1055b224921SEd Tanous { 1065b224921SEd Tanous handleServiceRootHead(app, req, asyncResp); 1075b224921SEd Tanous handleServiceRootGetImpl(asyncResp); 1085b224921SEd Tanous } 1098338891aSJohn Edward Broadbent 1108338891aSJohn Edward Broadbent inline void requestRoutesServiceRoot(App& app) 1118338891aSJohn Edward Broadbent { 1128338891aSJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/") 1135b224921SEd Tanous .privileges(redfish::privileges::headServiceRoot) 1145b224921SEd Tanous .methods(boost::beast::http::verb::head)( 1155b224921SEd Tanous std::bind_front(handleServiceRootHead, std::ref(app))); 1165b224921SEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/") 1178338891aSJohn Edward Broadbent .privileges(redfish::privileges::getServiceRoot) 1187cf436c9SEd Tanous .methods(boost::beast::http::verb::get)( 1195b224921SEd Tanous std::bind_front(handleServiceRootGet, std::ref(app))); 120b6df6dc7SBorawski.Lukasz } 1213602e232SEd Tanous 122b6df6dc7SBorawski.Lukasz } // namespace redfish 123