Adding StopTask endpoint and endpoint documentation

This commit is contained in:
Ian Roddis
2022-02-22 10:32:31 -04:00
parent 0ee198e3e7
commit b63739c0a9
5 changed files with 231 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ namespace daggy::daggyd {
DAGGY_REST_HANDLER(handleGetDAGRunState); // X
DAGGY_REST_HANDLER(handleSetDAGRunState); // X
DAGGY_REST_HANDLER(handleGetTask); // X
DAGGY_REST_HANDLER(handleStopTask); // X
DAGGY_REST_HANDLER(handleGetTaskState); // X
DAGGY_REST_HANDLER(handleSetTaskState); // X

View File

@@ -167,6 +167,10 @@ namespace daggy::daggyd {
.bind(&Server::handleGetTask, this)
.produces(MIME(Application, Json))
.response(Http::Code::Ok, "Details of a specific task");
taskPath.route(desc_.del("/"))
.bind(&Server::handleStopTask, this)
.produces(MIME(Application, Json))
.response(Http::Code::Ok, "Kill a specific task");
/*
Task State paths
@@ -682,6 +686,25 @@ namespace daggy::daggyd {
}
}
void Server::handleStopTask(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response)
{
if (!handleAuth(request))
return;
auto runID = request.param(":runID").as<DAGRunID>();
auto taskName = request.param(":taskName").as<std::string>();
{
std::lock_guard<std::mutex> lock(runnerGuard_);
auto it = runners_.find(runID);
if (runners_.find(runID) != runners_.end()) {
it->second->stopTask(taskName);
}
}
response.send(Pistache::Http::Code::Ok, "");
}
void Server::handleSetTaskState(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response)
{