blob: 3b9adbf37c00f5bd3341f943e0a0b6c83604134c [file] [log] [blame]
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +01001/*
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
Bernard Wong7bffdb72019-03-20 16:17:21 +080020#include <utils/systemd_utils.hpp>
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010021
Ed Tanous1abe55e2018-09-05 08:30:59 -070022namespace redfish
23{
Ed Tanous3ebd75f2018-03-05 18:20:01 -080024
Ed Tanous1abe55e2018-09-05 08:30:59 -070025class ServiceRoot : public Node
26{
27 public:
28 ServiceRoot(CrowApp& app) : Node(app, "/redfish/v1/")
29 {
Ed Tanous3602e232019-05-13 11:11:44 -070030 uuid = app.template getMiddleware<crow::persistent_data::Middleware>()
31 .systemUuid;
Ed Tanous1abe55e2018-09-05 08:30:59 -070032 entityPrivileges = {
33 {boost::beast::http::verb::get, {}},
34 {boost::beast::http::verb::head, {}},
35 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
36 {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
37 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
38 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
Ed Tanouse0625902018-05-16 13:35:08 -070039 }
Ed Tanous1abe55e2018-09-05 08:30:59 -070040
41 private:
42 void doGet(crow::Response& res, const crow::Request& req,
43 const std::vector<std::string>& params) override
44 {
Marri Devender Rao5968cae2019-01-21 10:27:12 -060045 res.jsonValue["@odata.type"] = "#ServiceRoot.v1_5_0.ServiceRoot";
Ed Tanousceac6f72018-12-02 11:58:47 -080046 res.jsonValue["@odata.id"] = "/redfish/v1";
Ed Tanous0f74e642018-11-12 15:17:05 -080047 res.jsonValue["@odata.context"] =
48 "/redfish/v1/$metadata#ServiceRoot.ServiceRoot";
49 res.jsonValue["Id"] = "RootService";
50 res.jsonValue["Name"] = "Root Service";
Ed Tanous029573d2019-02-01 10:57:49 -080051 res.jsonValue["RedfishVersion"] = "1.6.1";
Ed Tanous0f74e642018-11-12 15:17:05 -080052 res.jsonValue["Links"]["Sessions"] = {
53 {"@odata.id", "/redfish/v1/SessionService/Sessions"}};
54 res.jsonValue["AccountService"] = {
55 {"@odata.id", "/redfish/v1/AccountService"}};
56 res.jsonValue["Chassis"] = {{"@odata.id", "/redfish/v1/Chassis"}};
57 res.jsonValue["JsonSchemas"] = {
58 {"@odata.id", "/redfish/v1/JsonSchemas"}};
Ed Tanousaa7cb212018-11-29 13:47:36 -080059 res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}};
Ed Tanous0f74e642018-11-12 15:17:05 -080060 res.jsonValue["SessionService"] = {
Gunnar Mills8d3cae62018-12-13 16:22:42 -060061 {"@odata.id", "/redfish/v1/SessionService"}};
Ed Tanousceac6f72018-12-02 11:58:47 -080062 res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}};
Ed Tanous0f74e642018-11-12 15:17:05 -080063 res.jsonValue["Systems"] = {{"@odata.id", "/redfish/v1/Systems"}};
64 res.jsonValue["Registries"] = {{"@odata.id", "/redfish/v1/Registries"}};
65
66 res.jsonValue["UpdateService"] = {
67 {"@odata.id", "/redfish/v1/UpdateService"}};
Ed Tanous3602e232019-05-13 11:11:44 -070068 res.jsonValue["UUID"] = uuid;
Marri Devender Rao5968cae2019-01-21 10:27:12 -060069 res.jsonValue["CertificateService"] = {
70 {"@odata.id", "/redfish/v1/CertificateService"}};
Ed Tanous1abe55e2018-09-05 08:30:59 -070071 res.end();
72 }
Ed Tanous3602e232019-05-13 11:11:44 -070073
74 std::string uuid;
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010075};
76
Ed Tanous1abe55e2018-09-05 08:30:59 -070077} // namespace redfish