blob: 710d3ceb889bf6e9be074823e04a8fcc81db36b9 [file] [log] [blame]
#pragma once
#include "interfaces/json_storage.hpp"
#include "interfaces/report.hpp"
#include "interfaces/report_factory.hpp"
#include "interfaces/report_manager.hpp"
#include "interfaces/trigger_manager.hpp"
#include "report.hpp"
#include "utils/dbus_path_utils.hpp"
#include <systemd/sd-bus-protocol.h>
#include <sdbusplus/asio/object_server.hpp>
#include <chrono>
#include <memory>
#include <string>
#include <vector>
class ReportManager : public interfaces::ReportManager
{
public:
ReportManager(
std::unique_ptr<interfaces::ReportFactory> reportFactory,
std::unique_ptr<interfaces::JsonStorage> reportStorage,
const std::shared_ptr<sdbusplus::asio::object_server>& objServer);
~ReportManager() = default;
ReportManager(const ReportManager&) = delete;
ReportManager(ReportManager&&) = delete;
ReportManager& operator=(const ReportManager&) = delete;
ReportManager& operator=(ReportManager&&) = delete;
void removeReport(const interfaces::Report* report) override;
static void verifyMetricParams(
const std::vector<LabeledMetricParameters>& metricParams);
private:
std::unique_ptr<interfaces::ReportFactory> reportFactory;
std::unique_ptr<interfaces::JsonStorage> reportStorage;
std::shared_ptr<sdbusplus::asio::object_server> objServer;
std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface;
std::vector<std::unique_ptr<interfaces::Report>> reports;
void verifyAddReport(
const std::string& reportId, const std::string& reportName,
const ReportingType reportingType, Milliseconds interval,
const ReportUpdates reportUpdates, const uint64_t appendLimit,
const std::vector<LabeledMetricParameters>& readingParams);
interfaces::Report& addReport(
boost::asio::yield_context& yield, const std::string& reportId,
const std::string& reportName, const ReportingType reportingType,
const std::vector<ReportAction>& reportActions, Milliseconds interval,
const uint64_t appendLimit, const ReportUpdates reportUpdates,
ReadingParameters metricParams, const bool enabled);
interfaces::Report&
addReport(const std::string& reportId, const std::string& reportName,
const ReportingType reportingType,
const std::vector<ReportAction>& reportActions,
Milliseconds interval, const uint64_t appendLimit,
const ReportUpdates reportUpdates,
std::vector<LabeledMetricParameters> metricParams,
const bool enabled, Readings);
void loadFromPersistent();
public:
static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS};
static constexpr size_t maxNumberMetrics{TELEMETRY_MAX_READING_PARAMS};
static constexpr Milliseconds minInterval{TELEMETRY_MIN_INTERVAL};
static constexpr size_t maxAppendLimit{TELEMETRY_MAX_APPEND_LIMIT};
static constexpr const char* reportManagerIfaceName =
"xyz.openbmc_project.Telemetry.ReportManager";
static constexpr const char* reportManagerPath =
"/xyz/openbmc_project/Telemetry/Reports";
static constexpr std::string_view reportNameDefault = "Report";
static_assert(!reportNameDefault.empty(),
"Default report name cannot be empty.");
};