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:
24   ServiceRoot(CrowApp& app) : Node(app, "/redfish/v1/") {
25     Node::json["@odata.type"] = "#ServiceRoot.v1_1_1.ServiceRoot";
26     Node::json["@odata.id"] = "/redfish/v1/";
27     Node::json["@odata.context"] =
28         "/redfish/v1/$metadata#ServiceRoot.ServiceRoot";
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"] =
35         app.template get_middleware<crow::PersistentData::Middleware>()
36             .system_uuid;
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"}}}};
44   }
45 
46  private:
47   void doGet(crow::response& res, const crow::request& req,
48              const std::vector<std::string>& params) override {
49     res.json_value = Node::json;
50     res.end();
51   }
52 };
53 
54 }  // namespace redfish
55