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 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 18 | #include <app.hpp> |
Nan Zhou | 9629907 | 2022-03-23 09:13:46 -0700 | [diff] [blame] | 19 | #include <async_resp.hpp> |
| 20 | #include <http_request.hpp> |
| 21 | #include <nlohmann/json.hpp> |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 22 | #include <persistent_data.hpp> |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 23 | #include <registries/privilege_registry.hpp> |
Bernard Wong | 7bffdb7 | 2019-03-20 16:17:21 +0800 | [diff] [blame] | 24 | #include <utils/systemd_utils.hpp> |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 25 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 26 | namespace redfish |
| 27 | { |
Ed Tanous | 3ebd75f | 2018-03-05 18:20:01 -0800 | [diff] [blame] | 28 | |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 29 | inline void |
Ed Tanous | 104f09c | 2022-01-25 09:56:04 -0800 | [diff] [blame] | 30 | handleServiceRootGet(const crow::Request& /*req*/, |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 31 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
| 32 | { |
| 33 | |
| 34 | std::string uuid = persistent_data::getConfig().systemUuid; |
Shantappa Teekappanavar | 9c929be | 2021-12-16 19:02:52 -0600 | [diff] [blame] | 35 | asyncResp->res.jsonValue["@odata.type"] = |
| 36 | "#ServiceRoot.v1_11_0.ServiceRoot"; |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 37 | asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1"; |
| 38 | asyncResp->res.jsonValue["Id"] = "RootService"; |
| 39 | asyncResp->res.jsonValue["Name"] = "Root Service"; |
| 40 | asyncResp->res.jsonValue["RedfishVersion"] = "1.9.0"; |
| 41 | asyncResp->res.jsonValue["Links"]["Sessions"] = { |
| 42 | {"@odata.id", "/redfish/v1/SessionService/Sessions"}}; |
| 43 | asyncResp->res.jsonValue["AccountService"] = { |
| 44 | {"@odata.id", "/redfish/v1/AccountService"}}; |
| 45 | asyncResp->res.jsonValue["Chassis"] = { |
| 46 | {"@odata.id", "/redfish/v1/Chassis"}}; |
| 47 | asyncResp->res.jsonValue["JsonSchemas"] = { |
| 48 | {"@odata.id", "/redfish/v1/JsonSchemas"}}; |
| 49 | asyncResp->res.jsonValue["Managers"] = { |
| 50 | {"@odata.id", "/redfish/v1/Managers"}}; |
| 51 | asyncResp->res.jsonValue["SessionService"] = { |
| 52 | {"@odata.id", "/redfish/v1/SessionService"}}; |
| 53 | asyncResp->res.jsonValue["Systems"] = { |
| 54 | {"@odata.id", "/redfish/v1/Systems"}}; |
| 55 | asyncResp->res.jsonValue["Registries"] = { |
| 56 | {"@odata.id", "/redfish/v1/Registries"}}; |
| 57 | |
| 58 | asyncResp->res.jsonValue["UpdateService"] = { |
| 59 | {"@odata.id", "/redfish/v1/UpdateService"}}; |
| 60 | asyncResp->res.jsonValue["UUID"] = uuid; |
| 61 | asyncResp->res.jsonValue["CertificateService"] = { |
| 62 | {"@odata.id", "/redfish/v1/CertificateService"}}; |
| 63 | asyncResp->res.jsonValue["Tasks"] = { |
| 64 | {"@odata.id", "/redfish/v1/TaskService"}}; |
| 65 | asyncResp->res.jsonValue["EventService"] = { |
| 66 | {"@odata.id", "/redfish/v1/EventService"}}; |
| 67 | asyncResp->res.jsonValue["TelemetryService"] = { |
| 68 | {"@odata.id", "/redfish/v1/TelemetryService"}}; |
Shantappa Teekappanavar | 9c929be | 2021-12-16 19:02:52 -0600 | [diff] [blame] | 69 | asyncResp->res.jsonValue["Cables"] = {{"@odata.id", "/redfish/v1/Cables"}}; |
Nan Zhou | 9629907 | 2022-03-23 09:13:46 -0700 | [diff] [blame] | 70 | |
| 71 | nlohmann::json& protocolFeatures = |
| 72 | asyncResp->res.jsonValue["ProtocolFeaturesSupported"]; |
| 73 | protocolFeatures["ExcerptQuery"] = false; |
| 74 | protocolFeatures["ExpandQuery"]["ExpandAll"] = false; |
| 75 | protocolFeatures["ExpandQuery"]["Levels"] = false; |
| 76 | protocolFeatures["ExpandQuery"]["Links"] = false; |
| 77 | protocolFeatures["ExpandQuery"]["NoLinks"] = false; |
| 78 | protocolFeatures["FilterQuery"] = false; |
| 79 | protocolFeatures["OnlyMemberQuery"] = false; |
| 80 | protocolFeatures["SelectQuery"] = false; |
| 81 | protocolFeatures["DeepOperations"]["DeepPOST"] = false; |
| 82 | protocolFeatures["DeepOperations"]["DeepPATCH"] = false; |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 83 | } |
| 84 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 85 | inline void requestRoutesServiceRoot(App& app) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 86 | { |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 87 | BMCWEB_ROUTE(app, "/redfish/v1/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 88 | .privileges(redfish::privileges::getServiceRoot) |
John Edward Broadbent | 8338891 | 2021-06-29 10:46:46 -0700 | [diff] [blame] | 89 | .methods(boost::beast::http::verb::get)(handleServiceRootGet); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 90 | } |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 91 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 92 | } // namespace redfish |