xref: /openbmc/bmcweb/features/redfish/lib/thermal.hpp (revision 0f74e643ec246c333ef4724af1ecd5adeb1b6658)
108777fb0SLewanczyk, Dawid /*
208777fb0SLewanczyk, Dawid // Copyright (c) 2018 Intel Corporation
308777fb0SLewanczyk, Dawid //
408777fb0SLewanczyk, Dawid // Licensed under the Apache License, Version 2.0 (the "License");
508777fb0SLewanczyk, Dawid // you may not use this file except in compliance with the License.
608777fb0SLewanczyk, Dawid // You may obtain a copy of the License at
708777fb0SLewanczyk, Dawid //
808777fb0SLewanczyk, Dawid //      http://www.apache.org/licenses/LICENSE-2.0
908777fb0SLewanczyk, Dawid //
1008777fb0SLewanczyk, Dawid // Unless required by applicable law or agreed to in writing, software
1108777fb0SLewanczyk, Dawid // distributed under the License is distributed on an "AS IS" BASIS,
1208777fb0SLewanczyk, Dawid // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1308777fb0SLewanczyk, Dawid // See the License for the specific language governing permissions and
1408777fb0SLewanczyk, Dawid // limitations under the License.
1508777fb0SLewanczyk, Dawid */
1608777fb0SLewanczyk, Dawid #pragma once
1708777fb0SLewanczyk, Dawid 
1808777fb0SLewanczyk, Dawid #include "node.hpp"
1908777fb0SLewanczyk, Dawid #include "sensors.hpp"
2008777fb0SLewanczyk, Dawid 
211abe55efSEd Tanous namespace redfish
221abe55efSEd Tanous {
2308777fb0SLewanczyk, Dawid 
241abe55efSEd Tanous class Thermal : public Node
251abe55efSEd Tanous {
2608777fb0SLewanczyk, Dawid   public:
271abe55efSEd Tanous     Thermal(CrowApp& app) :
281abe55efSEd Tanous         Node((app), "/redfish/v1/Chassis/<str>/Thermal/", std::string())
291abe55efSEd Tanous     {
30e0d918bcSEd Tanous         entityPrivileges = {
31e0d918bcSEd Tanous             {boost::beast::http::verb::get, {{"Login"}}},
32e0d918bcSEd Tanous             {boost::beast::http::verb::head, {{"Login"}}},
33e0d918bcSEd Tanous             {boost::beast::http::verb::patch, {{"ConfigureManager"}}},
34e0d918bcSEd Tanous             {boost::beast::http::verb::put, {{"ConfigureManager"}}},
35e0d918bcSEd Tanous             {boost::beast::http::verb::delete_, {{"ConfigureManager"}}},
36e0d918bcSEd Tanous             {boost::beast::http::verb::post, {{"ConfigureManager"}}}};
3708777fb0SLewanczyk, Dawid     }
3808777fb0SLewanczyk, Dawid 
3908777fb0SLewanczyk, Dawid   private:
4055c7b7a2SEd Tanous     void doGet(crow::Response& res, const crow::Request& req,
411abe55efSEd Tanous                const std::vector<std::string>& params) override
421abe55efSEd Tanous     {
431abe55efSEd Tanous         if (params.size() != 1)
441abe55efSEd Tanous         {
45f12894f8SJason M. Bills             messages::internalError(res);
4608777fb0SLewanczyk, Dawid             res.end();
4708777fb0SLewanczyk, Dawid             return;
4808777fb0SLewanczyk, Dawid         }
4955c7b7a2SEd Tanous         const std::string& chassisName = params[0];
5008777fb0SLewanczyk, Dawid 
51*0f74e643SEd Tanous         res.jsonValue["@odata.type"] = "#Thermal.v1_4_0.Thermal";
52*0f74e643SEd Tanous         res.jsonValue["@odata.context"] =
53*0f74e643SEd Tanous             "/redfish/v1/$metadata#Thermal.Thermal";
54*0f74e643SEd Tanous         res.jsonValue["Id"] = "Thermal";
55*0f74e643SEd Tanous         res.jsonValue["Name"] = "Thermal";
562474adfaSEd Tanous 
57*0f74e643SEd Tanous         res.jsonValue["@odata.id"] =
582474adfaSEd Tanous             "/redfish/v1/Chassis/" + chassisName + "/Thermal";
592474adfaSEd Tanous 
602474adfaSEd Tanous         auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
6155c7b7a2SEd Tanous             res, chassisName,
6208777fb0SLewanczyk, Dawid             std::initializer_list<const char*>{
6303b5bae3SJames Feist                 "/xyz/openbmc_project/sensors/fan",
646f6d0d32SEd Tanous                 "/xyz/openbmc_project/sensors/temperature",
652474adfaSEd Tanous                 "/xyz/openbmc_project/sensors/fan_pwm"},
662474adfaSEd Tanous             "Thermal");
672474adfaSEd Tanous 
682474adfaSEd Tanous         // TODO Need to get Chassis Redundancy information.
692474adfaSEd Tanous         getChassisData(sensorAsyncResp);
7008777fb0SLewanczyk, Dawid     }
7108777fb0SLewanczyk, Dawid };
7208777fb0SLewanczyk, Dawid 
7308777fb0SLewanczyk, Dawid } // namespace redfish
74