xref: /openbmc/bmcweb/features/redfish/lib/service_root.hpp (revision 7bffdb7e9da69ae5416cda8df826372c33716beb)
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 
20*7bffdb7eSBernard Wong #include <utils/systemd_utils.hpp>
21b6df6dc7SBorawski.Lukasz 
221abe55efSEd Tanous namespace redfish
231abe55efSEd Tanous {
241abe55efSEd Tanous 
251abe55efSEd Tanous class ServiceRoot : public Node
261abe55efSEd Tanous {
27b6df6dc7SBorawski.Lukasz   public:
281abe55efSEd Tanous     ServiceRoot(CrowApp& app) : Node(app, "/redfish/v1/")
291abe55efSEd Tanous     {
30e0625906SEd Tanous         entityPrivileges = {
31e0625906SEd Tanous             {boost::beast::http::verb::get, {}},
32e0d918bcSEd Tanous             {boost::beast::http::verb::head, {}},
33e0d918bcSEd Tanous             {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
34e0d918bcSEd Tanous             {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
35e0d918bcSEd Tanous             {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
36e0d918bcSEd Tanous             {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
37b6df6dc7SBorawski.Lukasz     }
38b6df6dc7SBorawski.Lukasz 
39b6df6dc7SBorawski.Lukasz   private:
4055c7b7a2SEd Tanous     void doGet(crow::Response& res, const crow::Request& req,
411abe55efSEd Tanous                const std::vector<std::string>& params) override
421abe55efSEd Tanous     {
430f74e643SEd Tanous         res.jsonValue["@odata.type"] = "#ServiceRoot.v1_1_1.ServiceRoot";
44ceac6f75SEd Tanous         res.jsonValue["@odata.id"] = "/redfish/v1";
450f74e643SEd Tanous         res.jsonValue["@odata.context"] =
460f74e643SEd Tanous             "/redfish/v1/$metadata#ServiceRoot.ServiceRoot";
470f74e643SEd Tanous         res.jsonValue["Id"] = "RootService";
480f74e643SEd Tanous         res.jsonValue["Name"] = "Root Service";
49029573d4SEd Tanous         res.jsonValue["RedfishVersion"] = "1.6.1";
500f74e643SEd Tanous         res.jsonValue["Links"]["Sessions"] = {
510f74e643SEd Tanous             {"@odata.id", "/redfish/v1/SessionService/Sessions"}};
520f74e643SEd Tanous         res.jsonValue["AccountService"] = {
530f74e643SEd Tanous             {"@odata.id", "/redfish/v1/AccountService"}};
540f74e643SEd Tanous         res.jsonValue["Chassis"] = {{"@odata.id", "/redfish/v1/Chassis"}};
550f74e643SEd Tanous         res.jsonValue["JsonSchemas"] = {
560f74e643SEd Tanous             {"@odata.id", "/redfish/v1/JsonSchemas"}};
57aa7cb211SEd Tanous         res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}};
580f74e643SEd Tanous         res.jsonValue["SessionService"] = {
598d3cae6bSGunnar Mills             {"@odata.id", "/redfish/v1/SessionService"}};
60ceac6f75SEd Tanous         res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}};
610f74e643SEd Tanous         res.jsonValue["Systems"] = {{"@odata.id", "/redfish/v1/Systems"}};
620f74e643SEd Tanous         res.jsonValue["Registries"] = {{"@odata.id", "/redfish/v1/Registries"}};
630f74e643SEd Tanous 
640f74e643SEd Tanous         res.jsonValue["UpdateService"] = {
650f74e643SEd Tanous             {"@odata.id", "/redfish/v1/UpdateService"}};
660f74e643SEd Tanous 
67*7bffdb7eSBernard Wong         res.jsonValue["UUID"] = systemd_utils::getUuid();
68b6df6dc7SBorawski.Lukasz         res.end();
69b6df6dc7SBorawski.Lukasz     }
70b6df6dc7SBorawski.Lukasz };
71b6df6dc7SBorawski.Lukasz 
72b6df6dc7SBorawski.Lukasz } // namespace redfish
73