#pragma once

#include <drogon/HttpController.h>
#include "Util/logger.h"
#include "Util/NoticeCenter.h"
#include "Poller/EventPoller.h"
#include "Util/SqlPool.h"

using namespace toolkit;
using namespace drogon;

namespace api
{
namespace v1
{
class K8s : public drogon::HttpController<K8s>
{
  public:
    METHOD_LIST_BEGIN
      METHOD_ADD(K8s::getNodes, "/nodes?token={1}",Get, "LoginFilter");
      
      METHOD_ADD(K8s::getServers, "/Servers?token={1}", Get, "LoginFilter");
      METHOD_ADD(K8s::postServers, "/Servers?token={1}", Post, "LoginFilter");
      METHOD_ADD(K8s::putServers, "/Servers?token={1}&name={2}", Put, "LoginFilter");
      METHOD_ADD(K8s::deleteServers, "/Servers?token={1}&name={2}", Delete, "LoginFilter");

      METHOD_ADD(K8s::getPods, "/Pods?token={1}", Get, "LoginFilter");
      METHOD_ADD(K8s::deletePods, "/Pods?token={1}&name={2}",Delete, "LoginFilter");
      
      METHOD_ADD(K8s::getDeployment,"/Deployment?token={1}", Get, "LoginFilter");
      METHOD_ADD(K8s::postDeployment,"/Deployment?token={1}", Post, "LoginFilter");
      METHOD_ADD(K8s::putDeployment,"/Deployment?token={1}&name={2}", Put, "LoginFilter");
      METHOD_ADD(K8s::deleteDeployment,"/Deployment?token={1}&name={2}", Delete, "LoginFilter");

    METHOD_LIST_END

    // your declaration of processing function maybe like this:
    void getNodes(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
    
    // Servers
    void getServers(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback,  std::string token);
    void postServers(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback,  std::string token);
    void putServers(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback,  std::string token, std::string name);
    void deleteServers(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback,  std::string token, std::string name);

    // Pods  
    void getPods(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
    void deletePods(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);

    // Deployment
    void getDeployment(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
    void postDeployment(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
    void putDeployment(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);
    void deleteDeployment(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);
};
}
}
