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