164b75a5bSKrzysztof Grobelny #pragma once 264b75a5bSKrzysztof Grobelny 3e2362796SWludzik, Jozef #include "interfaces/json_storage.hpp" 42f9f9b87SWludzik, Jozef #include "interfaces/report.hpp" 52f9f9b87SWludzik, Jozef #include "interfaces/report_factory.hpp" 62f9f9b87SWludzik, Jozef #include "interfaces/report_manager.hpp" 7b4ef22e4SSzymon Dompke #include "interfaces/trigger_manager.hpp" 8e28aa53dSSzymon Dompke #include "report.hpp" 91cdd7e4fSSzymon Dompke #include "utils/dbus_path_utils.hpp" 10cb88cfdfSWludzik, Jozef 1132859b63SKarol Niczyj #include <systemd/sd-bus-protocol.h> 1232859b63SKarol Niczyj 1364b75a5bSKrzysztof Grobelny #include <sdbusplus/asio/object_server.hpp> 1464b75a5bSKrzysztof Grobelny 1564b75a5bSKrzysztof Grobelny #include <chrono> 1664b75a5bSKrzysztof Grobelny #include <memory> 17bc766b4dSWludzik, Jozef #include <string> 1864b75a5bSKrzysztof Grobelny #include <vector> 1964b75a5bSKrzysztof Grobelny 202f9f9b87SWludzik, Jozef class ReportManager : public interfaces::ReportManager 2164b75a5bSKrzysztof Grobelny { 2264b75a5bSKrzysztof Grobelny public: 2364b75a5bSKrzysztof Grobelny ReportManager( 242f9f9b87SWludzik, Jozef std::unique_ptr<interfaces::ReportFactory> reportFactory, 25e2362796SWludzik, Jozef std::unique_ptr<interfaces::JsonStorage> reportStorage, 26e6d48874SKrzysztof Grobelny const std::shared_ptr<sdbusplus::asio::object_server>& objServer); 27cb88cfdfSWludzik, Jozef ~ReportManager() = default; 2864b75a5bSKrzysztof Grobelny 2931db7f71SKrzysztof Grobelny ReportManager(const ReportManager&) = delete; 30cb88cfdfSWludzik, Jozef ReportManager(ReportManager&&) = delete; 3131db7f71SKrzysztof Grobelny ReportManager& operator=(const ReportManager&) = delete; 32cb88cfdfSWludzik, Jozef ReportManager& operator=(ReportManager&&) = delete; 33cb88cfdfSWludzik, Jozef 342f9f9b87SWludzik, Jozef void removeReport(const interfaces::Report* report) override; 3564b75a5bSKrzysztof Grobelny 365e7cbf42SMichal Orzel static void verifyMetricParams( 375e7cbf42SMichal Orzel const std::vector<LabeledMetricParameters>& metricParams); 385e7cbf42SMichal Orzel 3964b75a5bSKrzysztof Grobelny private: 402f9f9b87SWludzik, Jozef std::unique_ptr<interfaces::ReportFactory> reportFactory; 41e2362796SWludzik, Jozef std::unique_ptr<interfaces::JsonStorage> reportStorage; 4264b75a5bSKrzysztof Grobelny std::shared_ptr<sdbusplus::asio::object_server> objServer; 43cb88cfdfSWludzik, Jozef std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface; 442f9f9b87SWludzik, Jozef std::vector<std::unique_ptr<interfaces::Report>> reports; 4564b75a5bSKrzysztof Grobelny 46dcc4e193SKrzysztof Grobelny void verifyAddReport( 47b8cc78ddSKrzysztof Grobelny const std::string& reportId, const std::string& reportName, 48b8cc78ddSKrzysztof Grobelny const ReportingType reportingType, Milliseconds interval, 49cd5b0b7eSAnkita Vilas Gawade const ReportUpdates reportUpdates, const uint64_t appendLimit, 50dcc4e193SKrzysztof Grobelny const std::vector<LabeledMetricParameters>& readingParams); 517e098e93SLukasz Kazmierczak interfaces::Report& addReport( 52b8cc78ddSKrzysztof Grobelny boost::asio::yield_context& yield, const std::string& reportId, 53b8cc78ddSKrzysztof Grobelny const std::string& reportName, const ReportingType reportingType, 5451497a0cSKrzysztof Grobelny const std::vector<ReportAction>& reportActions, Milliseconds interval, 5551497a0cSKrzysztof Grobelny const uint64_t appendLimit, const ReportUpdates reportUpdates, 567e098e93SLukasz Kazmierczak ReadingParameters metricParams, const bool enabled); 57*583ba441SPatrick Williams interfaces::Report& addReport( 58*583ba441SPatrick Williams const std::string& reportId, const std::string& reportName, 59b8cc78ddSKrzysztof Grobelny const ReportingType reportingType, 60*583ba441SPatrick Williams const std::vector<ReportAction>& reportActions, Milliseconds interval, 61*583ba441SPatrick Williams const uint64_t appendLimit, const ReportUpdates reportUpdates, 62*583ba441SPatrick Williams std::vector<LabeledMetricParameters> metricParams, const bool enabled, 63*583ba441SPatrick Williams Readings); 64e2362796SWludzik, Jozef void loadFromPersistent(); 65e2362796SWludzik, Jozef 66cb88cfdfSWludzik, Jozef public: 67503c1589SWludzik, Jozef static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS}; 68cd5b0b7eSAnkita Vilas Gawade static constexpr size_t maxNumberMetrics{TELEMETRY_MAX_READING_PARAMS}; 69dcc4e193SKrzysztof Grobelny static constexpr Milliseconds minInterval{TELEMETRY_MIN_INTERVAL}; 70cd5b0b7eSAnkita Vilas Gawade static constexpr size_t maxAppendLimit{TELEMETRY_MAX_APPEND_LIMIT}; 712f9f9b87SWludzik, Jozef static constexpr const char* reportManagerIfaceName = 722f9f9b87SWludzik, Jozef "xyz.openbmc_project.Telemetry.ReportManager"; 732f9f9b87SWludzik, Jozef static constexpr const char* reportManagerPath = 742f9f9b87SWludzik, Jozef "/xyz/openbmc_project/Telemetry/Reports"; 7532305f14SSzymon Dompke static constexpr std::string_view reportNameDefault = "Report"; 7632305f14SSzymon Dompke 7732305f14SSzymon Dompke static_assert(!reportNameDefault.empty(), 7832305f14SSzymon Dompke "Default report name cannot be empty."); 7964b75a5bSKrzysztof Grobelny }; 80