blob: 129d58d85dc296054921e548b39ce689b61fcd13 [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 ServiceRoot(CrowApp& app)
33 : Node(app, EntityPrivileges(std::move(serviceRootOpMap)),
34 "/redfish/v1/") {
Borawski.Lukaszc1a46bd2018-02-08 13:31:59 +010035 Node::json["@odata.type"] = "#ServiceRoot.v1_1_1.ServiceRoot";
36 Node::json["@odata.id"] = "/redfish/v1/";
37 Node::json["@odata.context"] =
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010038 "/redfish/v1/$metadata#ServiceRoot.ServiceRoot";
Borawski.Lukaszc1a46bd2018-02-08 13:31:59 +010039 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.Lukaszb6df6dc2018-01-24 10:20:45 +010045 app.template get_middleware<crow::PersistentData::Middleware>()
46 .system_uuid;
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010047 }
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.Lukaszc1a46bd2018-02-08 13:31:59 +010053 res.json_value = Node::json;
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010054 res.end();
55 }
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010056};
57
58} // namespace redfish