1 #ifndef _MANAGEMENT_API_H 2 #define _MANAGEMENT_API_H 12 #include <json_provider.h> 13 #include <service_handler.h> 14 #include <server_http.hpp> 20 #define PING "/fledge/service/ping" 21 #define SERVICE_SHUTDOWN "/fledge/service/shutdown" 22 #define CONFIG_CHANGE "/fledge/change" 23 #define CONFIG_CHILD_CREATE "/fledge/child_create" 24 #define CONFIG_CHILD_DELETE "/fledge/child_delete" 25 #define SECURITY_CHANGE "^/fledge/security$" 27 using HttpServer = SimpleWeb::Server<SimpleWeb::HTTP>;
34 ManagementApi(
const std::string& name,
const unsigned short port);
43 m_serviceHandler = serviceHandler;
45 unsigned short getListenerPort() {
46 return m_server->getLocalPort();
48 void ping(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
49 void shutdown(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
50 void configChange(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
51 void configChildCreate(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
52 void configChildDelete(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
53 void securityChange(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
63 std::thread *m_thread;
65 void respond(std::shared_ptr<HttpServer::Response>,
const std::string&);
Fledge Logger class used to log to syslog.
Definition: logger.h:26
void registerStats(JSONProvider *statsProvider)
Register a statistics provider.
Definition: management_api.cpp:149
void securityChange(std::shared_ptr< HttpServer::Response > response, std::shared_ptr< HttpServer::Request > request)
Received a security change request, construct a reply and return to caller.
Definition: management_api.cpp:294
Management API server for a C++ microservice.
Definition: management_api.h:32
void shutdown(std::shared_ptr< HttpServer::Response > response, std::shared_ptr< HttpServer::Request > request)
Received a shutdown request, construct a reply and return to caller.
Definition: management_api.cpp:179
Definition: json_provider.h:14
ServiceHandler abstract class - the interface that services using the management API must provide...
Definition: service_handler.h:20
void configChange(std::shared_ptr< HttpServer::Response > response, std::shared_ptr< HttpServer::Request > request)
Received a config change request, construct a reply and return to caller.
Definition: management_api.cpp:194
void configChildDelete(std::shared_ptr< HttpServer::Response > response, std::shared_ptr< HttpServer::Request > request)
Received a children deletion request, construct a reply and return to caller.
Definition: management_api.cpp:224
void configChildCreate(std::shared_ptr< HttpServer::Response > response, std::shared_ptr< HttpServer::Request > request)
Received a children creation request, construct a reply and return to caller.
Definition: management_api.cpp:254
~ManagementApi()
Management API destructor.
Definition: management_api.cpp:140
static ManagementApi * getInstance()
Return the signleton instance of the management interface.
Definition: management_api.cpp:132
void ping(std::shared_ptr< HttpServer::Response > response, std::shared_ptr< HttpServer::Request > request)
Received a ping request, construct a reply and return to caller.
Definition: management_api.cpp:157
ManagementApi(const std::string &name, const unsigned short port)
Construct a microservices management API manager class.
Definition: management_api.cpp:80