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