12474adfaSEd Tanous /* 22474adfaSEd Tanous // Copyright (c) 2018 Intel Corporation 32474adfaSEd Tanous // Copyright (c) 2018 Ampere Computing LLC 42474adfaSEd Tanous / 52474adfaSEd Tanous // Licensed under the Apache License, Version 2.0 (the "License"); 62474adfaSEd Tanous // you may not use this file except in compliance with the License. 72474adfaSEd Tanous // You may obtain a copy of the License at 82474adfaSEd Tanous // 92474adfaSEd Tanous // http://www.apache.org/licenses/LICENSE-2.0 102474adfaSEd Tanous // 112474adfaSEd Tanous // Unless required by applicable law or agreed to in writing, software 122474adfaSEd Tanous // distributed under the License is distributed on an "AS IS" BASIS, 132474adfaSEd Tanous // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 142474adfaSEd Tanous // See the License for the specific language governing permissions and 152474adfaSEd Tanous // limitations under the License. 162474adfaSEd Tanous */ 172474adfaSEd Tanous #pragma once 182474adfaSEd Tanous 192474adfaSEd Tanous #include "node.hpp" 202474adfaSEd Tanous #include "sensors.hpp" 212474adfaSEd Tanous 222474adfaSEd Tanous namespace redfish 232474adfaSEd Tanous { 242474adfaSEd Tanous 252474adfaSEd Tanous class Power : public Node 262474adfaSEd Tanous { 272474adfaSEd Tanous public: 282474adfaSEd Tanous Power(CrowApp& app) : 292474adfaSEd Tanous Node((app), "/redfish/v1/Chassis/<str>/Power/", std::string()) 302474adfaSEd Tanous { 312474adfaSEd Tanous entityPrivileges = { 322474adfaSEd Tanous {boost::beast::http::verb::get, {{"Login"}}}, 332474adfaSEd Tanous {boost::beast::http::verb::head, {{"Login"}}}, 34*6f4fd479SRichard Marian Thomaiyar {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, 352474adfaSEd Tanous {boost::beast::http::verb::put, {{"ConfigureManager"}}}, 362474adfaSEd Tanous {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, 372474adfaSEd Tanous {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; 382474adfaSEd Tanous } 392474adfaSEd Tanous 402474adfaSEd Tanous private: 41413961deSRichard Marian Thomaiyar std::initializer_list<const char*> typeList = { 42413961deSRichard Marian Thomaiyar "/xyz/openbmc_project/sensors/voltage", 43413961deSRichard Marian Thomaiyar "/xyz/openbmc_project/sensors/power"}; 442474adfaSEd Tanous void doGet(crow::Response& res, const crow::Request& req, 452474adfaSEd Tanous const std::vector<std::string>& params) override 462474adfaSEd Tanous { 472474adfaSEd Tanous if (params.size() != 1) 482474adfaSEd Tanous { 492474adfaSEd Tanous res.result(boost::beast::http::status::internal_server_error); 502474adfaSEd Tanous res.end(); 512474adfaSEd Tanous return; 522474adfaSEd Tanous } 532474adfaSEd Tanous const std::string& chassis_name = params[0]; 542474adfaSEd Tanous 550f74e643SEd Tanous res.jsonValue["@odata.id"] = 562474adfaSEd Tanous "/redfish/v1/Chassis/" + chassis_name + "/Power"; 570f74e643SEd Tanous res.jsonValue["@odata.type"] = "#Power.v1_2_1.Power"; 580f74e643SEd Tanous res.jsonValue["@odata.context"] = "/redfish/v1/$metadata#Power.Power"; 590f74e643SEd Tanous res.jsonValue["Id"] = "Power"; 600f74e643SEd Tanous res.jsonValue["Name"] = "Power"; 612474adfaSEd Tanous auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>( 62413961deSRichard Marian Thomaiyar res, chassis_name, typeList, "Power"); 632474adfaSEd Tanous // TODO Need to retrieve Power Control information. 642474adfaSEd Tanous getChassisData(sensorAsyncResp); 652474adfaSEd Tanous } 66413961deSRichard Marian Thomaiyar void doPatch(crow::Response& res, const crow::Request& req, 67413961deSRichard Marian Thomaiyar const std::vector<std::string>& params) override 68413961deSRichard Marian Thomaiyar { 69413961deSRichard Marian Thomaiyar setSensorOverride(res, req, params, typeList, "Power"); 70413961deSRichard Marian Thomaiyar } 712474adfaSEd Tanous }; 722474adfaSEd Tanous 732474adfaSEd Tanous } // namespace redfish 74