xref: /openbmc/bmcweb/features/redfish/include/heartbeat_messages.hpp (revision fb54610544f97b989b549d8fc94518e2d38c9467)
1*fb546105SMyung Bae #pragma once
2*fb546105SMyung Bae #include "registries/heartbeat_event_message_registry.hpp"
3*fb546105SMyung Bae 
4*fb546105SMyung Bae #include <nlohmann/json.hpp>
5*fb546105SMyung Bae 
6*fb546105SMyung Bae #include <array>
7*fb546105SMyung Bae #include <span>
8*fb546105SMyung Bae #include <string_view>
9*fb546105SMyung Bae 
10*fb546105SMyung Bae namespace redfish::messages
11*fb546105SMyung Bae {
12*fb546105SMyung Bae 
13*fb546105SMyung Bae inline nlohmann::json
14*fb546105SMyung Bae     getLogHeartbeat(redfish::registries::heartbeat_event::Index name,
15*fb546105SMyung Bae                     std::span<const std::string_view> args)
16*fb546105SMyung Bae {
17*fb546105SMyung Bae     size_t index = static_cast<size_t>(name);
18*fb546105SMyung Bae     if (index >= redfish::registries::heartbeat_event::registry.size())
19*fb546105SMyung Bae     {
20*fb546105SMyung Bae         return {};
21*fb546105SMyung Bae     }
22*fb546105SMyung Bae     return getLogFromRegistry(redfish::registries::heartbeat_event::header,
23*fb546105SMyung Bae                               redfish::registries::heartbeat_event::registry,
24*fb546105SMyung Bae                               index, args);
25*fb546105SMyung Bae }
26*fb546105SMyung Bae 
27*fb546105SMyung Bae /**
28*fb546105SMyung Bae  * @brief Formats RedfishServiceFunctional message into JSON
29*fb546105SMyung Bae  * Message body: "Redfish service is functional."
30*fb546105SMyung Bae  *
31*fb546105SMyung Bae  * @returns Message RedfishServiceFunctional formatted to JSON */
32*fb546105SMyung Bae inline nlohmann::json redfishServiceFunctional()
33*fb546105SMyung Bae {
34*fb546105SMyung Bae     return getLogHeartbeat(
35*fb546105SMyung Bae         registries::heartbeat_event::Index::redfishServiceFunctional, {});
36*fb546105SMyung Bae }
37*fb546105SMyung Bae 
38*fb546105SMyung Bae } // namespace redfish::messages
39