Break out methods
"Like we do other places.. blah"
Tested: Top commit was tested.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I8a254067f97569a4d07817796b89a95cd768ff18
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index fdd86d4..54607a8 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -743,6 +743,38 @@
};
} // namespace telemetry
+inline void
+ handleMetricReportGet(App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& id)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, telemetry::service,
+ telemetry::getDbusReportPath(id), telemetry::reportInterface,
+ [asyncResp, id](const boost::system::error_code& ec,
+ const dbus::utility::DBusPropertiesMap& properties) {
+ if (ec.value() == EBADR || ec == boost::system::errc::host_unreachable)
+ {
+ messages::resourceNotFound(asyncResp->res, "MetricReportDefinition",
+ id);
+ return;
+ }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "respHandler DBus error " << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ telemetry::fillReportDefinition(asyncResp, id, properties);
+ });
+}
+
inline void handleMetricReportDelete(
App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& id)
@@ -861,37 +893,7 @@
"/redfish/v1/TelemetryService/MetricReportDefinitions/<str>/")
.privileges(redfish::privileges::getMetricReportDefinition)
.methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& id) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
-
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, telemetry::service,
- telemetry::getDbusReportPath(id), telemetry::reportInterface,
- [asyncResp,
- id](const boost::system::error_code& ec,
- const dbus::utility::DBusPropertiesMap& properties) {
- if (ec.value() == EBADR ||
- ec == boost::system::errc::host_unreachable)
- {
- messages::resourceNotFound(asyncResp->res,
- "MetricReportDefinition", id);
- return;
- }
- if (ec)
- {
- BMCWEB_LOG_ERROR << "respHandler DBus error " << ec;
- messages::internalError(asyncResp->res);
- return;
- }
-
- telemetry::fillReportDefinition(asyncResp, id, properties);
- });
- });
+ std::bind_front(handleMetricReportGet, std::ref(app)));
BMCWEB_ROUTE(app,
"/redfish/v1/TelemetryService/MetricReportDefinitions/<str>/")