From 8b2f4a6fe57bf2410cdb22f8c3c695e98d583040 Mon Sep 17 00:00:00 2001 From: "Wludzik, Jozef" Date: Mon, 18 May 2020 12:40:15 +0200 Subject: [PATCH 3/5] Add support for DELETE in MetricReportDefinitions/ Added support for DELETE action in MetricReportDefinitions/ node. It allows user to remove MetricReportDefinition together with MetricReport connected to it. Tested: - Succesfully passed RedfishServiceValidator.py - Validated DELETE action by removing exisiting MetricReportDefinitions from MonitoringService - Validated DELETE action with negative cases when MetricReportDefinition does not exist Signed-off-by: Wludzik, Jozef Change-Id: Iffde9f7bbf2955376e9714ac8d833967bd25eaa3 --- redfish-core/lib/metric_report_definition.hpp | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp index ecbab0c..8e04ac8 100644 --- a/redfish-core/lib/metric_report_definition.hpp +++ b/redfish-core/lib/metric_report_definition.hpp @@ -533,6 +533,38 @@ class MetricReportDefinition : public Node "xyz.openbmc_project.MonitoringService.Report"); } + void doDelete(crow::Response& res, const crow::Request& req, + const std::vector& params) override + { + auto asyncResp = std::make_shared(res); + if (params.size() != 1) + { + messages::internalError(asyncResp->res); + return; + } + + const std::string& id = params[0]; + telemetry::getReport(asyncResp, id, schemaType, deleteReport); + } + + static void deleteReport(const std::shared_ptr& asyncResp, + const std::string& path, const std::string& id) + { + crow::connections::systemBus->async_method_call( + [asyncResp](const boost::system::error_code ec) { + if (ec) + { + BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + messages::internalError(asyncResp->res); + return; + } + + asyncResp->res.result(boost::beast::http::status::no_content); + }, + "xyz.openbmc_project.MonitoringService", path, + "xyz.openbmc_project.Object.Delete", "Delete"); + } + public: static constexpr const char* schemaType = "#MetricReportDefinition.v1_3_0.MetricReportDefinition"; -- 2.16.6