1 #pragma once
2
3 #include "dbus_utility.hpp"
4 #include "utils/dbus_utils.hpp"
5
6 #include <optional>
7 #include <string>
8
9 namespace redfish
10 {
11 struct DbusEventLogEntry
12 {
13 // represents a subset of an instance of dbus interface
14 // xyz.openbmc_project.Logging.Entry
15
16 uint32_t Id = 0;
17 std::string Message;
18 const std::string* Path = nullptr;
19 const std::string* Resolution = nullptr;
20 bool Resolved = false;
21 std::string ServiceProviderNotify;
22 std::string Severity;
23 uint64_t Timestamp = 0;
24 uint64_t UpdateTimestamp = 0;
25 };
26
fillDbusEventLogEntryFromPropertyMap(const dbus::utility::DBusPropertiesMap & resp)27 inline std::optional<DbusEventLogEntry> fillDbusEventLogEntryFromPropertyMap(
28 const dbus::utility::DBusPropertiesMap& resp)
29 {
30 DbusEventLogEntry entry;
31
32 // clang-format off
33 bool success = sdbusplus::unpackPropertiesNoThrow(
34 dbus_utils::UnpackErrorPrinter(), resp,
35 "Id", entry.Id,
36 "Message", entry.Message,
37 "Path", entry.Path,
38 "Resolution", entry.Resolution,
39 "Resolved", entry.Resolved,
40 "ServiceProviderNotify", entry.ServiceProviderNotify,
41 "Severity", entry.Severity,
42 "Timestamp", entry.Timestamp,
43 "UpdateTimestamp", entry.UpdateTimestamp
44 );
45 // clang-format on
46 if (!success)
47 {
48 return std::nullopt;
49 }
50 return entry;
51 }
52 } // namespace redfish
53