xref: /openbmc/bmcweb/redfish-core/src/task_messages.cpp (revision 2ca561945f9c518e4916cd23c194f89816fdbeee)
1 /****************************************************************
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 <span>
21 #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)
26 #include <cstdint>
27 // NOLINTNEXTLINE(misc-include-cleaner)
28 #include <string>
29 // NOLINTNEXTLINE(misc-include-cleaner)
30 #include <utility>
31 
32 namespace redfish
33 {
34 
35 namespace messages
36 {
37 
getLog(redfish::registries::TaskEvent::Index name,std::span<const std::string_view> args)38 static nlohmann::json::object_t getLog(
39     redfish::registries::TaskEvent::Index name,
40     std::span<const std::string_view> args)
41 {
42     size_t index = static_cast<size_t>(name);
43     if (index >= redfish::registries::TaskEvent::registry.size())
44     {
45         return {};
46     }
47     return getLogFromRegistry(redfish::registries::TaskEvent::header,
48                               redfish::registries::TaskEvent::registry, index,
49                               args);
50 }
51 
52 /**
53  * @internal
54  * @brief Formats TaskStarted message into JSON
55  *
56  * See header file for more information
57  * @endinternal
58  */
taskStarted(std::string_view arg1)59 nlohmann::json::object_t taskStarted(std::string_view arg1)
60 {
61     return getLog(redfish::registries::TaskEvent::Index::taskStarted,
62                   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  */
taskCompletedOK(std::string_view arg1)72 nlohmann::json::object_t taskCompletedOK(std::string_view arg1)
73 {
74     return getLog(redfish::registries::TaskEvent::Index::taskCompletedOK,
75                   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  */
taskCompletedWarning(std::string_view arg1)85 nlohmann::json::object_t taskCompletedWarning(std::string_view arg1)
86 {
87     return getLog(redfish::registries::TaskEvent::Index::taskCompletedWarning,
88                   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  */
taskAborted(std::string_view arg1)98 nlohmann::json::object_t taskAborted(std::string_view arg1)
99 {
100     return getLog(redfish::registries::TaskEvent::Index::taskAborted,
101                   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  */
taskCancelled(std::string_view arg1)111 nlohmann::json::object_t taskCancelled(std::string_view arg1)
112 {
113     return getLog(redfish::registries::TaskEvent::Index::taskCancelled,
114                   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  */
taskRemoved(std::string_view arg1)124 nlohmann::json::object_t taskRemoved(std::string_view arg1)
125 {
126     return getLog(redfish::registries::TaskEvent::Index::taskRemoved,
127                   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  */
taskPaused(std::string_view arg1)137 nlohmann::json::object_t taskPaused(std::string_view arg1)
138 {
139     return getLog(redfish::registries::TaskEvent::Index::taskPaused,
140                   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  */
taskResumed(std::string_view arg1)150 nlohmann::json::object_t taskResumed(std::string_view arg1)
151 {
152     return getLog(redfish::registries::TaskEvent::Index::taskResumed,
153                   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  */
taskProgressChanged(std::string_view arg1,uint64_t arg2)163 nlohmann::json::object_t taskProgressChanged(std::string_view arg1,
164                                              uint64_t arg2)
165 {
166     std::string arg2Str = std::to_string(arg2);
167     return getLog(redfish::registries::TaskEvent::Index::taskProgressChanged,
168                   std::to_array<std::string_view>({arg1, arg2Str}));
169 }
170 
171 } // namespace messages
172 } // namespace redfish
173