2019-07-14 22:39:37 +00:00
|
|
|
#pragma once
|
|
|
|
#include <drogon/HttpController.h>
|
|
|
|
using namespace drogon;
|
|
|
|
namespace api
|
|
|
|
{
|
|
|
|
namespace v1
|
|
|
|
{
|
|
|
|
class devices:public drogon::HttpController<devices>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
METHOD_LIST_BEGIN
|
|
|
|
METHOD_ADD(devices::post_discover, "/discover", Post);
|
2019-07-20 21:33:17 +00:00
|
|
|
METHOD_ADD(devices::get_all, "/", Get);
|
|
|
|
METHOD_ADD(devices::get_one_by_id, "/{1}", Get);
|
|
|
|
METHOD_ADD(devices::delete_one_by_id, "/{1}", Delete);
|
|
|
|
|
|
|
|
METHOD_ADD(devices::get_relays_all, "/{1}/relays/", Get);
|
|
|
|
METHOD_ADD(devices::get_relays_one_by_id_and_num, "/{1}/relays/{2}", Get);
|
2019-07-21 22:00:07 +00:00
|
|
|
METHOD_ADD(devices::put_relays_one_by_id_and_num, "/{1}/relays/{2}", Put, "filters::json_required", "filters::relays::valid_json");
|
2019-07-14 22:39:37 +00:00
|
|
|
METHOD_LIST_END
|
|
|
|
|
2019-07-20 21:33:17 +00:00
|
|
|
static void post_discover(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback);
|
|
|
|
static void get_all(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback);
|
|
|
|
static void get_one_by_id(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& device_id);
|
|
|
|
static void delete_one_by_id(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& device_id);
|
|
|
|
|
|
|
|
static void get_relays_all(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& device_id);
|
|
|
|
static void get_relays_one_by_id_and_num(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& device_id, int relay_num);
|
|
|
|
static void put_relays_one_by_id_and_num(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, const std::string& device_id, int relay_num);
|
2019-07-14 22:39:37 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|