xref: /openbmc/bmcweb/features/redfish/src/task_messages.cpp (revision 10cf50dca112b27176dc5734126983ad37ba2c04)
1f175c280SEd Tanous /****************************************************************
2f175c280SEd Tanous  *                 READ THIS WARNING FIRST
3f175c280SEd Tanous  * This is an auto-generated header which contains definitions
4f175c280SEd Tanous  * for Redfish DMTF defined messages.
5f175c280SEd Tanous  * DO NOT modify this registry outside of running the
6f175c280SEd Tanous  * parse_registries.py script.  The definitions contained within
7f175c280SEd Tanous  * this file are owned by DMTF.  Any modifications to these files
8f175c280SEd Tanous  * should be first pushed to the relevant registry in the DMTF
9f175c280SEd Tanous  * github organization.
10f175c280SEd Tanous  ***************************************************************/
11f175c280SEd Tanous #include "task_messages.hpp"
12f175c280SEd Tanous 
13f175c280SEd Tanous #include "registries.hpp"
14f175c280SEd Tanous #include "registries/task_event_message_registry.hpp"
15f175c280SEd Tanous 
16f175c280SEd Tanous #include <nlohmann/json.hpp>
17f175c280SEd Tanous 
18f175c280SEd Tanous #include <array>
19f175c280SEd Tanous #include <cstddef>
20f175c280SEd Tanous #include <cstdint>
21f175c280SEd Tanous #include <span>
22f175c280SEd Tanous #include <string>
23f175c280SEd Tanous #include <string_view>
24f175c280SEd Tanous 
25f175c280SEd Tanous // Clang can't seem to decide whether this header needs to be included or not,
26f175c280SEd Tanous // and is inconsistent.  Include it for now
27f175c280SEd Tanous // NOLINTNEXTLINE(misc-include-cleaner)
28f175c280SEd Tanous #include <utility>
29f175c280SEd Tanous 
30f175c280SEd Tanous namespace redfish
31f175c280SEd Tanous {
32f175c280SEd Tanous 
33f175c280SEd Tanous namespace messages
34f175c280SEd Tanous {
35f175c280SEd Tanous 
36*10cf50dcSEd Tanous static nlohmann::json::object_t getLog(
37*10cf50dcSEd Tanous     redfish::registries::TaskEvent::Index name,
38f175c280SEd Tanous     std::span<const std::string_view> args)
39f175c280SEd Tanous {
40f175c280SEd Tanous     size_t index = static_cast<size_t>(name);
414a102cd4SPatrick Williams     if (index >= redfish::registries::TaskEvent::registry.size())
42f175c280SEd Tanous     {
43f175c280SEd Tanous         return {};
44f175c280SEd Tanous     }
454a102cd4SPatrick Williams     return getLogFromRegistry(redfish::registries::TaskEvent::header,
464a102cd4SPatrick Williams                               redfish::registries::TaskEvent::registry, index,
47f175c280SEd Tanous                               args);
48f175c280SEd Tanous }
49f175c280SEd Tanous 
50f175c280SEd Tanous /**
51f175c280SEd Tanous  * @internal
52f175c280SEd Tanous  * @brief Formats TaskStarted message into JSON
53f175c280SEd Tanous  *
54f175c280SEd Tanous  * See header file for more information
55f175c280SEd Tanous  * @endinternal
56f175c280SEd Tanous  */
57*10cf50dcSEd Tanous nlohmann::json::object_t taskStarted(std::string_view arg1)
58f175c280SEd Tanous {
594a102cd4SPatrick Williams     return getLog(redfish::registries::TaskEvent::Index::taskStarted,
60f175c280SEd Tanous                   std::to_array({arg1}));
61f175c280SEd Tanous }
62f175c280SEd Tanous 
63f175c280SEd Tanous /**
64f175c280SEd Tanous  * @internal
65f175c280SEd Tanous  * @brief Formats TaskCompletedOK message into JSON
66f175c280SEd Tanous  *
67f175c280SEd Tanous  * See header file for more information
68f175c280SEd Tanous  * @endinternal
69f175c280SEd Tanous  */
70*10cf50dcSEd Tanous nlohmann::json::object_t taskCompletedOK(std::string_view arg1)
71f175c280SEd Tanous {
724a102cd4SPatrick Williams     return getLog(redfish::registries::TaskEvent::Index::taskCompletedOK,
73f175c280SEd Tanous                   std::to_array({arg1}));
74f175c280SEd Tanous }
75f175c280SEd Tanous 
76f175c280SEd Tanous /**
77f175c280SEd Tanous  * @internal
78f175c280SEd Tanous  * @brief Formats TaskCompletedWarning message into JSON
79f175c280SEd Tanous  *
80f175c280SEd Tanous  * See header file for more information
81f175c280SEd Tanous  * @endinternal
82f175c280SEd Tanous  */
83*10cf50dcSEd Tanous nlohmann::json::object_t taskCompletedWarning(std::string_view arg1)
84f175c280SEd Tanous {
854a102cd4SPatrick Williams     return getLog(redfish::registries::TaskEvent::Index::taskCompletedWarning,
86f175c280SEd Tanous                   std::to_array({arg1}));
87f175c280SEd Tanous }
88f175c280SEd Tanous 
89f175c280SEd Tanous /**
90f175c280SEd Tanous  * @internal
91f175c280SEd Tanous  * @brief Formats TaskAborted message into JSON
92f175c280SEd Tanous  *
93f175c280SEd Tanous  * See header file for more information
94f175c280SEd Tanous  * @endinternal
95f175c280SEd Tanous  */
96*10cf50dcSEd Tanous nlohmann::json::object_t taskAborted(std::string_view arg1)
97f175c280SEd Tanous {
984a102cd4SPatrick Williams     return getLog(redfish::registries::TaskEvent::Index::taskAborted,
99f175c280SEd Tanous                   std::to_array({arg1}));
100f175c280SEd Tanous }
101f175c280SEd Tanous 
102f175c280SEd Tanous /**
103f175c280SEd Tanous  * @internal
104f175c280SEd Tanous  * @brief Formats TaskCancelled message into JSON
105f175c280SEd Tanous  *
106f175c280SEd Tanous  * See header file for more information
107f175c280SEd Tanous  * @endinternal
108f175c280SEd Tanous  */
109*10cf50dcSEd Tanous nlohmann::json::object_t taskCancelled(std::string_view arg1)
110f175c280SEd Tanous {
1114a102cd4SPatrick Williams     return getLog(redfish::registries::TaskEvent::Index::taskCancelled,
112f175c280SEd Tanous                   std::to_array({arg1}));
113f175c280SEd Tanous }
114f175c280SEd Tanous 
115f175c280SEd Tanous /**
116f175c280SEd Tanous  * @internal
117f175c280SEd Tanous  * @brief Formats TaskRemoved message into JSON
118f175c280SEd Tanous  *
119f175c280SEd Tanous  * See header file for more information
120f175c280SEd Tanous  * @endinternal
121f175c280SEd Tanous  */
122*10cf50dcSEd Tanous nlohmann::json::object_t taskRemoved(std::string_view arg1)
123f175c280SEd Tanous {
1244a102cd4SPatrick Williams     return getLog(redfish::registries::TaskEvent::Index::taskRemoved,
125f175c280SEd Tanous                   std::to_array({arg1}));
126f175c280SEd Tanous }
127f175c280SEd Tanous 
128f175c280SEd Tanous /**
129f175c280SEd Tanous  * @internal
130f175c280SEd Tanous  * @brief Formats TaskPaused message into JSON
131f175c280SEd Tanous  *
132f175c280SEd Tanous  * See header file for more information
133f175c280SEd Tanous  * @endinternal
134f175c280SEd Tanous  */
135*10cf50dcSEd Tanous nlohmann::json::object_t taskPaused(std::string_view arg1)
136f175c280SEd Tanous {
1374a102cd4SPatrick Williams     return getLog(redfish::registries::TaskEvent::Index::taskPaused,
138f175c280SEd Tanous                   std::to_array({arg1}));
139f175c280SEd Tanous }
140f175c280SEd Tanous 
141f175c280SEd Tanous /**
142f175c280SEd Tanous  * @internal
143f175c280SEd Tanous  * @brief Formats TaskResumed message into JSON
144f175c280SEd Tanous  *
145f175c280SEd Tanous  * See header file for more information
146f175c280SEd Tanous  * @endinternal
147f175c280SEd Tanous  */
148*10cf50dcSEd Tanous nlohmann::json::object_t taskResumed(std::string_view arg1)
149f175c280SEd Tanous {
1504a102cd4SPatrick Williams     return getLog(redfish::registries::TaskEvent::Index::taskResumed,
151f175c280SEd Tanous                   std::to_array({arg1}));
152f175c280SEd Tanous }
153f175c280SEd Tanous 
154f175c280SEd Tanous /**
155f175c280SEd Tanous  * @internal
156f175c280SEd Tanous  * @brief Formats TaskProgressChanged message into JSON
157f175c280SEd Tanous  *
158f175c280SEd Tanous  * See header file for more information
159f175c280SEd Tanous  * @endinternal
160f175c280SEd Tanous  */
161*10cf50dcSEd Tanous nlohmann::json::object_t taskProgressChanged(std::string_view arg1,
162*10cf50dcSEd Tanous                                              uint64_t arg2)
163f175c280SEd Tanous {
164f175c280SEd Tanous     std::string arg2Str = std::to_string(arg2);
1654a102cd4SPatrick Williams     return getLog(redfish::registries::TaskEvent::Index::taskProgressChanged,
166f175c280SEd Tanous                   std::to_array<std::string_view>({arg1, arg2Str}));
167f175c280SEd Tanous }
168f175c280SEd Tanous 
169f175c280SEd Tanous } // namespace messages
170f175c280SEd Tanous } // namespace redfish
171