blob: 696d6fd025d3370fcde98cf9f22b4087518d031c [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
Ed Tanousf4c99e72021-10-04 17:02:43 -070018#include <bmcweb_config.h>
19
John Edward Broadbent7e860f12021-04-08 15:57:16 -070020#include <app.hpp>
Nan Zhou96299072022-03-23 09:13:46 -070021#include <async_resp.hpp>
22#include <http_request.hpp>
23#include <nlohmann/json.hpp>
John Edward Broadbent83388912021-06-29 10:46:46 -070024#include <persistent_data.hpp>
Ed Tanoused398212021-06-09 17:05:54 -070025#include <registries/privilege_registry.hpp>
Bernard Wong7bffdb72019-03-20 16:17:21 +080026#include <utils/systemd_utils.hpp>
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010027
Ed Tanous1abe55e2018-09-05 08:30:59 -070028namespace redfish
29{
Ed Tanous3ebd75f2018-03-05 18:20:01 -080030
John Edward Broadbent83388912021-06-29 10:46:46 -070031inline void
Ed Tanous104f09c2022-01-25 09:56:04 -080032 handleServiceRootGet(const crow::Request& /*req*/,
John Edward Broadbent83388912021-06-29 10:46:46 -070033 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
34{
35
36 std::string uuid = persistent_data::getConfig().systemUuid;
Shantappa Teekappanavar9c929be2021-12-16 19:02:52 -060037 asyncResp->res.jsonValue["@odata.type"] =
38 "#ServiceRoot.v1_11_0.ServiceRoot";
John Edward Broadbent83388912021-06-29 10:46:46 -070039 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1";
40 asyncResp->res.jsonValue["Id"] = "RootService";
41 asyncResp->res.jsonValue["Name"] = "Root Service";
42 asyncResp->res.jsonValue["RedfishVersion"] = "1.9.0";
43 asyncResp->res.jsonValue["Links"]["Sessions"] = {
44 {"@odata.id", "/redfish/v1/SessionService/Sessions"}};
45 asyncResp->res.jsonValue["AccountService"] = {
46 {"@odata.id", "/redfish/v1/AccountService"}};
47 asyncResp->res.jsonValue["Chassis"] = {
48 {"@odata.id", "/redfish/v1/Chassis"}};
49 asyncResp->res.jsonValue["JsonSchemas"] = {
50 {"@odata.id", "/redfish/v1/JsonSchemas"}};
51 asyncResp->res.jsonValue["Managers"] = {
52 {"@odata.id", "/redfish/v1/Managers"}};
53 asyncResp->res.jsonValue["SessionService"] = {
54 {"@odata.id", "/redfish/v1/SessionService"}};
55 asyncResp->res.jsonValue["Systems"] = {
56 {"@odata.id", "/redfish/v1/Systems"}};
57 asyncResp->res.jsonValue["Registries"] = {
58 {"@odata.id", "/redfish/v1/Registries"}};
59
60 asyncResp->res.jsonValue["UpdateService"] = {
61 {"@odata.id", "/redfish/v1/UpdateService"}};
62 asyncResp->res.jsonValue["UUID"] = uuid;
63 asyncResp->res.jsonValue["CertificateService"] = {
64 {"@odata.id", "/redfish/v1/CertificateService"}};
65 asyncResp->res.jsonValue["Tasks"] = {
66 {"@odata.id", "/redfish/v1/TaskService"}};
67 asyncResp->res.jsonValue["EventService"] = {
68 {"@odata.id", "/redfish/v1/EventService"}};
69 asyncResp->res.jsonValue["TelemetryService"] = {
70 {"@odata.id", "/redfish/v1/TelemetryService"}};
Shantappa Teekappanavar9c929be2021-12-16 19:02:52 -060071 asyncResp->res.jsonValue["Cables"] = {{"@odata.id", "/redfish/v1/Cables"}};
Nan Zhou96299072022-03-23 09:13:46 -070072
73 nlohmann::json& protocolFeatures =
74 asyncResp->res.jsonValue["ProtocolFeaturesSupported"];
75 protocolFeatures["ExcerptQuery"] = false;
76 protocolFeatures["ExpandQuery"]["ExpandAll"] = false;
77 protocolFeatures["ExpandQuery"]["Levels"] = false;
78 protocolFeatures["ExpandQuery"]["Links"] = false;
79 protocolFeatures["ExpandQuery"]["NoLinks"] = false;
80 protocolFeatures["FilterQuery"] = false;
Ed Tanousf4c99e72021-10-04 17:02:43 -070081 protocolFeatures["OnlyMemberQuery"] = bmcwebInsecureEnableQueryParams;
Nan Zhou96299072022-03-23 09:13:46 -070082 protocolFeatures["SelectQuery"] = false;
83 protocolFeatures["DeepOperations"]["DeepPOST"] = false;
84 protocolFeatures["DeepOperations"]["DeepPATCH"] = false;
John Edward Broadbent83388912021-06-29 10:46:46 -070085}
86
John Edward Broadbent7e860f12021-04-08 15:57:16 -070087inline void requestRoutesServiceRoot(App& app)
Ed Tanous1abe55e2018-09-05 08:30:59 -070088{
John Edward Broadbent7e860f12021-04-08 15:57:16 -070089 BMCWEB_ROUTE(app, "/redfish/v1/")
Ed Tanoused398212021-06-09 17:05:54 -070090 .privileges(redfish::privileges::getServiceRoot)
John Edward Broadbent83388912021-06-29 10:46:46 -070091 .methods(boost::beast::http::verb::get)(handleServiceRootGet);
John Edward Broadbent7e860f12021-04-08 15:57:16 -070092}
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010093
Ed Tanous1abe55e2018-09-05 08:30:59 -070094} // namespace redfish