xref: /openbmc/bmcweb/features/redfish/src/heartbeat_messages.cpp (revision 4a102cd48c588d32c0a4d6610b4a9ed616f255f3)
1a8a5bc1bSEd Tanous /****************************************************************
2a8a5bc1bSEd Tanous  *                 READ THIS WARNING FIRST
3a8a5bc1bSEd Tanous  * This is an auto-generated header which contains definitions
4a8a5bc1bSEd Tanous  * for Redfish DMTF defined messages.
5a8a5bc1bSEd Tanous  * DO NOT modify this registry outside of running the
6a8a5bc1bSEd Tanous  * parse_registries.py script.  The definitions contained within
7a8a5bc1bSEd Tanous  * this file are owned by DMTF.  Any modifications to these files
8a8a5bc1bSEd Tanous  * should be first pushed to the relevant registry in the DMTF
9a8a5bc1bSEd Tanous  * github organization.
10a8a5bc1bSEd Tanous  ***************************************************************/
11a8a5bc1bSEd Tanous #include "heartbeat_messages.hpp"
12a8a5bc1bSEd Tanous 
13a8a5bc1bSEd Tanous #include "registries.hpp"
14a8a5bc1bSEd Tanous #include "registries/heartbeat_event_message_registry.hpp"
15a8a5bc1bSEd Tanous 
16a8a5bc1bSEd Tanous #include <nlohmann/json.hpp>
17a8a5bc1bSEd Tanous 
18a8a5bc1bSEd Tanous #include <array>
19a8a5bc1bSEd Tanous #include <cstddef>
20a8a5bc1bSEd Tanous #include <span>
21a8a5bc1bSEd Tanous #include <string_view>
22a8a5bc1bSEd Tanous 
23a8a5bc1bSEd Tanous // Clang can't seem to decide whether this header needs to be included or not,
24a8a5bc1bSEd Tanous // and is inconsistent.  Include it for now
25a8a5bc1bSEd Tanous // NOLINTNEXTLINE(misc-include-cleaner)
26a8a5bc1bSEd Tanous #include <utility>
27a8a5bc1bSEd Tanous 
28a8a5bc1bSEd Tanous namespace redfish
29a8a5bc1bSEd Tanous {
30a8a5bc1bSEd Tanous 
31a8a5bc1bSEd Tanous namespace messages
32a8a5bc1bSEd Tanous {
33a8a5bc1bSEd Tanous 
34*4a102cd4SPatrick Williams static nlohmann::json getLog(redfish::registries::HeartbeatEvent::Index name,
35a8a5bc1bSEd Tanous                              std::span<const std::string_view> args)
36a8a5bc1bSEd Tanous {
37a8a5bc1bSEd Tanous     size_t index = static_cast<size_t>(name);
38*4a102cd4SPatrick Williams     if (index >= redfish::registries::HeartbeatEvent::registry.size())
39a8a5bc1bSEd Tanous     {
40a8a5bc1bSEd Tanous         return {};
41a8a5bc1bSEd Tanous     }
42*4a102cd4SPatrick Williams     return getLogFromRegistry(redfish::registries::HeartbeatEvent::header,
43*4a102cd4SPatrick Williams                               redfish::registries::HeartbeatEvent::registry,
44a8a5bc1bSEd Tanous                               index, args);
45a8a5bc1bSEd Tanous }
46a8a5bc1bSEd Tanous 
47a8a5bc1bSEd Tanous /**
48a8a5bc1bSEd Tanous  * @internal
49a8a5bc1bSEd Tanous  * @brief Formats RedfishServiceFunctional message into JSON
50a8a5bc1bSEd Tanous  *
51a8a5bc1bSEd Tanous  * See header file for more information
52a8a5bc1bSEd Tanous  * @endinternal
53a8a5bc1bSEd Tanous  */
54a8a5bc1bSEd Tanous nlohmann::json redfishServiceFunctional()
55a8a5bc1bSEd Tanous {
56a8a5bc1bSEd Tanous     return getLog(
57*4a102cd4SPatrick Williams         redfish::registries::HeartbeatEvent::Index::redfishServiceFunctional,
58a8a5bc1bSEd Tanous         {});
59a8a5bc1bSEd Tanous }
60a8a5bc1bSEd Tanous 
61a8a5bc1bSEd Tanous } // namespace messages
62a8a5bc1bSEd Tanous } // namespace redfish
63