// // Created by stephane bourque on 2022-04-01. // #pragma once #include "RESTObjects/RESTAPI_ProvObjects.h" #include "framework/KafkaManager.h" #include "framework/KafkaTopics.h" namespace OpenWifi { enum ProvisioningOperation { creation = 0, modification, removal }; template inline bool UpdateKafkaProvisioningObject(ProvisioningOperation op, const ObjectType &obj) { static std::vector Ops{"creation", "modification", "removal"}; std::string OT{"object"}; if constexpr (std::is_same_v) { OT = "Venue"; } if constexpr (std::is_same_v) { OT = "Entity"; } if constexpr (std::is_same_v) { OT = "InventoryTag"; } if constexpr (std::is_same_v) { OT = "Contact"; } if constexpr (std::is_same_v) { OT = "Location"; } if constexpr (std::is_same_v) { OT = "DeviceConfiguration"; } Poco::JSON::Object Payload; obj.to_json(Payload); Payload.set("ObjectType", OT); std::ostringstream OS; Payload.stringify(OS); KafkaManager()->PostMessage(KafkaTopics::PROVISIONING_CHANGE, Ops[op], OS.str()); return true; } } // namespace OpenWifi