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 | { |
| 30 | Node::json["@odata.type"] = "#Thermal.v1_4_0.Thermal"; |
| 31 | Node::json["@odata.context"] = "/redfish/v1/$metadata#Thermal.Thermal"; |
| 32 | Node::json["Id"] = "Thermal"; |
| 33 | Node::json["Name"] = "Thermal"; |
Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 34 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame^] | 35 | entityPrivileges = { |
| 36 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 37 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 38 | {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, |
| 39 | {boost::beast::http::verb::put, {{"ConfigureManager"}}}, |
| 40 | {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, |
| 41 | {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; |
Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 42 | } |
Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 43 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame^] | 44 | private: |
| 45 | void doGet(crow::Response& res, const crow::Request& req, |
| 46 | const std::vector<std::string>& params) override |
| 47 | { |
| 48 | if (params.size() != 1) |
| 49 | { |
| 50 | res.result(boost::beast::http::status::internal_server_error); |
| 51 | res.end(); |
| 52 | return; |
| 53 | } |
| 54 | const std::string& chassisName = params[0]; |
| 55 | |
| 56 | res.jsonValue = Node::json; |
| 57 | auto asyncResp = std::make_shared<SensorsAsyncResp>( |
| 58 | res, chassisName, |
| 59 | std::initializer_list<const char*>{ |
| 60 | "/xyz/openbmc_project/sensors/fan", |
| 61 | "/xyz/openbmc_project/sensors/temperature"}); |
| 62 | getChassisData(asyncResp); |
| 63 | } |
Lewanczyk, Dawid | 08777fb | 2018-03-22 23:33:49 +0100 | [diff] [blame] | 64 | }; |
| 65 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame^] | 66 | } // namespace redfish |