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 | |
| 18 | #include "node.hpp" |
| 19 | |
Bernard Wong | 7bffdb7 | 2019-03-20 16:17:21 +0800 | [diff] [blame] | 20 | #include <utils/systemd_utils.hpp> |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 21 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 22 | namespace redfish |
| 23 | { |
Ed Tanous | 3ebd75f | 2018-03-05 18:20:01 -0800 | [diff] [blame] | 24 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 25 | class ServiceRoot : public Node |
| 26 | { |
| 27 | public: |
| 28 | ServiceRoot(CrowApp& app) : Node(app, "/redfish/v1/") |
| 29 | { |
Ed Tanous | 3602e23 | 2019-05-13 11:11:44 -0700 | [diff] [blame] | 30 | uuid = app.template getMiddleware<crow::persistent_data::Middleware>() |
| 31 | .systemUuid; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 32 | entityPrivileges = { |
| 33 | {boost::beast::http::verb::get, {}}, |
| 34 | {boost::beast::http::verb::head, {}}, |
| 35 | {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, |
| 36 | {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, |
| 37 | {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, |
| 38 | {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; |
Ed Tanous | e062590 | 2018-05-16 13:35:08 -0700 | [diff] [blame] | 39 | } |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 40 | |
| 41 | private: |
| 42 | void doGet(crow::Response& res, const crow::Request& req, |
| 43 | const std::vector<std::string>& params) override |
| 44 | { |
Marri Devender Rao | 5968cae | 2019-01-21 10:27:12 -0600 | [diff] [blame] | 45 | res.jsonValue["@odata.type"] = "#ServiceRoot.v1_5_0.ServiceRoot"; |
Ed Tanous | ceac6f7 | 2018-12-02 11:58:47 -0800 | [diff] [blame] | 46 | res.jsonValue["@odata.id"] = "/redfish/v1"; |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 47 | res.jsonValue["Id"] = "RootService"; |
| 48 | res.jsonValue["Name"] = "Root Service"; |
Gunnar Mills | 5b816f2 | 2020-02-14 11:48:20 -0600 | [diff] [blame] | 49 | res.jsonValue["RedfishVersion"] = "1.9.0"; |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 50 | res.jsonValue["Links"]["Sessions"] = { |
| 51 | {"@odata.id", "/redfish/v1/SessionService/Sessions"}}; |
| 52 | res.jsonValue["AccountService"] = { |
| 53 | {"@odata.id", "/redfish/v1/AccountService"}}; |
| 54 | res.jsonValue["Chassis"] = {{"@odata.id", "/redfish/v1/Chassis"}}; |
| 55 | res.jsonValue["JsonSchemas"] = { |
| 56 | {"@odata.id", "/redfish/v1/JsonSchemas"}}; |
Ed Tanous | aa7cb21 | 2018-11-29 13:47:36 -0800 | [diff] [blame] | 57 | res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}}; |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 58 | res.jsonValue["SessionService"] = { |
Gunnar Mills | 8d3cae6 | 2018-12-13 16:22:42 -0600 | [diff] [blame] | 59 | {"@odata.id", "/redfish/v1/SessionService"}}; |
Ed Tanous | ceac6f7 | 2018-12-02 11:58:47 -0800 | [diff] [blame] | 60 | res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}}; |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 61 | res.jsonValue["Systems"] = {{"@odata.id", "/redfish/v1/Systems"}}; |
| 62 | res.jsonValue["Registries"] = {{"@odata.id", "/redfish/v1/Registries"}}; |
| 63 | |
| 64 | res.jsonValue["UpdateService"] = { |
| 65 | {"@odata.id", "/redfish/v1/UpdateService"}}; |
Ed Tanous | 3602e23 | 2019-05-13 11:11:44 -0700 | [diff] [blame] | 66 | res.jsonValue["UUID"] = uuid; |
Marri Devender Rao | 5968cae | 2019-01-21 10:27:12 -0600 | [diff] [blame] | 67 | res.jsonValue["CertificateService"] = { |
| 68 | {"@odata.id", "/redfish/v1/CertificateService"}}; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 69 | res.end(); |
| 70 | } |
Ed Tanous | 3602e23 | 2019-05-13 11:11:44 -0700 | [diff] [blame] | 71 | |
| 72 | std::string uuid; |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 73 | }; |
| 74 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 75 | } // namespace redfish |