#pragma once #include "dbus_utility.hpp" namespace redfish { namespace telemetry { constexpr const char* service = "xyz.openbmc_project.Telemetry"; constexpr const char* reportInterface = "xyz.openbmc_project.Telemetry.Report"; constexpr const char* metricReportDefinitionUri = "/redfish/v1/TelemetryService/MetricReportDefinitions/"; constexpr const char* metricReportUri = "/redfish/v1/TelemetryService/MetricReports/"; inline void getReportCollection(const std::shared_ptr& asyncResp, const std::string& uri) { const std::array interfaces = {reportInterface}; crow::connections::systemBus->async_method_call( [asyncResp, uri](const boost::system::error_code ec, const std::vector& reports) { if (ec == boost::system::errc::io_error) { asyncResp->res.jsonValue["Members"] = nlohmann::json::array(); asyncResp->res.jsonValue["Members@odata.count"] = 0; return; } if (ec) { BMCWEB_LOG_ERROR << "Dbus method call failed: " << ec; messages::internalError(asyncResp->res); return; } nlohmann::json& members = asyncResp->res.jsonValue["Members"]; members = nlohmann::json::array(); for (const std::string& report : reports) { sdbusplus::message::object_path path(report); std::string name = path.filename(); if (name.empty()) { BMCWEB_LOG_ERROR << "Received invalid path: " << report; messages::internalError(asyncResp->res); return; } members.push_back({{"@odata.id", uri + name}}); } asyncResp->res.jsonValue["Members@odata.count"] = members.size(); }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/xyz/openbmc_project/Telemetry/Reports/TelemetryService", 1, interfaces); } inline std::string getDbusReportPath(const std::string& id) { std::string path = "/xyz/openbmc_project/Telemetry/Reports/TelemetryService/" + id; dbus::utility::escapePathForDbus(path); return path; } } // namespace telemetry } // namespace redfish