1 #pragma once
2 
3 #include "helpers.hpp"
4 #include "report_manager.hpp"
5 #include "types/report_types.hpp"
6 
7 #include <chrono>
8 #include <string>
9 
10 class ReportParams final
11 {
12   public:
reportId(std::string_view val)13     ReportParams& reportId(std::string_view val)
14     {
15         reportIdProperty = val;
16         return *this;
17     }
18 
reportId() const19     const std::string& reportId() const
20     {
21         return reportIdProperty;
22     }
23 
reportName(std::string_view val)24     ReportParams& reportName(std::string_view val)
25     {
26         reportNameProperty = val;
27         return *this;
28     }
29 
reportName() const30     const std::string& reportName() const
31     {
32         return reportNameProperty;
33     }
34 
reportingType(const ReportingType val)35     ReportParams& reportingType(const ReportingType val)
36     {
37         reportingTypeProperty = val;
38         return *this;
39     }
40 
reportingType() const41     ReportingType reportingType() const
42     {
43         return reportingTypeProperty;
44     }
45 
reportActions(std::vector<ReportAction> val)46     ReportParams& reportActions(std::vector<ReportAction> val)
47     {
48         reportActionsProperty = std::move(val);
49         return *this;
50     }
51 
reportActions() const52     std::vector<ReportAction> reportActions() const
53     {
54         return reportActionsProperty;
55     }
56 
interval(Milliseconds val)57     ReportParams& interval(Milliseconds val)
58     {
59         intervalProperty = val;
60         return *this;
61     }
62 
interval() const63     Milliseconds interval() const
64     {
65         return intervalProperty;
66     }
67 
enabled(bool val)68     ReportParams& enabled(bool val)
69     {
70         enabledProperty = val;
71         return *this;
72     }
73 
enabled() const74     bool enabled() const
75     {
76         return enabledProperty;
77     }
78 
appendLimit(uint64_t val)79     ReportParams& appendLimit(uint64_t val)
80     {
81         appendLimitProperty = val;
82         return *this;
83     }
84 
appendLimit() const85     uint64_t appendLimit() const
86     {
87         return appendLimitProperty;
88     }
89 
reportUpdates(ReportUpdates val)90     ReportParams& reportUpdates(ReportUpdates val)
91     {
92         reportUpdatesProperty = val;
93         return *this;
94     }
95 
reportUpdates() const96     ReportUpdates reportUpdates() const
97     {
98         return reportUpdatesProperty;
99     }
100 
metricParameters(std::vector<LabeledMetricParameters> val)101     ReportParams& metricParameters(std::vector<LabeledMetricParameters> val)
102     {
103         metricParametersProperty = std::move(val);
104         return *this;
105     }
106 
metricParameters() const107     const std::vector<LabeledMetricParameters>& metricParameters() const
108     {
109         return metricParametersProperty;
110     }
111 
readings(Readings val)112     ReportParams& readings(Readings val)
113     {
114         readingsProperty = std::move(val);
115         return *this;
116     }
117 
readings() const118     Readings readings() const
119     {
120         return readingsProperty;
121     }
122 
PrintTo(const ReportParams & params,std::ostream * os)123     friend void PrintTo(const ReportParams& params, std::ostream* os)
124     {
125         *os << "{ Id: \"" << params.reportIdProperty << "\", Name: \""
126             << params.reportNameProperty << "\", ReportingType: \""
127             << utils::enumToString(params.reportingTypeProperty)
128             << "\", ReportActions: ";
129         PrintTo(params.reportActionsProperty, os);
130         *os << ", Interval: " << params.intervalProperty
131             << ", Enabled: " << params.enabledProperty
132             << ", AppendLimit: " << std::to_string(params.appendLimitProperty)
133             << ", ReportUpdates: \""
134             << utils::enumToString(params.reportUpdatesProperty)
135             << "\", MetricParameters: ";
136         PrintTo(params.metricParametersProperty, os);
137         *os << ", Readings: ";
138         PrintTo(params.readingsProperty, os);
139         *os << " }";
140     }
141 
142   private:
143     std::string reportIdProperty = "TestId";
144     std::string reportNameProperty = "TestReport";
145     ReportingType reportingTypeProperty = ReportingType::onChange;
146     std::vector<ReportAction> reportActionsProperty = {
147         ReportAction::logToMetricReportsCollection};
148     Milliseconds intervalProperty{};
149     uint64_t appendLimitProperty = 123;
150     ReportUpdates reportUpdatesProperty = ReportUpdates::overwrite;
151     std::vector<LabeledMetricParameters> metricParametersProperty{
152         {LabeledMetricParameters{
153              {LabeledSensorInfo{"Service",
154                                 "/xyz/openbmc_project/sensors/power/p1",
155                                 "metadata1"}},
156              OperationType::avg,
157              CollectionTimeScope::point,
158              CollectionDuration(Milliseconds(0u))},
159          LabeledMetricParameters{
160              {LabeledSensorInfo{"Service",
161                                 "/xyz/openbmc_project/sensors/power/p2",
162                                 "metadata2"}},
163              OperationType::avg,
164              CollectionTimeScope::point,
165              CollectionDuration(Milliseconds(0u))}}};
166     bool enabledProperty = true;
167     Readings readingsProperty = {};
168 };
169