blob: 867e735c638c6ab3573a735ebce9cdf0746c289d [file] [log] [blame]
Ed Tanousf175c282024-12-02 15:12:50 -08001/****************************************************************
2 * READ THIS WARNING FIRST
3 * This is an auto-generated header which contains definitions
4 * for Redfish DMTF defined messages.
5 * DO NOT modify this registry outside of running the
6 * parse_registries.py script. The definitions contained within
7 * this file are owned by DMTF. Any modifications to these files
8 * should be first pushed to the relevant registry in the DMTF
9 * github organization.
10 ***************************************************************/
11#include "task_messages.hpp"
12
13#include "registries.hpp"
14#include "registries/task_event_message_registry.hpp"
15
16#include <nlohmann/json.hpp>
17
18#include <array>
19#include <cstddef>
Ed Tanousf175c282024-12-02 15:12:50 -080020#include <span>
Ed Tanousf175c282024-12-02 15:12:50 -080021#include <string_view>
22
23// Clang can't seem to decide whether this header needs to be included or not,
24// and is inconsistent. Include it for now
25// NOLINTNEXTLINE(misc-include-cleaner)
Ed Tanous2ca56192025-09-16 13:19:08 -070026#include <cstdint>
27// NOLINTNEXTLINE(misc-include-cleaner)
28#include <string>
29// NOLINTNEXTLINE(misc-include-cleaner)
Ed Tanousf175c282024-12-02 15:12:50 -080030#include <utility>
31
32namespace redfish
33{
34
35namespace messages
36{
37
Ed Tanous10cf50d2025-05-06 16:10:32 -070038static nlohmann::json::object_t getLog(
39 redfish::registries::TaskEvent::Index name,
40 std::span<const std::string_view> args)
Ed Tanousf175c282024-12-02 15:12:50 -080041{
42 size_t index = static_cast<size_t>(name);
Patrick Williams4a102cd2025-02-27 14:52:54 -050043 if (index >= redfish::registries::TaskEvent::registry.size())
Ed Tanousf175c282024-12-02 15:12:50 -080044 {
45 return {};
46 }
Patrick Williams4a102cd2025-02-27 14:52:54 -050047 return getLogFromRegistry(redfish::registries::TaskEvent::header,
48 redfish::registries::TaskEvent::registry, index,
Ed Tanousf175c282024-12-02 15:12:50 -080049 args);
50}
51
52/**
53 * @internal
54 * @brief Formats TaskStarted message into JSON
55 *
56 * See header file for more information
57 * @endinternal
58 */
Ed Tanous10cf50d2025-05-06 16:10:32 -070059nlohmann::json::object_t taskStarted(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -080060{
Patrick Williams4a102cd2025-02-27 14:52:54 -050061 return getLog(redfish::registries::TaskEvent::Index::taskStarted,
Ed Tanousf175c282024-12-02 15:12:50 -080062 std::to_array({arg1}));
63}
64
65/**
66 * @internal
67 * @brief Formats TaskCompletedOK message into JSON
68 *
69 * See header file for more information
70 * @endinternal
71 */
Ed Tanous10cf50d2025-05-06 16:10:32 -070072nlohmann::json::object_t taskCompletedOK(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -080073{
Patrick Williams4a102cd2025-02-27 14:52:54 -050074 return getLog(redfish::registries::TaskEvent::Index::taskCompletedOK,
Ed Tanousf175c282024-12-02 15:12:50 -080075 std::to_array({arg1}));
76}
77
78/**
79 * @internal
80 * @brief Formats TaskCompletedWarning message into JSON
81 *
82 * See header file for more information
83 * @endinternal
84 */
Ed Tanous10cf50d2025-05-06 16:10:32 -070085nlohmann::json::object_t taskCompletedWarning(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -080086{
Patrick Williams4a102cd2025-02-27 14:52:54 -050087 return getLog(redfish::registries::TaskEvent::Index::taskCompletedWarning,
Ed Tanousf175c282024-12-02 15:12:50 -080088 std::to_array({arg1}));
89}
90
91/**
92 * @internal
93 * @brief Formats TaskAborted message into JSON
94 *
95 * See header file for more information
96 * @endinternal
97 */
Ed Tanous10cf50d2025-05-06 16:10:32 -070098nlohmann::json::object_t taskAborted(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -080099{
Patrick Williams4a102cd2025-02-27 14:52:54 -0500100 return getLog(redfish::registries::TaskEvent::Index::taskAborted,
Ed Tanousf175c282024-12-02 15:12:50 -0800101 std::to_array({arg1}));
102}
103
104/**
105 * @internal
106 * @brief Formats TaskCancelled message into JSON
107 *
108 * See header file for more information
109 * @endinternal
110 */
Ed Tanous10cf50d2025-05-06 16:10:32 -0700111nlohmann::json::object_t taskCancelled(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -0800112{
Patrick Williams4a102cd2025-02-27 14:52:54 -0500113 return getLog(redfish::registries::TaskEvent::Index::taskCancelled,
Ed Tanousf175c282024-12-02 15:12:50 -0800114 std::to_array({arg1}));
115}
116
117/**
118 * @internal
119 * @brief Formats TaskRemoved message into JSON
120 *
121 * See header file for more information
122 * @endinternal
123 */
Ed Tanous10cf50d2025-05-06 16:10:32 -0700124nlohmann::json::object_t taskRemoved(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -0800125{
Patrick Williams4a102cd2025-02-27 14:52:54 -0500126 return getLog(redfish::registries::TaskEvent::Index::taskRemoved,
Ed Tanousf175c282024-12-02 15:12:50 -0800127 std::to_array({arg1}));
128}
129
130/**
131 * @internal
132 * @brief Formats TaskPaused message into JSON
133 *
134 * See header file for more information
135 * @endinternal
136 */
Ed Tanous10cf50d2025-05-06 16:10:32 -0700137nlohmann::json::object_t taskPaused(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -0800138{
Patrick Williams4a102cd2025-02-27 14:52:54 -0500139 return getLog(redfish::registries::TaskEvent::Index::taskPaused,
Ed Tanousf175c282024-12-02 15:12:50 -0800140 std::to_array({arg1}));
141}
142
143/**
144 * @internal
145 * @brief Formats TaskResumed message into JSON
146 *
147 * See header file for more information
148 * @endinternal
149 */
Ed Tanous10cf50d2025-05-06 16:10:32 -0700150nlohmann::json::object_t taskResumed(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -0800151{
Patrick Williams4a102cd2025-02-27 14:52:54 -0500152 return getLog(redfish::registries::TaskEvent::Index::taskResumed,
Ed Tanousf175c282024-12-02 15:12:50 -0800153 std::to_array({arg1}));
154}
155
156/**
157 * @internal
158 * @brief Formats TaskProgressChanged message into JSON
159 *
160 * See header file for more information
161 * @endinternal
162 */
Ed Tanous10cf50d2025-05-06 16:10:32 -0700163nlohmann::json::object_t taskProgressChanged(std::string_view arg1,
164 uint64_t arg2)
Ed Tanousf175c282024-12-02 15:12:50 -0800165{
166 std::string arg2Str = std::to_string(arg2);
Patrick Williams4a102cd2025-02-27 14:52:54 -0500167 return getLog(redfish::registries::TaskEvent::Index::taskProgressChanged,
Ed Tanousf175c282024-12-02 15:12:50 -0800168 std::to_array<std::string_view>({arg1, arg2Str}));
169}
170
171} // namespace messages
172} // namespace redfish