Add GET method for Triggers
Added GET method for retrieving details of individual Trigger searched
by given Trigger name, details are extracted from Telemetry service
Tested:
- Added single Trigger and requested result from bmcweb via
/redfish/v1/TelemetryService/Triggers/<triggername>
- Added multiple Triggers numeric and discrete with various parameters
(empty, non-empty), and requested results from bmcweb via
/redfish/v1/TelemetryService/Triggers/<triggername>
- Verified uris /redfish/v1/TelemetryService/Triggers/<triggername> by
using Redfish-Service-Validator (all passed)
Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com>
Change-Id: I1c966b2f792324cc6f6a8784ad18a683e5ce7bd9
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index e56996d..2397df6 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -208,6 +208,7 @@
requestRoutesMetricReportCollection(app);
requestRoutesMetricReport(app);
requestRoutesTriggerCollection(app);
+ requestRoutesTrigger(app);
}
};
diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp
index ee21fd7..d4c65de 100644
--- a/redfish-core/include/utils/time_utils.hpp
+++ b/redfish-core/include/utils/time_utils.hpp
@@ -208,5 +208,25 @@
return fmt;
}
+inline std::optional<std::string>
+ toDurationStringFromUint(const uint64_t timeMs)
+{
+ static const uint64_t maxTimeMs =
+ static_cast<uint64_t>(std::chrono::milliseconds::max().count());
+
+ if (maxTimeMs < timeMs)
+ {
+ return std::nullopt;
+ }
+
+ std::string duration = toDurationString(std::chrono::milliseconds(timeMs));
+ if (duration.empty())
+ {
+ return std::nullopt;
+ }
+
+ return std::make_optional(duration);
+}
+
} // namespace time_utils
} // namespace redfish