Add support for DELETE on Triggers schema
Added DELETE method on /redfish/v1/TelemetryService/Triggers/<trigger>
uri. Dbus Delete interface on trigger object is used as a backend.
Tested:
- Trigger was removed successfully by making DELETE call on
redfish/v1/TelemetryService/Triggers/TestTrigger
Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: Ia830920dac6a539da5b289428374cb96d6492183
diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp
index c16cc89..8aeff0d 100644
--- a/redfish-core/include/utils/telemetry_utils.hpp
+++ b/redfish-core/include/utils/telemetry_utils.hpp
@@ -16,10 +16,16 @@
inline std::string getDbusReportPath(const std::string& id)
{
- std::string path =
- "/xyz/openbmc_project/Telemetry/Reports/TelemetryService/" + id;
- dbus::utility::escapePathForDbus(path);
- return path;
+ sdbusplus::message::object_path reportsPath(
+ "/xyz/openbmc_project/Telemetry/Reports/TelemetryService");
+ return {reportsPath / id};
+}
+
+inline std::string getDbusTriggerPath(const std::string& id)
+{
+ sdbusplus::message::object_path triggersPath(
+ "/xyz/openbmc_project/Telemetry/Triggers/TelemetryService");
+ return {triggersPath / id};
}
} // namespace telemetry
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index c3d1448..210468c 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -270,13 +270,6 @@
return true;
}
-inline std::string getDbusTriggerPath(const std::string& id)
-{
- sdbusplus::message::object_path path(
- "/xyz/openbmc_project/Telemetry/Triggers/TelemetryService");
- return {path / id};
-}
-
} // namespace telemetry
inline void requestRoutesTriggerCollection(App& app)
@@ -337,6 +330,38 @@
"org.freedesktop.DBus.Properties", "GetAll",
telemetry::triggerInterface);
});
+
+ BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/Triggers/<str>/")
+ .privileges(redfish::privileges::deleteTriggers)
+ .methods(boost::beast::http::verb::delete_)(
+ [](const crow::Request&,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& id) {
+ const std::string triggerPath =
+ telemetry::getDbusTriggerPath(id);
+
+ crow::connections::systemBus->async_method_call(
+ [asyncResp, id](const boost::system::error_code ec) {
+ if (ec.value() == EBADR)
+ {
+ messages::resourceNotFound(asyncResp->res,
+ "Triggers", id);
+ return;
+ }
+
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "respHandler DBus error " << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ asyncResp->res.result(
+ boost::beast::http::status::no_content);
+ },
+ telemetry::service, triggerPath,
+ "xyz.openbmc_project.Object.Delete", "Delete");
+ });
}
} // namespace redfish