xref: /openbmc/bmcweb/features/redfish/lib/service_root.hpp (revision 3602e232fda4a6ddac4dcf6d3a024bd5ff6e7835)
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 
207bffdb7eSBernard 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     {
30*3602e232SEd Tanous         uuid = app.template getMiddleware<crow::persistent_data::Middleware>()
31*3602e232SEd Tanous                    .systemUuid;
32e0625906SEd Tanous         entityPrivileges = {
33e0625906SEd Tanous             {boost::beast::http::verb::get, {}},
34e0d918bcSEd Tanous             {boost::beast::http::verb::head, {}},
35e0d918bcSEd Tanous             {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
36e0d918bcSEd Tanous             {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
37e0d918bcSEd Tanous             {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
38e0d918bcSEd Tanous             {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
39b6df6dc7SBorawski.Lukasz     }
40b6df6dc7SBorawski.Lukasz 
41b6df6dc7SBorawski.Lukasz   private:
4255c7b7a2SEd Tanous     void doGet(crow::Response& res, const crow::Request& req,
431abe55efSEd Tanous                const std::vector<std::string>& params) override
441abe55efSEd Tanous     {
450f74e643SEd Tanous         res.jsonValue["@odata.type"] = "#ServiceRoot.v1_1_1.ServiceRoot";
46ceac6f75SEd Tanous         res.jsonValue["@odata.id"] = "/redfish/v1";
470f74e643SEd Tanous         res.jsonValue["@odata.context"] =
480f74e643SEd Tanous             "/redfish/v1/$metadata#ServiceRoot.ServiceRoot";
490f74e643SEd Tanous         res.jsonValue["Id"] = "RootService";
500f74e643SEd Tanous         res.jsonValue["Name"] = "Root Service";
51029573d4SEd Tanous         res.jsonValue["RedfishVersion"] = "1.6.1";
520f74e643SEd Tanous         res.jsonValue["Links"]["Sessions"] = {
530f74e643SEd Tanous             {"@odata.id", "/redfish/v1/SessionService/Sessions"}};
540f74e643SEd Tanous         res.jsonValue["AccountService"] = {
550f74e643SEd Tanous             {"@odata.id", "/redfish/v1/AccountService"}};
560f74e643SEd Tanous         res.jsonValue["Chassis"] = {{"@odata.id", "/redfish/v1/Chassis"}};
570f74e643SEd Tanous         res.jsonValue["JsonSchemas"] = {
580f74e643SEd Tanous             {"@odata.id", "/redfish/v1/JsonSchemas"}};
59aa7cb211SEd Tanous         res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}};
600f74e643SEd Tanous         res.jsonValue["SessionService"] = {
618d3cae6bSGunnar Mills             {"@odata.id", "/redfish/v1/SessionService"}};
62ceac6f75SEd Tanous         res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}};
630f74e643SEd Tanous         res.jsonValue["Systems"] = {{"@odata.id", "/redfish/v1/Systems"}};
640f74e643SEd Tanous         res.jsonValue["Registries"] = {{"@odata.id", "/redfish/v1/Registries"}};
650f74e643SEd Tanous 
660f74e643SEd Tanous         res.jsonValue["UpdateService"] = {
670f74e643SEd Tanous             {"@odata.id", "/redfish/v1/UpdateService"}};
680f74e643SEd Tanous 
69*3602e232SEd Tanous         res.jsonValue["UUID"] = uuid;
70b6df6dc7SBorawski.Lukasz         res.end();
71b6df6dc7SBorawski.Lukasz     }
72*3602e232SEd Tanous 
73*3602e232SEd Tanous     std::string uuid;
74b6df6dc7SBorawski.Lukasz };
75b6df6dc7SBorawski.Lukasz 
76b6df6dc7SBorawski.Lukasz } // namespace redfish
77