| 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 |  | 
 | 21 | namespace redfish { | 
 | 22 |  | 
 | 23 | class Thermal : public Node { | 
 | 24 |  public: | 
 | 25 |   Thermal(CrowApp& app) | 
 | 26 |       : Node((app), "/redfish/v1/Chassis/<str>/Thermal/", std::string()) { | 
| Lewanczyk, Dawid | 7885954 | 2018-06-11 16:58:40 +0200 | [diff] [blame] | 27 |     Node::json["@odata.type"] = "#Thermal.v1_4_0.Thermal"; | 
| Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 28 |     Node::json["@odata.context"] = "/redfish/v1/$metadata#Thermal.Thermal"; | 
 | 29 |     Node::json["Id"] = "Thermal"; | 
 | 30 |     Node::json["Name"] = "Thermal"; | 
 | 31 |  | 
| Ed Tanous | e0d918b | 2018-03-27 17:41:04 -0700 | [diff] [blame] | 32 |     entityPrivileges = { | 
 | 33 |         {boost::beast::http::verb::get, {{"Login"}}}, | 
 | 34 |         {boost::beast::http::verb::head, {{"Login"}}}, | 
 | 35 |         {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, | 
 | 36 |         {boost::beast::http::verb::put, {{"ConfigureManager"}}}, | 
 | 37 |         {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, | 
 | 38 |         {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; | 
| Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 39 |   } | 
 | 40 |  | 
 | 41 |  private: | 
| Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame^] | 42 |   void doGet(crow::Response& res, const crow::Request& req, | 
| Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 43 |              const std::vector<std::string>& params) override { | 
 | 44 |     if (params.size() != 1) { | 
| Ed Tanous | e0d918b | 2018-03-27 17:41:04 -0700 | [diff] [blame] | 45 |       res.result(boost::beast::http::status::internal_server_error); | 
| Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 46 |       res.end(); | 
 | 47 |       return; | 
 | 48 |     } | 
| Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame^] | 49 |     const std::string& chassisName = params[0]; | 
| Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 50 |  | 
| Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame^] | 51 |     res.jsonValue = Node::json; | 
| Kowalski, Kamil | 588c3f0 | 2018-04-03 14:55:27 +0200 | [diff] [blame] | 52 |     auto asyncResp = std::make_shared<SensorsAsyncResp>( | 
| Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame^] | 53 |         res, chassisName, | 
| Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 54 |         std::initializer_list<const char*>{ | 
| James Feist | 03b5bae | 2018-07-06 12:08:09 -0700 | [diff] [blame] | 55 |             "/xyz/openbmc_project/sensors/fan", | 
 | 56 |             "/xyz/openbmc_project/sensors/temperature"}); | 
| Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 57 |     getChassisData(asyncResp); | 
 | 58 |   } | 
 | 59 | }; | 
 | 60 |  | 
 | 61 | }  // namespace redfish |