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*4a102cd4SPatrick Williams static nlohmann::json getLog(redfish::registries::TaskEvent::Index name, 37f175c280SEd Tanous std::span<const std::string_view> args) 38f175c280SEd Tanous { 39f175c280SEd Tanous size_t index = static_cast<size_t>(name); 40*4a102cd4SPatrick Williams if (index >= redfish::registries::TaskEvent::registry.size()) 41f175c280SEd Tanous { 42f175c280SEd Tanous return {}; 43f175c280SEd Tanous } 44*4a102cd4SPatrick Williams return getLogFromRegistry(redfish::registries::TaskEvent::header, 45*4a102cd4SPatrick Williams redfish::registries::TaskEvent::registry, index, 46f175c280SEd Tanous args); 47f175c280SEd Tanous } 48f175c280SEd Tanous 49f175c280SEd Tanous /** 50f175c280SEd Tanous * @internal 51f175c280SEd Tanous * @brief Formats TaskStarted message into JSON 52f175c280SEd Tanous * 53f175c280SEd Tanous * See header file for more information 54f175c280SEd Tanous * @endinternal 55f175c280SEd Tanous */ 56f175c280SEd Tanous nlohmann::json taskStarted(std::string_view arg1) 57f175c280SEd Tanous { 58*4a102cd4SPatrick Williams return getLog(redfish::registries::TaskEvent::Index::taskStarted, 59f175c280SEd Tanous std::to_array({arg1})); 60f175c280SEd Tanous } 61f175c280SEd Tanous 62f175c280SEd Tanous /** 63f175c280SEd Tanous * @internal 64f175c280SEd Tanous * @brief Formats TaskCompletedOK message into JSON 65f175c280SEd Tanous * 66f175c280SEd Tanous * See header file for more information 67f175c280SEd Tanous * @endinternal 68f175c280SEd Tanous */ 69f175c280SEd Tanous nlohmann::json taskCompletedOK(std::string_view arg1) 70f175c280SEd Tanous { 71*4a102cd4SPatrick Williams return getLog(redfish::registries::TaskEvent::Index::taskCompletedOK, 72f175c280SEd Tanous std::to_array({arg1})); 73f175c280SEd Tanous } 74f175c280SEd Tanous 75f175c280SEd Tanous /** 76f175c280SEd Tanous * @internal 77f175c280SEd Tanous * @brief Formats TaskCompletedWarning message into JSON 78f175c280SEd Tanous * 79f175c280SEd Tanous * See header file for more information 80f175c280SEd Tanous * @endinternal 81f175c280SEd Tanous */ 82f175c280SEd Tanous nlohmann::json taskCompletedWarning(std::string_view arg1) 83f175c280SEd Tanous { 84*4a102cd4SPatrick Williams return getLog(redfish::registries::TaskEvent::Index::taskCompletedWarning, 85f175c280SEd Tanous std::to_array({arg1})); 86f175c280SEd Tanous } 87f175c280SEd Tanous 88f175c280SEd Tanous /** 89f175c280SEd Tanous * @internal 90f175c280SEd Tanous * @brief Formats TaskAborted message into JSON 91f175c280SEd Tanous * 92f175c280SEd Tanous * See header file for more information 93f175c280SEd Tanous * @endinternal 94f175c280SEd Tanous */ 95f175c280SEd Tanous nlohmann::json taskAborted(std::string_view arg1) 96f175c280SEd Tanous { 97*4a102cd4SPatrick Williams return getLog(redfish::registries::TaskEvent::Index::taskAborted, 98f175c280SEd Tanous std::to_array({arg1})); 99f175c280SEd Tanous } 100f175c280SEd Tanous 101f175c280SEd Tanous /** 102f175c280SEd Tanous * @internal 103f175c280SEd Tanous * @brief Formats TaskCancelled message into JSON 104f175c280SEd Tanous * 105f175c280SEd Tanous * See header file for more information 106f175c280SEd Tanous * @endinternal 107f175c280SEd Tanous */ 108f175c280SEd Tanous nlohmann::json taskCancelled(std::string_view arg1) 109f175c280SEd Tanous { 110*4a102cd4SPatrick Williams return getLog(redfish::registries::TaskEvent::Index::taskCancelled, 111f175c280SEd Tanous std::to_array({arg1})); 112f175c280SEd Tanous } 113f175c280SEd Tanous 114f175c280SEd Tanous /** 115f175c280SEd Tanous * @internal 116f175c280SEd Tanous * @brief Formats TaskRemoved message into JSON 117f175c280SEd Tanous * 118f175c280SEd Tanous * See header file for more information 119f175c280SEd Tanous * @endinternal 120f175c280SEd Tanous */ 121f175c280SEd Tanous nlohmann::json taskRemoved(std::string_view arg1) 122f175c280SEd Tanous { 123*4a102cd4SPatrick Williams return getLog(redfish::registries::TaskEvent::Index::taskRemoved, 124f175c280SEd Tanous std::to_array({arg1})); 125f175c280SEd Tanous } 126f175c280SEd Tanous 127f175c280SEd Tanous /** 128f175c280SEd Tanous * @internal 129f175c280SEd Tanous * @brief Formats TaskPaused message into JSON 130f175c280SEd Tanous * 131f175c280SEd Tanous * See header file for more information 132f175c280SEd Tanous * @endinternal 133f175c280SEd Tanous */ 134f175c280SEd Tanous nlohmann::json taskPaused(std::string_view arg1) 135f175c280SEd Tanous { 136*4a102cd4SPatrick Williams return getLog(redfish::registries::TaskEvent::Index::taskPaused, 137f175c280SEd Tanous std::to_array({arg1})); 138f175c280SEd Tanous } 139f175c280SEd Tanous 140f175c280SEd Tanous /** 141f175c280SEd Tanous * @internal 142f175c280SEd Tanous * @brief Formats TaskResumed message into JSON 143f175c280SEd Tanous * 144f175c280SEd Tanous * See header file for more information 145f175c280SEd Tanous * @endinternal 146f175c280SEd Tanous */ 147f175c280SEd Tanous nlohmann::json taskResumed(std::string_view arg1) 148f175c280SEd Tanous { 149*4a102cd4SPatrick Williams return getLog(redfish::registries::TaskEvent::Index::taskResumed, 150f175c280SEd Tanous std::to_array({arg1})); 151f175c280SEd Tanous } 152f175c280SEd Tanous 153f175c280SEd Tanous /** 154f175c280SEd Tanous * @internal 155f175c280SEd Tanous * @brief Formats TaskProgressChanged message into JSON 156f175c280SEd Tanous * 157f175c280SEd Tanous * See header file for more information 158f175c280SEd Tanous * @endinternal 159f175c280SEd Tanous */ 160f175c280SEd Tanous nlohmann::json taskProgressChanged(std::string_view arg1, uint64_t arg2) 161f175c280SEd Tanous { 162f175c280SEd Tanous std::string arg2Str = std::to_string(arg2); 163*4a102cd4SPatrick Williams return getLog(redfish::registries::TaskEvent::Index::taskProgressChanged, 164f175c280SEd Tanous std::to_array<std::string_view>({arg1, arg2Str})); 165f175c280SEd Tanous } 166f175c280SEd Tanous 167f175c280SEd Tanous } // namespace messages 168f175c280SEd Tanous } // namespace redfish 169