1*2474adfaSEd Tanous /* 2*2474adfaSEd Tanous // Copyright (c) 2018 Intel Corporation 3*2474adfaSEd Tanous // Copyright (c) 2018 Ampere Computing LLC 4*2474adfaSEd Tanous / 5*2474adfaSEd Tanous // Licensed under the Apache License, Version 2.0 (the "License"); 6*2474adfaSEd Tanous // you may not use this file except in compliance with the License. 7*2474adfaSEd Tanous // You may obtain a copy of the License at 8*2474adfaSEd Tanous // 9*2474adfaSEd Tanous // http://www.apache.org/licenses/LICENSE-2.0 10*2474adfaSEd Tanous // 11*2474adfaSEd Tanous // Unless required by applicable law or agreed to in writing, software 12*2474adfaSEd Tanous // distributed under the License is distributed on an "AS IS" BASIS, 13*2474adfaSEd Tanous // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*2474adfaSEd Tanous // See the License for the specific language governing permissions and 15*2474adfaSEd Tanous // limitations under the License. 16*2474adfaSEd Tanous */ 17*2474adfaSEd Tanous #pragma once 18*2474adfaSEd Tanous 19*2474adfaSEd Tanous #include "node.hpp" 20*2474adfaSEd Tanous #include "sensors.hpp" 21*2474adfaSEd Tanous 22*2474adfaSEd Tanous namespace redfish 23*2474adfaSEd Tanous { 24*2474adfaSEd Tanous 25*2474adfaSEd Tanous class Power : public Node 26*2474adfaSEd Tanous { 27*2474adfaSEd Tanous public: 28*2474adfaSEd Tanous Power(CrowApp& app) : 29*2474adfaSEd Tanous Node((app), "/redfish/v1/Chassis/<str>/Power/", std::string()) 30*2474adfaSEd Tanous { 31*2474adfaSEd Tanous Node::json["@odata.type"] = "#Power.v1_2_1.Power"; 32*2474adfaSEd Tanous Node::json["@odata.context"] = "/redfish/v1/$metadata#Power.Power"; 33*2474adfaSEd Tanous Node::json["Id"] = "Power"; 34*2474adfaSEd Tanous Node::json["Name"] = "Power"; 35*2474adfaSEd Tanous 36*2474adfaSEd Tanous entityPrivileges = { 37*2474adfaSEd Tanous {boost::beast::http::verb::get, {{"Login"}}}, 38*2474adfaSEd Tanous {boost::beast::http::verb::head, {{"Login"}}}, 39*2474adfaSEd Tanous {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, 40*2474adfaSEd Tanous {boost::beast::http::verb::put, {{"ConfigureManager"}}}, 41*2474adfaSEd Tanous {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, 42*2474adfaSEd Tanous {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; 43*2474adfaSEd Tanous } 44*2474adfaSEd Tanous 45*2474adfaSEd Tanous private: 46*2474adfaSEd Tanous void doGet(crow::Response& res, const crow::Request& req, 47*2474adfaSEd Tanous const std::vector<std::string>& params) override 48*2474adfaSEd Tanous { 49*2474adfaSEd Tanous if (params.size() != 1) 50*2474adfaSEd Tanous { 51*2474adfaSEd Tanous res.result(boost::beast::http::status::internal_server_error); 52*2474adfaSEd Tanous res.end(); 53*2474adfaSEd Tanous return; 54*2474adfaSEd Tanous } 55*2474adfaSEd Tanous const std::string& chassis_name = params[0]; 56*2474adfaSEd Tanous 57*2474adfaSEd Tanous Node::json["@odata.id"] = 58*2474adfaSEd Tanous "/redfish/v1/Chassis/" + chassis_name + "/Power"; 59*2474adfaSEd Tanous res.jsonValue = Node::json; 60*2474adfaSEd Tanous auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>( 61*2474adfaSEd Tanous res, chassis_name, 62*2474adfaSEd Tanous std::initializer_list<const char*>{ 63*2474adfaSEd Tanous "/xyz/openbmc_project/sensors/voltage", 64*2474adfaSEd Tanous "/xyz/openbmc_project/sensors/power"}, 65*2474adfaSEd Tanous "Power"); 66*2474adfaSEd Tanous // TODO Need to retrieve Power Control information. 67*2474adfaSEd Tanous getChassisData(sensorAsyncResp); 68*2474adfaSEd Tanous } 69*2474adfaSEd Tanous }; 70*2474adfaSEd Tanous 71*2474adfaSEd Tanous } // namespace redfish 72