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> 25*7cf436c9SEd 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 33*7cf436c9SEd Tanous handleServiceRootGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 341abe55efSEd Tanous { 357e860f15SJohn Edward Broadbent std::string uuid = persistent_data::getConfig().systemUuid; 369c929beaSShantappa Teekappanavar asyncResp->res.jsonValue["@odata.type"] = 379c929beaSShantappa Teekappanavar "#ServiceRoot.v1_11_0.ServiceRoot"; 388d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1"; 398d1b46d7Szhanghch05 asyncResp->res.jsonValue["Id"] = "RootService"; 408d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Root Service"; 418d1b46d7Szhanghch05 asyncResp->res.jsonValue["RedfishVersion"] = "1.9.0"; 428d1b46d7Szhanghch05 asyncResp->res.jsonValue["Links"]["Sessions"] = { 430f74e643SEd Tanous {"@odata.id", "/redfish/v1/SessionService/Sessions"}}; 448d1b46d7Szhanghch05 asyncResp->res.jsonValue["AccountService"] = { 450f74e643SEd Tanous {"@odata.id", "/redfish/v1/AccountService"}}; 468d1b46d7Szhanghch05 asyncResp->res.jsonValue["Chassis"] = { 478d1b46d7Szhanghch05 {"@odata.id", "/redfish/v1/Chassis"}}; 488d1b46d7Szhanghch05 asyncResp->res.jsonValue["JsonSchemas"] = { 490f74e643SEd Tanous {"@odata.id", "/redfish/v1/JsonSchemas"}}; 508d1b46d7Szhanghch05 asyncResp->res.jsonValue["Managers"] = { 518d1b46d7Szhanghch05 {"@odata.id", "/redfish/v1/Managers"}}; 528d1b46d7Szhanghch05 asyncResp->res.jsonValue["SessionService"] = { 538d3cae6bSGunnar Mills {"@odata.id", "/redfish/v1/SessionService"}}; 548d1b46d7Szhanghch05 asyncResp->res.jsonValue["Systems"] = { 558d1b46d7Szhanghch05 {"@odata.id", "/redfish/v1/Systems"}}; 568d1b46d7Szhanghch05 asyncResp->res.jsonValue["Registries"] = { 578d1b46d7Szhanghch05 {"@odata.id", "/redfish/v1/Registries"}}; 580f74e643SEd Tanous 598d1b46d7Szhanghch05 asyncResp->res.jsonValue["UpdateService"] = { 600f74e643SEd Tanous {"@odata.id", "/redfish/v1/UpdateService"}}; 618d1b46d7Szhanghch05 asyncResp->res.jsonValue["UUID"] = uuid; 628d1b46d7Szhanghch05 asyncResp->res.jsonValue["CertificateService"] = { 635968caeeSMarri Devender Rao {"@odata.id", "/redfish/v1/CertificateService"}}; 648d1b46d7Szhanghch05 asyncResp->res.jsonValue["Tasks"] = { 658d1b46d7Szhanghch05 {"@odata.id", "/redfish/v1/TaskService"}}; 668d1b46d7Szhanghch05 asyncResp->res.jsonValue["EventService"] = { 67e5aaf047SAppaRao Puli {"@odata.id", "/redfish/v1/EventService"}}; 688d1b46d7Szhanghch05 asyncResp->res.jsonValue["TelemetryService"] = { 69081ebf06SWludzik, Jozef {"@odata.id", "/redfish/v1/TelemetryService"}}; 709c929beaSShantappa Teekappanavar asyncResp->res.jsonValue["Cables"] = {{"@odata.id", "/redfish/v1/Cables"}}; 719629907dSNan Zhou 729629907dSNan Zhou nlohmann::json& protocolFeatures = 739629907dSNan Zhou asyncResp->res.jsonValue["ProtocolFeaturesSupported"]; 749629907dSNan Zhou protocolFeatures["ExcerptQuery"] = false; 75*7cf436c9SEd Tanous 76*7cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["ExpandAll"] = 77*7cf436c9SEd Tanous bmcwebInsecureEnableQueryParams; 78*7cf436c9SEd Tanous // This is the maximum level defined in ServiceRoot.v1_13_0.json 79*7cf436c9SEd Tanous if (bmcwebInsecureEnableQueryParams) 80*7cf436c9SEd Tanous { 81*7cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["MaxLevels"] = 6; 82*7cf436c9SEd Tanous } 83*7cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["Levels"] = bmcwebInsecureEnableQueryParams; 84*7cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["Links"] = bmcwebInsecureEnableQueryParams; 85*7cf436c9SEd Tanous protocolFeatures["ExpandQuery"]["NoLinks"] = 86*7cf436c9SEd Tanous bmcwebInsecureEnableQueryParams; 879629907dSNan Zhou protocolFeatures["FilterQuery"] = false; 88f4c99e70SEd Tanous protocolFeatures["OnlyMemberQuery"] = bmcwebInsecureEnableQueryParams; 899629907dSNan Zhou protocolFeatures["SelectQuery"] = false; 909629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPOST"] = false; 919629907dSNan Zhou protocolFeatures["DeepOperations"]["DeepPATCH"] = false; 928338891aSJohn Edward Broadbent } 938338891aSJohn Edward Broadbent 948338891aSJohn Edward Broadbent inline void requestRoutesServiceRoot(App& app) 958338891aSJohn Edward Broadbent { 968338891aSJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/") 978338891aSJohn Edward Broadbent .privileges(redfish::privileges::getServiceRoot) 98*7cf436c9SEd Tanous .methods(boost::beast::http::verb::get)( 99*7cf436c9SEd Tanous [&app](const crow::Request& req, 100*7cf436c9SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 101*7cf436c9SEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) 102*7cf436c9SEd Tanous { 103*7cf436c9SEd Tanous return; 104*7cf436c9SEd Tanous } 105*7cf436c9SEd Tanous handleServiceRootGet(asyncResp); 106*7cf436c9SEd Tanous }); 107b6df6dc7SBorawski.Lukasz } 1083602e232SEd Tanous 109b6df6dc7SBorawski.Lukasz } // namespace redfish 110