Add GET method for TriggerCollection
Added GET method for retrieving list of Triggers from Telemetry service
Tested:
- Added single Trigger and requested result from bmcweb via
/redfish/v1/TelemetryService/Triggers
- Added multiple Triggers numeric and discrete, and requested results
from bmcweb via /redfish/v1/TelemetryService/Triggers
- Verified uri /redfish/v1/TelemetryService/Triggers by using
Redfish-Service-Validator with no Triggers/empty Collection (passed)
Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com>
Change-Id: Ide00eb44901ea1b97b80fc5c5ddfd97e393d4a04
diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp
index 8ecc591..b79a5cd 100644
--- a/redfish-core/lib/telemetry_service.hpp
+++ b/redfish-core/lib/telemetry_service.hpp
@@ -23,6 +23,8 @@
"/redfish/v1/TelemetryService/MetricReportDefinitions";
asyncResp->res.jsonValue["MetricReports"]["@odata.id"] =
"/redfish/v1/TelemetryService/MetricReports";
+ asyncResp->res.jsonValue["Triggers"]["@odata.id"] =
+ "/redfish/v1/TelemetryService/Triggers";
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
new file mode 100644
index 0000000..bbe0887
--- /dev/null
+++ b/redfish-core/lib/trigger.hpp
@@ -0,0 +1,39 @@
+#pragma once
+
+#include "utils/collection.hpp"
+#include "utils/telemetry_utils.hpp"
+
+#include <app.hpp>
+#include <registries/privilege_registry.hpp>
+
+namespace redfish
+{
+namespace telemetry
+{
+constexpr const char* triggerInterface =
+ "xyz.openbmc_project.Telemetry.Trigger";
+constexpr const char* triggerUri = "/redfish/v1/TelemetryService/Triggers";
+
+} // namespace telemetry
+
+inline void requestRoutesTriggerCollection(App& app)
+{
+ BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/Triggers/")
+ .privileges(redfish::privileges::getTriggersCollection)
+ .methods(boost::beast::http::verb::get)(
+ [](const crow::Request&,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#TriggersCollection.TriggersCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/TelemetryService/Triggers";
+ asyncResp->res.jsonValue["Name"] = "Triggers Collection";
+ const std::vector<const char*> interfaces{
+ telemetry::triggerInterface};
+ collection_util::getCollectionMembers(
+ asyncResp, telemetry::triggerUri, interfaces,
+ "/xyz/openbmc_project/Telemetry/Triggers/TelemetryService");
+ });
+}
+
+} // namespace redfish