 |
Fledge
An open source edge computing platform for industrial users
|
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);
44 m_serviceHandler = serviceHandler;
46 unsigned short getListenerPort() {
47 return m_server->getLocalPort();
49 void ping(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
50 void shutdown(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
51 void configChange(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
52 void configChildCreate(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
53 void configChildDelete(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
54 void securityChange(std::shared_ptr<HttpServer::Response> response, std::shared_ptr<HttpServer::Request> request);
64 std::thread *m_thread;
66 void respond(std::shared_ptr<HttpServer::Response>,
const std::string&);
67 std::vector<JSONProvider *>
Definition: json_provider.h:14
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:225
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:352
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:309
Management API server for a C++ microservice.
Definition: management_api.h:32
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:194
~ManagementApi()
Management API destructor.
Definition: management_api.cpp:161
static ManagementApi * getInstance()
Return the signleton instance of the management interface.
Definition: management_api.cpp:153
void registerProvider(JSONProvider *provider)
Register a generic provider.
Definition: management_api.cpp:183
ManagementApi(const std::string &name, const unsigned short port)
Construct a microservices management API manager class.
Definition: management_api.cpp:101
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:243
void registerStats(JSONProvider *statsProvider)
Register a statistics provider.
Definition: management_api.cpp:172
Fledge Logger class used to log to syslog.
Definition: logger.h:42
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:276
ServiceHandler abstract class - the interface that services using the management API must provide.
Definition: service_handler.h:20