xref: /openbmc/bmcweb/features/redfish/lib/service_root.hpp (revision b6df6dc7a1777e1063104012cf79f2aaa9dbe3f9)
1*b6df6dc7SBorawski.Lukasz /*
2*b6df6dc7SBorawski.Lukasz // Copyright (c) 2018 Intel Corporation
3*b6df6dc7SBorawski.Lukasz //
4*b6df6dc7SBorawski.Lukasz // Licensed under the Apache License, Version 2.0 (the "License");
5*b6df6dc7SBorawski.Lukasz // you may not use this file except in compliance with the License.
6*b6df6dc7SBorawski.Lukasz // You may obtain a copy of the License at
7*b6df6dc7SBorawski.Lukasz //
8*b6df6dc7SBorawski.Lukasz //      http://www.apache.org/licenses/LICENSE-2.0
9*b6df6dc7SBorawski.Lukasz //
10*b6df6dc7SBorawski.Lukasz // Unless required by applicable law or agreed to in writing, software
11*b6df6dc7SBorawski.Lukasz // distributed under the License is distributed on an "AS IS" BASIS,
12*b6df6dc7SBorawski.Lukasz // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*b6df6dc7SBorawski.Lukasz // See the License for the specific language governing permissions and
14*b6df6dc7SBorawski.Lukasz // limitations under the License.
15*b6df6dc7SBorawski.Lukasz */
16*b6df6dc7SBorawski.Lukasz #pragma once
17*b6df6dc7SBorawski.Lukasz 
18*b6df6dc7SBorawski.Lukasz #include "node.hpp"
19*b6df6dc7SBorawski.Lukasz 
20*b6df6dc7SBorawski.Lukasz namespace redfish {
21*b6df6dc7SBorawski.Lukasz 
22*b6df6dc7SBorawski.Lukasz class ServiceRoot : public Node {
23*b6df6dc7SBorawski.Lukasz  public:
24*b6df6dc7SBorawski.Lukasz   template <typename CrowApp, typename PrivilegeProvider>
25*b6df6dc7SBorawski.Lukasz   ServiceRoot(CrowApp& app, PrivilegeProvider& provider)
26*b6df6dc7SBorawski.Lukasz       : Node(app, provider, "#ServiceRoot.v1_1_1.ServiceRoot", "/redfish/v1/") {
27*b6df6dc7SBorawski.Lukasz     nodeJson["@odata.type"] = Node::odataType;
28*b6df6dc7SBorawski.Lukasz     nodeJson["@odata.id"] = Node::odataId;
29*b6df6dc7SBorawski.Lukasz     nodeJson["@odata.context"] =
30*b6df6dc7SBorawski.Lukasz         "/redfish/v1/$metadata#ServiceRoot.ServiceRoot";
31*b6df6dc7SBorawski.Lukasz     nodeJson["Id"] = "RootService";
32*b6df6dc7SBorawski.Lukasz     nodeJson["Name"] = "Root Service";
33*b6df6dc7SBorawski.Lukasz     nodeJson["RedfishVersion"] = "1.1.0";
34*b6df6dc7SBorawski.Lukasz     nodeJson["Links"]["Sessions"] = {
35*b6df6dc7SBorawski.Lukasz         {"@odata.id", "/redfish/v1/SessionService/Sessions/"}};
36*b6df6dc7SBorawski.Lukasz     nodeJson["UUID"] =
37*b6df6dc7SBorawski.Lukasz         app.template get_middleware<crow::PersistentData::Middleware>()
38*b6df6dc7SBorawski.Lukasz             .system_uuid;
39*b6df6dc7SBorawski.Lukasz     getRedfishSubRoutes(app, "/redfish/v1/", nodeJson);
40*b6df6dc7SBorawski.Lukasz   }
41*b6df6dc7SBorawski.Lukasz 
42*b6df6dc7SBorawski.Lukasz  private:
43*b6df6dc7SBorawski.Lukasz   void doGet(crow::response& res, const crow::request& req,
44*b6df6dc7SBorawski.Lukasz              const std::vector<std::string>& params) override {
45*b6df6dc7SBorawski.Lukasz     res.add_header("Content-Type", "application/json");
46*b6df6dc7SBorawski.Lukasz     res.body = nodeJson.dump();
47*b6df6dc7SBorawski.Lukasz     res.end();
48*b6df6dc7SBorawski.Lukasz   }
49*b6df6dc7SBorawski.Lukasz 
50*b6df6dc7SBorawski.Lukasz   nlohmann::json nodeJson;
51*b6df6dc7SBorawski.Lukasz };
52*b6df6dc7SBorawski.Lukasz 
53*b6df6dc7SBorawski.Lukasz }  // namespace redfish
54