Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
| 17 | |
Ed Tanous | f4c99e7 | 2021-10-04 17:02:43 -0700 | [diff] [blame] | 18 | #include <bmcweb_config.h> |
| 19 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 20 | #include <app.hpp> |
Nan Zhou | 9629907 | 2022-03-23 09:13:46 -0700 | [diff] [blame] | 21 | #include <async_resp.hpp> |
| 22 | #include <http_request.hpp> |
| 23 | #include <nlohmann/json.hpp> |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 24 | #include <persistent_data.hpp> |
Ed Tanous | 7cf436c | 2022-03-22 23:53:51 -0700 | [diff] [blame] | 25 | #include <query.hpp> |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 26 | #include <registries/privilege_registry.hpp> |
Bernard Wong | 7bffdb7 | 2019-03-20 16:17:21 +0800 | [diff] [blame] | 27 | #include <utils/systemd_utils.hpp> |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 28 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 29 | namespace redfish |
| 30 | { |
Ed Tanous | 3ebd75f | 2018-03-05 18:20:01 -0800 | [diff] [blame] | 31 | |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 32 | inline void |
Ed Tanous | 7cf436c | 2022-03-22 23:53:51 -0700 | [diff] [blame] | 33 | handleServiceRootGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 34 | { |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 35 | std::string uuid = persistent_data::getConfig().systemUuid; |
Shantappa Teekappanavar | 9c929be | 2021-12-16 19:02:52 -0600 | [diff] [blame] | 36 | asyncResp->res.jsonValue["@odata.type"] = |
| 37 | "#ServiceRoot.v1_11_0.ServiceRoot"; |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 38 | asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1"; |
| 39 | asyncResp->res.jsonValue["Id"] = "RootService"; |
| 40 | asyncResp->res.jsonValue["Name"] = "Root Service"; |
| 41 | asyncResp->res.jsonValue["RedfishVersion"] = "1.9.0"; |
| 42 | asyncResp->res.jsonValue["Links"]["Sessions"] = { |
| 43 | {"@odata.id", "/redfish/v1/SessionService/Sessions"}}; |
| 44 | asyncResp->res.jsonValue["AccountService"] = { |
| 45 | {"@odata.id", "/redfish/v1/AccountService"}}; |
| 46 | asyncResp->res.jsonValue["Chassis"] = { |
| 47 | {"@odata.id", "/redfish/v1/Chassis"}}; |
| 48 | asyncResp->res.jsonValue["JsonSchemas"] = { |
| 49 | {"@odata.id", "/redfish/v1/JsonSchemas"}}; |
| 50 | asyncResp->res.jsonValue["Managers"] = { |
| 51 | {"@odata.id", "/redfish/v1/Managers"}}; |
| 52 | asyncResp->res.jsonValue["SessionService"] = { |
| 53 | {"@odata.id", "/redfish/v1/SessionService"}}; |
| 54 | asyncResp->res.jsonValue["Systems"] = { |
| 55 | {"@odata.id", "/redfish/v1/Systems"}}; |
| 56 | asyncResp->res.jsonValue["Registries"] = { |
| 57 | {"@odata.id", "/redfish/v1/Registries"}}; |
| 58 | |
| 59 | asyncResp->res.jsonValue["UpdateService"] = { |
| 60 | {"@odata.id", "/redfish/v1/UpdateService"}}; |
| 61 | asyncResp->res.jsonValue["UUID"] = uuid; |
| 62 | asyncResp->res.jsonValue["CertificateService"] = { |
| 63 | {"@odata.id", "/redfish/v1/CertificateService"}}; |
| 64 | asyncResp->res.jsonValue["Tasks"] = { |
| 65 | {"@odata.id", "/redfish/v1/TaskService"}}; |
| 66 | asyncResp->res.jsonValue["EventService"] = { |
| 67 | {"@odata.id", "/redfish/v1/EventService"}}; |
| 68 | asyncResp->res.jsonValue["TelemetryService"] = { |
| 69 | {"@odata.id", "/redfish/v1/TelemetryService"}}; |
Shantappa Teekappanavar | 9c929be | 2021-12-16 19:02:52 -0600 | [diff] [blame] | 70 | asyncResp->res.jsonValue["Cables"] = {{"@odata.id", "/redfish/v1/Cables"}}; |
Nan Zhou | 9629907 | 2022-03-23 09:13:46 -0700 | [diff] [blame] | 71 | |
| 72 | nlohmann::json& protocolFeatures = |
| 73 | asyncResp->res.jsonValue["ProtocolFeaturesSupported"]; |
| 74 | protocolFeatures["ExcerptQuery"] = false; |
Ed Tanous | 7cf436c | 2022-03-22 23:53:51 -0700 | [diff] [blame] | 75 | |
| 76 | protocolFeatures["ExpandQuery"]["ExpandAll"] = |
| 77 | bmcwebInsecureEnableQueryParams; |
| 78 | // This is the maximum level defined in ServiceRoot.v1_13_0.json |
| 79 | if (bmcwebInsecureEnableQueryParams) |
| 80 | { |
| 81 | protocolFeatures["ExpandQuery"]["MaxLevels"] = 6; |
| 82 | } |
| 83 | protocolFeatures["ExpandQuery"]["Levels"] = bmcwebInsecureEnableQueryParams; |
| 84 | protocolFeatures["ExpandQuery"]["Links"] = bmcwebInsecureEnableQueryParams; |
| 85 | protocolFeatures["ExpandQuery"]["NoLinks"] = |
| 86 | bmcwebInsecureEnableQueryParams; |
Nan Zhou | 9629907 | 2022-03-23 09:13:46 -0700 | [diff] [blame] | 87 | protocolFeatures["FilterQuery"] = false; |
Ed Tanous | f4c99e7 | 2021-10-04 17:02:43 -0700 | [diff] [blame] | 88 | protocolFeatures["OnlyMemberQuery"] = bmcwebInsecureEnableQueryParams; |
Nan Zhou | 9629907 | 2022-03-23 09:13:46 -0700 | [diff] [blame] | 89 | protocolFeatures["SelectQuery"] = false; |
| 90 | protocolFeatures["DeepOperations"]["DeepPOST"] = false; |
| 91 | protocolFeatures["DeepOperations"]["DeepPATCH"] = false; |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 92 | } |
| 93 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 94 | inline void requestRoutesServiceRoot(App& app) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 95 | { |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 96 | BMCWEB_ROUTE(app, "/redfish/v1/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 97 | .privileges(redfish::privileges::getServiceRoot) |
Ed Tanous | 7cf436c | 2022-03-22 23:53:51 -0700 | [diff] [blame] | 98 | .methods(boost::beast::http::verb::get)( |
| 99 | [&app](const crow::Request& req, |
| 100 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { |
| 101 | if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) |
| 102 | { |
| 103 | return; |
| 104 | } |
| 105 | handleServiceRootGet(asyncResp); |
| 106 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 107 | } |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 108 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 109 | } // namespace redfish |