Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 1 | /* |
| 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 | #include "sensors.hpp" |
| 20 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 21 | namespace redfish |
| 22 | { |
Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 23 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 24 | class Thermal : public Node |
| 25 | { |
| 26 | public: |
| 27 | Thermal(CrowApp& app) : |
| 28 | Node((app), "/redfish/v1/Chassis/<str>/Thermal/", std::string()) |
| 29 | { |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 30 | entityPrivileges = { |
| 31 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 32 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 33 | {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, |
| 34 | {boost::beast::http::verb::put, {{"ConfigureManager"}}}, |
| 35 | {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, |
| 36 | {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; |
Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 37 | } |
Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 38 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 39 | private: |
Richard Marian Thomaiyar | 413961d | 2019-02-01 00:43:39 +0530 | [diff] [blame] | 40 | std::initializer_list<const char*> typeList = { |
| 41 | "/xyz/openbmc_project/sensors/fan", |
| 42 | "/xyz/openbmc_project/sensors/temperature", |
| 43 | "/xyz/openbmc_project/sensors/fan_pwm"}; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 44 | void doGet(crow::Response& res, const crow::Request& req, |
| 45 | const std::vector<std::string>& params) override |
| 46 | { |
| 47 | if (params.size() != 1) |
| 48 | { |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 49 | messages::internalError(res); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 50 | res.end(); |
| 51 | return; |
| 52 | } |
| 53 | const std::string& chassisName = params[0]; |
| 54 | |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 55 | res.jsonValue["@odata.type"] = "#Thermal.v1_4_0.Thermal"; |
| 56 | res.jsonValue["@odata.context"] = |
| 57 | "/redfish/v1/$metadata#Thermal.Thermal"; |
| 58 | res.jsonValue["Id"] = "Thermal"; |
| 59 | res.jsonValue["Name"] = "Thermal"; |
Ed Tanous | 2474adf | 2018-09-05 16:31:16 -0700 | [diff] [blame] | 60 | |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 61 | res.jsonValue["@odata.id"] = |
Ed Tanous | 2474adf | 2018-09-05 16:31:16 -0700 | [diff] [blame] | 62 | "/redfish/v1/Chassis/" + chassisName + "/Thermal"; |
| 63 | |
Ed Tanous | 2474adf | 2018-09-05 16:31:16 -0700 | [diff] [blame] | 64 | auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>( |
Richard Marian Thomaiyar | 413961d | 2019-02-01 00:43:39 +0530 | [diff] [blame] | 65 | res, chassisName, typeList, "Thermal"); |
Ed Tanous | 2474adf | 2018-09-05 16:31:16 -0700 | [diff] [blame] | 66 | |
| 67 | // TODO Need to get Chassis Redundancy information. |
| 68 | getChassisData(sensorAsyncResp); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 69 | } |
Richard Marian Thomaiyar | 413961d | 2019-02-01 00:43:39 +0530 | [diff] [blame] | 70 | void doPatch(crow::Response& res, const crow::Request& req, |
| 71 | const std::vector<std::string>& params) override |
| 72 | { |
| 73 | setSensorOverride(res, req, params, typeList, "Thermal"); |
| 74 | } |
Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 75 | }; |
| 76 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 77 | } // namespace redfish |