diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d5fd29..fe15290 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,7 @@ add_executable(owsub src/APIServers.cpp src/Daemon.cpp src/Daemon.h src/Dashboard.h src/Dashboard.cpp - src/StorageService.cpp src/StorageService.h) + src/StorageService.cpp src/StorageService.h src/RESTAPI/RESTAPI_internetConnection_handler.cpp src/RESTAPI/RESTAPI_internetConnection_handler.h src/RESTAPI/RESTAPI_homeDeviceMode_handler.cpp src/RESTAPI/RESTAPI_homeDeviceMode_handler.h src/RESTAPI/RESTAPI_ipReservations_handler.cpp src/RESTAPI/RESTAPI_ipReservations_handler.h src/RESTAPI/RESTAPI_wifiNetworks_handler.cpp src/RESTAPI/RESTAPI_wifiNetworks_handler.h src/RESTAPI/RESTAPI_wiredClients_handler.cpp src/RESTAPI/RESTAPI_wiredClients_handler.h src/RESTAPI/RESTAPI_wifiClients_handler.cpp src/RESTAPI/RESTAPI_wifiClients_handler.h src/RESTAPI/RESTAPI_subscriberDevices_handler.cpp src/RESTAPI/RESTAPI_subscriberDevices_handler.h) target_link_libraries(owsub PUBLIC ${Poco_LIBRARIES} ${MySQL_LIBRARIES} diff --git a/build b/build index 780fea9..eb13855 100644 --- a/build +++ b/build @@ -1 +1 @@ -77 \ No newline at end of file +79 \ No newline at end of file diff --git a/src/APIServers.cpp b/src/APIServers.cpp index 3e2f6ce..db3208b 100644 --- a/src/APIServers.cpp +++ b/src/APIServers.cpp @@ -3,17 +3,33 @@ // #include "framework/MicroService.h" +#include "RESTAPI/RESTAPI_homeDeviceMode_handler.h" +#include "RESTAPI/RESTAPI_internetConnection_handler.h" +#include "RESTAPI/RESTAPI_ipReservations_handler.h" +#include "RESTAPI/RESTAPI_subscriberDevices_handler.h" +#include "RESTAPI/RESTAPI_wifiClients_handler.h" +#include "RESTAPI/RESTAPI_wifiNetworks_handler.h" +#include "RESTAPI//RESTAPI_wiredClients_handler.h" namespace OpenWifi { Poco::Net::HTTPRequestHandler * RESTAPI_external_server(const char *Path, RESTAPIHandler::BindingMap &Bindings, Poco::Logger & L, RESTAPI_GenericServer & S) { - return RESTAPI_Router(Path, Bindings, L, S); + return RESTAPI_Router< + RESTAPI_homeDeviceMode_handler, + RESTAPI_internetConnection_handler, + RESTAPI_ipReservations_handler, + RESTAPI_subscriberDevices_handler, + RESTAPI_wifiClients_handler, + RESTAPI_wifiNetworks_handler, + RESTAPI_wiredClients_handler, + RESTAPI_system_command>(Path, Bindings, L, S); } Poco::Net::HTTPRequestHandler * RESTAPI_internal_server(const char *Path, RESTAPIHandler::BindingMap &Bindings, Poco::Logger & L, RESTAPI_GenericServer & S) { - return RESTAPI_Router_I(Path, Bindings, L, S); + return RESTAPI_Router_I< + RESTAPI_system_command>(Path, Bindings, L, S); } } \ No newline at end of file diff --git a/src/RESTAPI/RESTAPI_homeDeviceMode_handler.cpp b/src/RESTAPI/RESTAPI_homeDeviceMode_handler.cpp new file mode 100644 index 0000000..c69b8f7 --- /dev/null +++ b/src/RESTAPI/RESTAPI_homeDeviceMode_handler.cpp @@ -0,0 +1,15 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#include "RESTAPI_homeDeviceMode_handler.h" + +namespace OpenWifi { + void RESTAPI_homeDeviceMode_handler::DoGet() { + + } + + void RESTAPI_homeDeviceMode_handler::DoPut() { + + } +} \ No newline at end of file diff --git a/src/RESTAPI/RESTAPI_homeDeviceMode_handler.h b/src/RESTAPI/RESTAPI_homeDeviceMode_handler.h new file mode 100644 index 0000000..d68f4dd --- /dev/null +++ b/src/RESTAPI/RESTAPI_homeDeviceMode_handler.h @@ -0,0 +1,32 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#ifndef OWSUB_RESTAPI_HOMEDEVICEMODE_HANDLER_H +#define OWSUB_RESTAPI_HOMEDEVICEMODE_HANDLER_H + +#include "framework/MicroService.h" + +namespace OpenWifi { + class RESTAPI_homeDeviceMode_handler : public RESTAPIHandler { + public: + RESTAPI_homeDeviceMode_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, bool Internal) + : RESTAPIHandler(bindings, L, + std::vector{ + Poco::Net::HTTPRequest::HTTP_GET, + Poco::Net::HTTPRequest::HTTP_PUT, + Poco::Net::HTTPRequest::HTTP_OPTIONS}, + Server, + Internal){} + + static const std::list PathName() { return std::list{"/api/v1/homeDeviceMode"}; }; + + void DoGet() final; + void DoPost() final {}; + void DoPut() final; + void DoDelete() final {}; + private: + }; +} + +#endif //OWSUB_RESTAPI_HOMEDEVICEMODE_HANDLER_H diff --git a/src/RESTAPI/RESTAPI_internetConnection_handler.cpp b/src/RESTAPI/RESTAPI_internetConnection_handler.cpp new file mode 100644 index 0000000..a98727e --- /dev/null +++ b/src/RESTAPI/RESTAPI_internetConnection_handler.cpp @@ -0,0 +1,15 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#include "RESTAPI_internetConnection_handler.h" + +namespace OpenWifi { + void RESTAPI_internetConnection_handler::DoGet() { + + } + + void RESTAPI_internetConnection_handler::DoPut() { + + } +} \ No newline at end of file diff --git a/src/RESTAPI/RESTAPI_internetConnection_handler.h b/src/RESTAPI/RESTAPI_internetConnection_handler.h new file mode 100644 index 0000000..e008b90 --- /dev/null +++ b/src/RESTAPI/RESTAPI_internetConnection_handler.h @@ -0,0 +1,33 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#ifndef OWSUB_RESTAPI_INTERNETCONNECTION_HANDLER_H +#define OWSUB_RESTAPI_INTERNETCONNECTION_HANDLER_H + +#include "framework/MicroService.h" + +namespace OpenWifi { + class RESTAPI_internetConnection_handler : public RESTAPIHandler { + public: + RESTAPI_internetConnection_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, bool Internal) + : RESTAPIHandler(bindings, L, + std::vector{ + Poco::Net::HTTPRequest::HTTP_GET, + Poco::Net::HTTPRequest::HTTP_PUT, + Poco::Net::HTTPRequest::HTTP_OPTIONS}, + Server, + Internal){} + + static const std::list PathName() { return std::list{"/api/v1/internetConnection"}; }; + + void DoGet() final; + void DoPost() final {}; + void DoPut() final; + void DoDelete() final {}; + private: + }; +} + + +#endif //OWSUB_RESTAPI_INTERNETCONNECTION_HANDLER_H diff --git a/src/RESTAPI/RESTAPI_ipReservations_handler.cpp b/src/RESTAPI/RESTAPI_ipReservations_handler.cpp new file mode 100644 index 0000000..4d15865 --- /dev/null +++ b/src/RESTAPI/RESTAPI_ipReservations_handler.cpp @@ -0,0 +1,15 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#include "RESTAPI_ipReservations_handler.h" + +namespace OpenWifi { + void RESTAPI_ipReservations_handler::DoGet() { + + } + + void RESTAPI_ipReservations_handler::DoPut() { + + } +} \ No newline at end of file diff --git a/src/RESTAPI/RESTAPI_ipReservations_handler.h b/src/RESTAPI/RESTAPI_ipReservations_handler.h new file mode 100644 index 0000000..328450a --- /dev/null +++ b/src/RESTAPI/RESTAPI_ipReservations_handler.h @@ -0,0 +1,32 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#ifndef OWSUB_RESTAPI_IPRESERVATIONS_HANDLER_H +#define OWSUB_RESTAPI_IPRESERVATIONS_HANDLER_H + +#include "framework/MicroService.h" + +namespace OpenWifi { + class RESTAPI_ipReservations_handler : public RESTAPIHandler { + public: + RESTAPI_ipReservations_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, bool Internal) + : RESTAPIHandler(bindings, L, + std::vector{ + Poco::Net::HTTPRequest::HTTP_GET, + Poco::Net::HTTPRequest::HTTP_PUT, + Poco::Net::HTTPRequest::HTTP_OPTIONS}, + Server, + Internal){} + + static const std::list PathName() { return std::list{"/api/v1/ipReservations"}; }; + + void DoGet() final; + void DoPost() final {}; + void DoPut() final; + void DoDelete() final {}; + private: + }; +} + +#endif //OWSUB_RESTAPI_IPRESERVATIONS_HANDLER_H diff --git a/src/RESTAPI/RESTAPI_subscriberDevices_handler.cpp b/src/RESTAPI/RESTAPI_subscriberDevices_handler.cpp new file mode 100644 index 0000000..1b42876 --- /dev/null +++ b/src/RESTAPI/RESTAPI_subscriberDevices_handler.cpp @@ -0,0 +1,17 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#include "RESTAPI_subscriberDevices_handler.h" + +namespace OpenWifi { + + void RESTAPI_subscriberDevices_handler::DoGet() { + + } + + void RESTAPI_subscriberDevices_handler::DoPut() { + + } + +} \ No newline at end of file diff --git a/src/RESTAPI/RESTAPI_subscriberDevices_handler.h b/src/RESTAPI/RESTAPI_subscriberDevices_handler.h new file mode 100644 index 0000000..c8c6be0 --- /dev/null +++ b/src/RESTAPI/RESTAPI_subscriberDevices_handler.h @@ -0,0 +1,32 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#ifndef OWSUB_RESTAPI_SUBSCRIBERDEVICES_HANDLER_H +#define OWSUB_RESTAPI_SUBSCRIBERDEVICES_HANDLER_H + +#include "framework/MicroService.h" + +namespace OpenWifi { + class RESTAPI_subscriberDevices_handler : public RESTAPIHandler { + public: + RESTAPI_subscriberDevices_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, bool Internal) + : RESTAPIHandler(bindings, L, + std::vector{ + Poco::Net::HTTPRequest::HTTP_GET, + Poco::Net::HTTPRequest::HTTP_PUT, + Poco::Net::HTTPRequest::HTTP_OPTIONS}, + Server, + Internal){} + + static const std::list PathName() { return std::list{"/api/v1/subscriberDevices"}; }; + + void DoGet() final; + void DoPost() final {}; + void DoPut() final; + void DoDelete() final {}; + private: + }; +} + +#endif //OWSUB_RESTAPI_SUBSCRIBERDEVICES_HANDLER_H diff --git a/src/RESTAPI/RESTAPI_wifiClients_handler.cpp b/src/RESTAPI/RESTAPI_wifiClients_handler.cpp new file mode 100644 index 0000000..53dfde0 --- /dev/null +++ b/src/RESTAPI/RESTAPI_wifiClients_handler.cpp @@ -0,0 +1,11 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#include "RESTAPI_wifiClients_handler.h" + +namespace OpenWifi { + void RESTAPI_wifiClients_handler::DoGet() { + + } +} \ No newline at end of file diff --git a/src/RESTAPI/RESTAPI_wifiClients_handler.h b/src/RESTAPI/RESTAPI_wifiClients_handler.h new file mode 100644 index 0000000..887b758 --- /dev/null +++ b/src/RESTAPI/RESTAPI_wifiClients_handler.h @@ -0,0 +1,31 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#ifndef OWSUB_RESTAPI_WIFICLIENTS_HANDLER_H +#define OWSUB_RESTAPI_WIFICLIENTS_HANDLER_H + +#include "framework/MicroService.h" + +namespace OpenWifi { + class RESTAPI_wifiClients_handler : public RESTAPIHandler { + public: + RESTAPI_wifiClients_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, bool Internal) + : RESTAPIHandler(bindings, L, + std::vector{ + Poco::Net::HTTPRequest::HTTP_GET, + Poco::Net::HTTPRequest::HTTP_OPTIONS}, + Server, + Internal){} + + static const std::list PathName() { return std::list{"/api/v1/wifiClients"}; }; + + void DoGet() final; + void DoPost() final {}; + void DoPut() final {}; + void DoDelete() final {}; + private: + }; +} + +#endif //OWSUB_RESTAPI_WIFICLIENTS_HANDLER_H diff --git a/src/RESTAPI/RESTAPI_wifiNetworks_handler.cpp b/src/RESTAPI/RESTAPI_wifiNetworks_handler.cpp new file mode 100644 index 0000000..08f1075 --- /dev/null +++ b/src/RESTAPI/RESTAPI_wifiNetworks_handler.cpp @@ -0,0 +1,16 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#include "RESTAPI_wifiNetworks_handler.h" + +namespace OpenWifi { + + void RESTAPI_wifiNetworks_handler::DoGet() { + + } + + void RESTAPI_wifiNetworks_handler::DoPut() { + + } +} \ No newline at end of file diff --git a/src/RESTAPI/RESTAPI_wifiNetworks_handler.h b/src/RESTAPI/RESTAPI_wifiNetworks_handler.h new file mode 100644 index 0000000..57758bd --- /dev/null +++ b/src/RESTAPI/RESTAPI_wifiNetworks_handler.h @@ -0,0 +1,33 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#ifndef OWSUB_RESTAPI_WIFINETWORKS_HANDLER_H +#define OWSUB_RESTAPI_WIFINETWORKS_HANDLER_H + +#include "framework/MicroService.h" + +namespace OpenWifi { + class RESTAPI_wifiNetworks_handler : public RESTAPIHandler { + public: + RESTAPI_wifiNetworks_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, bool Internal) + : RESTAPIHandler(bindings, L, + std::vector{ + Poco::Net::HTTPRequest::HTTP_GET, + Poco::Net::HTTPRequest::HTTP_PUT, + Poco::Net::HTTPRequest::HTTP_OPTIONS}, + Server, + Internal){} + + static const std::list PathName() { return std::list{"/api/v1/wifiNetworks"}; }; + + void DoGet() final; + void DoPost() final {}; + void DoPut() final; + void DoDelete() final {}; + private: + }; +} + + +#endif //OWSUB_RESTAPI_WIFINETWORKS_HANDLER_H diff --git a/src/RESTAPI/RESTAPI_wiredClients_handler.cpp b/src/RESTAPI/RESTAPI_wiredClients_handler.cpp new file mode 100644 index 0000000..9163cc1 --- /dev/null +++ b/src/RESTAPI/RESTAPI_wiredClients_handler.cpp @@ -0,0 +1,13 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#include "RESTAPI_wiredClients_handler.h" + +namespace OpenWifi { + + void RESTAPI_wiredClients_handler::DoGet() { + + } + +} \ No newline at end of file diff --git a/src/RESTAPI/RESTAPI_wiredClients_handler.h b/src/RESTAPI/RESTAPI_wiredClients_handler.h new file mode 100644 index 0000000..4652a2e --- /dev/null +++ b/src/RESTAPI/RESTAPI_wiredClients_handler.h @@ -0,0 +1,31 @@ +// +// Created by stephane bourque on 2021-10-26. +// + +#ifndef OWSUB_RESTAPI_WIREDCLIENTS_HANDLER_H +#define OWSUB_RESTAPI_WIREDCLIENTS_HANDLER_H + +#include "framework/MicroService.h" + +namespace OpenWifi { + class RESTAPI_wiredClients_handler : public RESTAPIHandler { + public: + RESTAPI_wiredClients_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, bool Internal) + : RESTAPIHandler(bindings, L, + std::vector{ + Poco::Net::HTTPRequest::HTTP_GET, + Poco::Net::HTTPRequest::HTTP_OPTIONS}, + Server, + Internal){} + + static const std::list PathName() { return std::list{"/api/v1/wiredClients"}; }; + + void DoGet() final; + void DoPost() final {}; + void DoPut() final {}; + void DoDelete() final {}; + private: + }; +} + +#endif //OWSUB_RESTAPI_WIREDCLIENTS_HANDLER_H