xref: /openbmc/bmcweb/features/redfish/src/resource_messages.cpp (revision 10cf50dca112b27176dc5734126983ad37ba2c04)
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 "resource_messages.hpp"
12 
13 #include "registries.hpp"
14 #include "registries/resource_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 <utility>
27 
28 namespace redfish
29 {
30 
31 namespace messages
32 {
33 
34 static nlohmann::json::object_t getLog(
35     redfish::registries::ResourceEvent::Index name,
36     std::span<const std::string_view> args)
37 {
38     size_t index = static_cast<size_t>(name);
39     if (index >= redfish::registries::ResourceEvent::registry.size())
40     {
41         return {};
42     }
43     return getLogFromRegistry(redfish::registries::ResourceEvent::header,
44                               redfish::registries::ResourceEvent::registry,
45                               index, args);
46 }
47 
48 /**
49  * @internal
50  * @brief Formats ResourceCreated message into JSON
51  *
52  * See header file for more information
53  * @endinternal
54  */
55 nlohmann::json::object_t resourceCreated()
56 {
57     return getLog(redfish::registries::ResourceEvent::Index::resourceCreated,
58                   {});
59 }
60 
61 /**
62  * @internal
63  * @brief Formats ResourceRemoved message into JSON
64  *
65  * See header file for more information
66  * @endinternal
67  */
68 nlohmann::json::object_t resourceRemoved()
69 {
70     return getLog(redfish::registries::ResourceEvent::Index::resourceRemoved,
71                   {});
72 }
73 
74 /**
75  * @internal
76  * @brief Formats ResourceErrorsDetected message into JSON
77  *
78  * See header file for more information
79  * @endinternal
80  */
81 nlohmann::json::object_t resourceErrorsDetected(std::string_view arg1,
82                                                 std::string_view arg2)
83 {
84     return getLog(
85         redfish::registries::ResourceEvent::Index::resourceErrorsDetected,
86         std::to_array({arg1, arg2}));
87 }
88 
89 /**
90  * @internal
91  * @brief Formats ResourceErrorsCorrected message into JSON
92  *
93  * See header file for more information
94  * @endinternal
95  */
96 nlohmann::json::object_t resourceErrorsCorrected(std::string_view arg1,
97                                                  std::string_view arg2)
98 {
99     return getLog(
100         redfish::registries::ResourceEvent::Index::resourceErrorsCorrected,
101         std::to_array({arg1, arg2}));
102 }
103 
104 /**
105  * @internal
106  * @brief Formats ResourceErrorThresholdExceeded message into JSON
107  *
108  * See header file for more information
109  * @endinternal
110  */
111 nlohmann::json::object_t resourceErrorThresholdExceeded(std::string_view arg1,
112                                                         std::string_view arg2)
113 {
114     return getLog(redfish::registries::ResourceEvent::Index::
115                       resourceErrorThresholdExceeded,
116                   std::to_array({arg1, arg2}));
117 }
118 
119 /**
120  * @internal
121  * @brief Formats ResourceErrorThresholdCleared message into JSON
122  *
123  * See header file for more information
124  * @endinternal
125  */
126 nlohmann::json::object_t resourceErrorThresholdCleared(std::string_view arg1,
127                                                        std::string_view arg2)
128 {
129     return getLog(redfish::registries::ResourceEvent::Index::
130                       resourceErrorThresholdCleared,
131                   std::to_array({arg1, arg2}));
132 }
133 
134 /**
135  * @internal
136  * @brief Formats ResourceWarningThresholdExceeded message into JSON
137  *
138  * See header file for more information
139  * @endinternal
140  */
141 nlohmann::json::object_t resourceWarningThresholdExceeded(std::string_view arg1,
142                                                           std::string_view arg2)
143 {
144     return getLog(redfish::registries::ResourceEvent::Index::
145                       resourceWarningThresholdExceeded,
146                   std::to_array({arg1, arg2}));
147 }
148 
149 /**
150  * @internal
151  * @brief Formats ResourceWarningThresholdCleared message into JSON
152  *
153  * See header file for more information
154  * @endinternal
155  */
156 nlohmann::json::object_t resourceWarningThresholdCleared(std::string_view arg1,
157                                                          std::string_view arg2)
158 {
159     return getLog(redfish::registries::ResourceEvent::Index::
160                       resourceWarningThresholdCleared,
161                   std::to_array({arg1, arg2}));
162 }
163 
164 /**
165  * @internal
166  * @brief Formats ResourceStatusChangedOK message into JSON
167  *
168  * See header file for more information
169  * @endinternal
170  */
171 nlohmann::json::object_t resourceStatusChangedOK(std::string_view arg1,
172                                                  std::string_view arg2)
173 {
174     return getLog(
175         redfish::registries::ResourceEvent::Index::resourceStatusChangedOK,
176         std::to_array({arg1, arg2}));
177 }
178 
179 /**
180  * @internal
181  * @brief Formats ResourceStatusChangedWarning message into JSON
182  *
183  * See header file for more information
184  * @endinternal
185  */
186 nlohmann::json::object_t resourceStatusChangedWarning(std::string_view arg1,
187                                                       std::string_view arg2)
188 {
189     return getLog(
190         redfish::registries::ResourceEvent::Index::resourceStatusChangedWarning,
191         std::to_array({arg1, arg2}));
192 }
193 
194 /**
195  * @internal
196  * @brief Formats ResourceStatusChangedCritical message into JSON
197  *
198  * See header file for more information
199  * @endinternal
200  */
201 nlohmann::json::object_t resourceStatusChangedCritical(std::string_view arg1,
202                                                        std::string_view arg2)
203 {
204     return getLog(redfish::registries::ResourceEvent::Index::
205                       resourceStatusChangedCritical,
206                   std::to_array({arg1, arg2}));
207 }
208 
209 /**
210  * @internal
211  * @brief Formats ResourceStateChanged message into JSON
212  *
213  * See header file for more information
214  * @endinternal
215  */
216 nlohmann::json::object_t resourceStateChanged(std::string_view arg1,
217                                               std::string_view arg2)
218 {
219     return getLog(
220         redfish::registries::ResourceEvent::Index::resourceStateChanged,
221         std::to_array({arg1, arg2}));
222 }
223 
224 /**
225  * @internal
226  * @brief Formats ResourcePoweredOn message into JSON
227  *
228  * See header file for more information
229  * @endinternal
230  */
231 nlohmann::json::object_t resourcePoweredOn(std::string_view arg1)
232 {
233     return getLog(redfish::registries::ResourceEvent::Index::resourcePoweredOn,
234                   std::to_array({arg1}));
235 }
236 
237 /**
238  * @internal
239  * @brief Formats ResourcePoweringOn message into JSON
240  *
241  * See header file for more information
242  * @endinternal
243  */
244 nlohmann::json::object_t resourcePoweringOn(std::string_view arg1)
245 {
246     return getLog(redfish::registries::ResourceEvent::Index::resourcePoweringOn,
247                   std::to_array({arg1}));
248 }
249 
250 /**
251  * @internal
252  * @brief Formats ResourcePoweredOff message into JSON
253  *
254  * See header file for more information
255  * @endinternal
256  */
257 nlohmann::json::object_t resourcePoweredOff(std::string_view arg1)
258 {
259     return getLog(redfish::registries::ResourceEvent::Index::resourcePoweredOff,
260                   std::to_array({arg1}));
261 }
262 
263 /**
264  * @internal
265  * @brief Formats ResourcePoweringOff message into JSON
266  *
267  * See header file for more information
268  * @endinternal
269  */
270 nlohmann::json::object_t resourcePoweringOff(std::string_view arg1)
271 {
272     return getLog(
273         redfish::registries::ResourceEvent::Index::resourcePoweringOff,
274         std::to_array({arg1}));
275 }
276 
277 /**
278  * @internal
279  * @brief Formats ResourcePaused message into JSON
280  *
281  * See header file for more information
282  * @endinternal
283  */
284 nlohmann::json::object_t resourcePaused(std::string_view arg1)
285 {
286     return getLog(redfish::registries::ResourceEvent::Index::resourcePaused,
287                   std::to_array({arg1}));
288 }
289 
290 /**
291  * @internal
292  * @brief Formats URIForResourceChanged message into JSON
293  *
294  * See header file for more information
295  * @endinternal
296  */
297 nlohmann::json::object_t uRIForResourceChanged()
298 {
299     return getLog(
300         redfish::registries::ResourceEvent::Index::uRIForResourceChanged, {});
301 }
302 
303 /**
304  * @internal
305  * @brief Formats ResourceChanged message into JSON
306  *
307  * See header file for more information
308  * @endinternal
309  */
310 nlohmann::json::object_t resourceChanged()
311 {
312     return getLog(redfish::registries::ResourceEvent::Index::resourceChanged,
313                   {});
314 }
315 
316 /**
317  * @internal
318  * @brief Formats ResourceVersionIncompatible message into JSON
319  *
320  * See header file for more information
321  * @endinternal
322  */
323 nlohmann::json::object_t resourceVersionIncompatible(std::string_view arg1)
324 {
325     return getLog(
326         redfish::registries::ResourceEvent::Index::resourceVersionIncompatible,
327         std::to_array({arg1}));
328 }
329 
330 /**
331  * @internal
332  * @brief Formats ResourceSelfTestFailed message into JSON
333  *
334  * See header file for more information
335  * @endinternal
336  */
337 nlohmann::json::object_t resourceSelfTestFailed(std::string_view arg1)
338 {
339     return getLog(
340         redfish::registries::ResourceEvent::Index::resourceSelfTestFailed,
341         std::to_array({arg1}));
342 }
343 
344 /**
345  * @internal
346  * @brief Formats ResourceSelfTestCompleted message into JSON
347  *
348  * See header file for more information
349  * @endinternal
350  */
351 nlohmann::json::object_t resourceSelfTestCompleted()
352 {
353     return getLog(
354         redfish::registries::ResourceEvent::Index::resourceSelfTestCompleted,
355         {});
356 }
357 
358 /**
359  * @internal
360  * @brief Formats TestMessage message into JSON
361  *
362  * See header file for more information
363  * @endinternal
364  */
365 nlohmann::json::object_t testMessage()
366 {
367     return getLog(redfish::registries::ResourceEvent::Index::testMessage, {});
368 }
369 
370 /**
371  * @internal
372  * @brief Formats AggregationSourceDiscovered message into JSON
373  *
374  * See header file for more information
375  * @endinternal
376  */
377 nlohmann::json::object_t aggregationSourceDiscovered(std::string_view arg1,
378                                                      std::string_view arg2)
379 {
380     return getLog(
381         redfish::registries::ResourceEvent::Index::aggregationSourceDiscovered,
382         std::to_array({arg1, arg2}));
383 }
384 
385 /**
386  * @internal
387  * @brief Formats LicenseExpired message into JSON
388  *
389  * See header file for more information
390  * @endinternal
391  */
392 nlohmann::json::object_t licenseExpired(std::string_view arg1,
393                                         std::string_view arg2)
394 {
395     return getLog(redfish::registries::ResourceEvent::Index::licenseExpired,
396                   std::to_array({arg1, arg2}));
397 }
398 
399 /**
400  * @internal
401  * @brief Formats LicenseChanged message into JSON
402  *
403  * See header file for more information
404  * @endinternal
405  */
406 nlohmann::json::object_t licenseChanged(std::string_view arg1,
407                                         std::string_view arg2)
408 {
409     return getLog(redfish::registries::ResourceEvent::Index::licenseChanged,
410                   std::to_array({arg1, arg2}));
411 }
412 
413 /**
414  * @internal
415  * @brief Formats LicenseAdded message into JSON
416  *
417  * See header file for more information
418  * @endinternal
419  */
420 nlohmann::json::object_t licenseAdded(std::string_view arg1,
421                                       std::string_view arg2)
422 {
423     return getLog(redfish::registries::ResourceEvent::Index::licenseAdded,
424                   std::to_array({arg1, arg2}));
425 }
426 
427 } // namespace messages
428 } // namespace redfish
429