blob: 24ad79d308f1eb5ac707543c2eef701e25962d5a [file] [log] [blame]
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +01001/*
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
20namespace redfish {
21
Borawski.Lukasz43a095a2018-02-19 15:39:01 +010022static 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.Lukaszb6df6dc2018-01-24 10:20:45 +010030class ServiceRoot : public Node {
31 public:
Borawski.Lukasz43a095a2018-02-19 15:39:01 +010032 template <typename CrowApp>
33 ServiceRoot(CrowApp& app)
34 : Node(app, EntityPrivileges(std::move(serviceRootOpMap)),
35 "/redfish/v1/") {
Borawski.Lukaszaecb47a2018-01-25 12:14:14 +010036 nodeJson["@odata.type"] = "#ServiceRoot.v1_1_1.ServiceRoot";
37 nodeJson["@odata.id"] = "/redfish/v1";
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010038 nodeJson["@odata.context"] =
39 "/redfish/v1/$metadata#ServiceRoot.ServiceRoot";
40 nodeJson["Id"] = "RootService";
41 nodeJson["Name"] = "Root Service";
42 nodeJson["RedfishVersion"] = "1.1.0";
43 nodeJson["Links"]["Sessions"] = {
44 {"@odata.id", "/redfish/v1/SessionService/Sessions/"}};
45 nodeJson["UUID"] =
46 app.template get_middleware<crow::PersistentData::Middleware>()
47 .system_uuid;
48 getRedfishSubRoutes(app, "/redfish/v1/", nodeJson);
49 }
50
51 private:
52 void doGet(crow::response& res, const crow::request& req,
53 const std::vector<std::string>& params) override {
54 res.add_header("Content-Type", "application/json");
55 res.body = nodeJson.dump();
56 res.end();
57 }
58
59 nlohmann::json nodeJson;
60};
61
62} // namespace redfish