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