xref: /openbmc/bmcweb/features/redfish/src/heartbeat_messages.cpp (revision 10cf50dca112b27176dc5734126983ad37ba2c04)
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*10cf50dcSEd Tanous static nlohmann::json::object_t getLog(
35*10cf50dcSEd Tanous     redfish::registries::HeartbeatEvent::Index name,
36a8a5bc1bSEd Tanous     std::span<const std::string_view> args)
37a8a5bc1bSEd Tanous {
38a8a5bc1bSEd Tanous     size_t index = static_cast<size_t>(name);
394a102cd4SPatrick Williams     if (index >= redfish::registries::HeartbeatEvent::registry.size())
40a8a5bc1bSEd Tanous     {
41a8a5bc1bSEd Tanous         return {};
42a8a5bc1bSEd Tanous     }
434a102cd4SPatrick Williams     return getLogFromRegistry(redfish::registries::HeartbeatEvent::header,
444a102cd4SPatrick Williams                               redfish::registries::HeartbeatEvent::registry,
45a8a5bc1bSEd Tanous                               index, args);
46a8a5bc1bSEd Tanous }
47a8a5bc1bSEd Tanous 
48a8a5bc1bSEd Tanous /**
49a8a5bc1bSEd Tanous  * @internal
50a8a5bc1bSEd Tanous  * @brief Formats RedfishServiceFunctional message into JSON
51a8a5bc1bSEd Tanous  *
52a8a5bc1bSEd Tanous  * See header file for more information
53a8a5bc1bSEd Tanous  * @endinternal
54a8a5bc1bSEd Tanous  */
55*10cf50dcSEd Tanous nlohmann::json::object_t redfishServiceFunctional()
56a8a5bc1bSEd Tanous {
57a8a5bc1bSEd Tanous     return getLog(
584a102cd4SPatrick Williams         redfish::registries::HeartbeatEvent::Index::redfishServiceFunctional,
59a8a5bc1bSEd Tanous         {});
60a8a5bc1bSEd Tanous }
61a8a5bc1bSEd Tanous 
62a8a5bc1bSEd Tanous } // namespace messages
63a8a5bc1bSEd Tanous } // namespace redfish
64