api_v1_K8s.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include <drogon/HttpController.h>
  3. #include "Util/logger.h"
  4. #include "Util/NoticeCenter.h"
  5. #include "Poller/EventPoller.h"
  6. #include "Util/SqlPool.h"
  7. using namespace toolkit;
  8. using namespace drogon;
  9. namespace api
  10. {
  11. namespace v1
  12. {
  13. class K8s : public drogon::HttpController<K8s>
  14. {
  15. public:
  16. METHOD_LIST_BEGIN
  17. METHOD_ADD(K8s::getNodes, "/nodes?token={1}",Get, "LoginFilter");
  18. METHOD_ADD(K8s::getServers, "/Servers?token={1}", Get, "LoginFilter");
  19. METHOD_ADD(K8s::postServers, "/Servers?token={1}", Post, "LoginFilter");
  20. METHOD_ADD(K8s::putServers, "/Servers?token={1}&name={2}", Put, "LoginFilter");
  21. METHOD_ADD(K8s::deleteServers, "/Servers?token={1}&name={2}", Delete, "LoginFilter");
  22. METHOD_ADD(K8s::getPods, "/Pods?token={1}", Get, "LoginFilter");
  23. METHOD_ADD(K8s::deletePods, "/Pods?token={1}&name={2}",Delete, "LoginFilter");
  24. METHOD_ADD(K8s::getDeployment,"/Deployment?token={1}", Get, "LoginFilter");
  25. METHOD_ADD(K8s::postDeployment,"/Deployment?token={1}", Post, "LoginFilter");
  26. METHOD_ADD(K8s::putDeployment,"/Deployment?token={1}&name={2}", Put, "LoginFilter");
  27. METHOD_ADD(K8s::deleteDeployment,"/Deployment?token={1}&name={2}", Delete, "LoginFilter");
  28. METHOD_LIST_END
  29. // your declaration of processing function maybe like this:
  30. void getNodes(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
  31. // Servers
  32. void getServers(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
  33. void postServers(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
  34. void putServers(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);
  35. void deleteServers(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);
  36. // Pods
  37. void getPods(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
  38. void deletePods(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);
  39. // Deployment
  40. void getDeployment(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
  41. void postDeployment(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
  42. void putDeployment(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);
  43. void deleteDeployment(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);
  44. };
  45. }
  46. }