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 | |
| 20 | namespace redfish { |
| 21 | |
| 22 | class ServiceRoot : public Node { |
| 23 | public: |
Ed Tanous | 3ebd75f | 2018-03-05 18:20:01 -0800 | [diff] [blame^] | 24 | ServiceRoot(CrowApp& app) : Node(app, "/redfish/v1/") { |
Borawski.Lukasz | c1a46bd | 2018-02-08 13:31:59 +0100 | [diff] [blame] | 25 | Node::json["@odata.type"] = "#ServiceRoot.v1_1_1.ServiceRoot"; |
| 26 | Node::json["@odata.id"] = "/redfish/v1/"; |
| 27 | Node::json["@odata.context"] = |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 28 | "/redfish/v1/$metadata#ServiceRoot.ServiceRoot"; |
Borawski.Lukasz | c1a46bd | 2018-02-08 13:31:59 +0100 | [diff] [blame] | 29 | Node::json["Id"] = "RootService"; |
| 30 | Node::json["Name"] = "Root Service"; |
| 31 | Node::json["RedfishVersion"] = "1.1.0"; |
| 32 | Node::json["Links"]["Sessions"] = { |
| 33 | {"@odata.id", "/redfish/v1/SessionService/Sessions"}}; |
| 34 | Node::json["UUID"] = |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 35 | app.template get_middleware<crow::PersistentData::Middleware>() |
| 36 | .system_uuid; |
Ed Tanous | 3ebd75f | 2018-03-05 18:20:01 -0800 | [diff] [blame^] | 37 | |
| 38 | entityPrivileges = {{crow::HTTPMethod::GET, {}}, |
| 39 | {crow::HTTPMethod::HEAD, {}}, |
| 40 | {crow::HTTPMethod::PATCH, {{"ConfigureComponents"}}}, |
| 41 | {crow::HTTPMethod::PUT, {{"ConfigureComponents"}}}, |
| 42 | {crow::HTTPMethod::DELETE, {{"ConfigureComponents"}}}, |
| 43 | {crow::HTTPMethod::POST, {{"ConfigureComponents"}}}}; |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | private: |
| 47 | void doGet(crow::response& res, const crow::request& req, |
| 48 | const std::vector<std::string>& params) override { |
Borawski.Lukasz | c1a46bd | 2018-02-08 13:31:59 +0100 | [diff] [blame] | 49 | res.json_value = Node::json; |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 50 | res.end(); |
| 51 | } |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | } // namespace redfish |