24 #include "modules/pifacedigital/PFGPIO_odb.h" 36 std::vector<WebSockAPI::ICRUDResourceHandler::ActionActionParam>
38 const json &req)
const 40 std::vector<CRUDResourceHandler::ActionActionParam> ret;
47 catch (json::out_of_range &e)
77 odb::transaction t(db->begin());
79 auto new_gpio = std::make_shared<PFGPIO>();
82 db->persist(new_gpio);
92 auto gpio = db->find<
PFGPIO>(id);
103 using Result = odb::result<PFGPIO>;
105 odb::transaction t(db->begin());
108 if (!gpio_id.is_nil())
116 rep[
"data"] = json::array();
120 for (
const auto &gpio : result)
123 if (
ctx_.
session->security_context().check_permission(
126 rep[
"data"].push_back(
139 odb::transaction t(db->begin());
155 odb::transaction t(db->begin());
std::vector< ActionActionParam > required_permission(Verb verb, const WebSockAPI::json &req) const override
boost::optional< WebSockAPI::json > create_impl(const WebSockAPI::json &req) override
Hardware::DeviceId device_id
This is the header file for a generated source file, GitSHA1.cpp.
static json serialize(const PFGPIO &in, const SecurityContext &sc)
Piface Module GPIO descriptor.
static WebSockAPI::CRUDResourceHandlerUPtr instanciate(WebSockAPI::RequestContext)
CRUDResourceHandler(RequestContext ctx)
static void unserialize(PFGPIO &out, const json &in, const SecurityContext &sc)
virtual UserSecurityContext & security_context() const override
Helper function that returns the security context.
An optional transaction is an object that behave like an odb::transaction if there is no currently ac...
std::unique_ptr< CRUDResourceHandler > CRUDResourceHandlerUPtr
Thin wrapper around boost::uuids::uuid.
Permissions for hardware devices.
boost::optional< WebSockAPI::json > read_impl(const WebSockAPI::json &req) override
boost::optional< WebSockAPI::json > update_impl(const WebSockAPI::json &req) override
boost::optional< WebSockAPI::json > delete_impl(const WebSockAPI::json &req) override
CRUDHandler(const WebSockAPI::RequestContext &ctx)
odb::result< Tools::LogEntry > Result
Holds valuable pointer to provide context to a request.
std::shared_ptr< odb::database > DBPtr
auto find_gpio_by_id(const Hardware::DeviceId &id, DBPtr db)