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 <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 30 namespace redfish 31 { 32 33 namespace messages 34 { 35 36 static nlohmann::json::object_t getLog( 37 redfish::registries::TaskEvent::Index name, 38 std::span<const std::string_view> args) 39 { 40 size_t index = static_cast<size_t>(name); 41 if (index >= redfish::registries::TaskEvent::registry.size()) 42 { 43 return {}; 44 } 45 return getLogFromRegistry(redfish::registries::TaskEvent::header, 46 redfish::registries::TaskEvent::registry, index, 47 args); 48 } 49 50 /** 51 * @internal 52 * @brief Formats TaskStarted message into JSON 53 * 54 * See header file for more information 55 * @endinternal 56 */ 57 nlohmann::json::object_t taskStarted(std::string_view arg1) 58 { 59 return getLog(redfish::registries::TaskEvent::Index::taskStarted, 60 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 */ 70 nlohmann::json::object_t taskCompletedOK(std::string_view arg1) 71 { 72 return getLog(redfish::registries::TaskEvent::Index::taskCompletedOK, 73 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 */ 83 nlohmann::json::object_t taskCompletedWarning(std::string_view arg1) 84 { 85 return getLog(redfish::registries::TaskEvent::Index::taskCompletedWarning, 86 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 */ 96 nlohmann::json::object_t taskAborted(std::string_view arg1) 97 { 98 return getLog(redfish::registries::TaskEvent::Index::taskAborted, 99 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 */ 109 nlohmann::json::object_t taskCancelled(std::string_view arg1) 110 { 111 return getLog(redfish::registries::TaskEvent::Index::taskCancelled, 112 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 */ 122 nlohmann::json::object_t taskRemoved(std::string_view arg1) 123 { 124 return getLog(redfish::registries::TaskEvent::Index::taskRemoved, 125 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 */ 135 nlohmann::json::object_t taskPaused(std::string_view arg1) 136 { 137 return getLog(redfish::registries::TaskEvent::Index::taskPaused, 138 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 */ 148 nlohmann::json::object_t taskResumed(std::string_view arg1) 149 { 150 return getLog(redfish::registries::TaskEvent::Index::taskResumed, 151 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 */ 161 nlohmann::json::object_t taskProgressChanged(std::string_view arg1, 162 uint64_t arg2) 163 { 164 std::string arg2Str = std::to_string(arg2); 165 return getLog(redfish::registries::TaskEvent::Index::taskProgressChanged, 166 std::to_array<std::string_view>({arg1, arg2Str})); 167 } 168 169 } // namespace messages 170 } // namespace redfish 171