blob: 79c312a95d6899085d79e16087f0f72373dd37fd [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>
20#include <cstdint>
21#include <span>
22#include <string>
23#include <string_view>
24
25// Clang can't seem to decide whether this header needs to be included or not,
26// and is inconsistent. Include it for now
27// NOLINTNEXTLINE(misc-include-cleaner)
28#include <utility>
29
30namespace redfish
31{
32
33namespace messages
34{
35
Ed Tanous10cf50d2025-05-06 16:10:32 -070036static nlohmann::json::object_t getLog(
37 redfish::registries::TaskEvent::Index name,
38 std::span<const std::string_view> args)
Ed Tanousf175c282024-12-02 15:12:50 -080039{
40 size_t index = static_cast<size_t>(name);
Patrick Williams4a102cd2025-02-27 14:52:54 -050041 if (index >= redfish::registries::TaskEvent::registry.size())
Ed Tanousf175c282024-12-02 15:12:50 -080042 {
43 return {};
44 }
Patrick Williams4a102cd2025-02-27 14:52:54 -050045 return getLogFromRegistry(redfish::registries::TaskEvent::header,
46 redfish::registries::TaskEvent::registry, index,
Ed Tanousf175c282024-12-02 15:12:50 -080047 args);
48}
49
50/**
51 * @internal
52 * @brief Formats TaskStarted message into JSON
53 *
54 * See header file for more information
55 * @endinternal
56 */
Ed Tanous10cf50d2025-05-06 16:10:32 -070057nlohmann::json::object_t taskStarted(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -080058{
Patrick Williams4a102cd2025-02-27 14:52:54 -050059 return getLog(redfish::registries::TaskEvent::Index::taskStarted,
Ed Tanousf175c282024-12-02 15:12:50 -080060 std::to_array({arg1}));
61}
62
63/**
64 * @internal
65 * @brief Formats TaskCompletedOK message into JSON
66 *
67 * See header file for more information
68 * @endinternal
69 */
Ed Tanous10cf50d2025-05-06 16:10:32 -070070nlohmann::json::object_t taskCompletedOK(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -080071{
Patrick Williams4a102cd2025-02-27 14:52:54 -050072 return getLog(redfish::registries::TaskEvent::Index::taskCompletedOK,
Ed Tanousf175c282024-12-02 15:12:50 -080073 std::to_array({arg1}));
74}
75
76/**
77 * @internal
78 * @brief Formats TaskCompletedWarning message into JSON
79 *
80 * See header file for more information
81 * @endinternal
82 */
Ed Tanous10cf50d2025-05-06 16:10:32 -070083nlohmann::json::object_t taskCompletedWarning(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -080084{
Patrick Williams4a102cd2025-02-27 14:52:54 -050085 return getLog(redfish::registries::TaskEvent::Index::taskCompletedWarning,
Ed Tanousf175c282024-12-02 15:12:50 -080086 std::to_array({arg1}));
87}
88
89/**
90 * @internal
91 * @brief Formats TaskAborted message into JSON
92 *
93 * See header file for more information
94 * @endinternal
95 */
Ed Tanous10cf50d2025-05-06 16:10:32 -070096nlohmann::json::object_t taskAborted(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -080097{
Patrick Williams4a102cd2025-02-27 14:52:54 -050098 return getLog(redfish::registries::TaskEvent::Index::taskAborted,
Ed Tanousf175c282024-12-02 15:12:50 -080099 std::to_array({arg1}));
100}
101
102/**
103 * @internal
104 * @brief Formats TaskCancelled message into JSON
105 *
106 * See header file for more information
107 * @endinternal
108 */
Ed Tanous10cf50d2025-05-06 16:10:32 -0700109nlohmann::json::object_t taskCancelled(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -0800110{
Patrick Williams4a102cd2025-02-27 14:52:54 -0500111 return getLog(redfish::registries::TaskEvent::Index::taskCancelled,
Ed Tanousf175c282024-12-02 15:12:50 -0800112 std::to_array({arg1}));
113}
114
115/**
116 * @internal
117 * @brief Formats TaskRemoved message into JSON
118 *
119 * See header file for more information
120 * @endinternal
121 */
Ed Tanous10cf50d2025-05-06 16:10:32 -0700122nlohmann::json::object_t taskRemoved(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -0800123{
Patrick Williams4a102cd2025-02-27 14:52:54 -0500124 return getLog(redfish::registries::TaskEvent::Index::taskRemoved,
Ed Tanousf175c282024-12-02 15:12:50 -0800125 std::to_array({arg1}));
126}
127
128/**
129 * @internal
130 * @brief Formats TaskPaused message into JSON
131 *
132 * See header file for more information
133 * @endinternal
134 */
Ed Tanous10cf50d2025-05-06 16:10:32 -0700135nlohmann::json::object_t taskPaused(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -0800136{
Patrick Williams4a102cd2025-02-27 14:52:54 -0500137 return getLog(redfish::registries::TaskEvent::Index::taskPaused,
Ed Tanousf175c282024-12-02 15:12:50 -0800138 std::to_array({arg1}));
139}
140
141/**
142 * @internal
143 * @brief Formats TaskResumed message into JSON
144 *
145 * See header file for more information
146 * @endinternal
147 */
Ed Tanous10cf50d2025-05-06 16:10:32 -0700148nlohmann::json::object_t taskResumed(std::string_view arg1)
Ed Tanousf175c282024-12-02 15:12:50 -0800149{
Patrick Williams4a102cd2025-02-27 14:52:54 -0500150 return getLog(redfish::registries::TaskEvent::Index::taskResumed,
Ed Tanousf175c282024-12-02 15:12:50 -0800151 std::to_array({arg1}));
152}
153
154/**
155 * @internal
156 * @brief Formats TaskProgressChanged message into JSON
157 *
158 * See header file for more information
159 * @endinternal
160 */
Ed Tanous10cf50d2025-05-06 16:10:32 -0700161nlohmann::json::object_t taskProgressChanged(std::string_view arg1,
162 uint64_t arg2)
Ed Tanousf175c282024-12-02 15:12:50 -0800163{
164 std::string arg2Str = std::to_string(arg2);
Patrick Williams4a102cd2025-02-27 14:52:54 -0500165 return getLog(redfish::registries::TaskEvent::Index::taskProgressChanged,
Ed Tanousf175c282024-12-02 15:12:50 -0800166 std::to_array<std::string_view>({arg1, arg2Str}));
167}
168
169} // namespace messages
170} // namespace redfish