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