mirror of
https://github.com/Telecominfraproject/wlan-cloud-owls.git
synced 2026-01-27 10:22:52 +00:00
Initial RESTAPI
This commit is contained in:
@@ -3,9 +3,48 @@
|
||||
//
|
||||
|
||||
#include "RESTAPI_operation_handler.h"
|
||||
#include "Simulation.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_operation_handler::DoPost() {
|
||||
|
||||
}
|
||||
std::string Op;
|
||||
if(!HasParameter("operation", Op) ||
|
||||
( Op != "start" && Op!= "stop" && Op != "cancel" && Op != "pause" && Op != "resume")) {
|
||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||
}
|
||||
|
||||
std::string Id;
|
||||
if(HasParameter("id",Id) && Op=="start") {
|
||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||
}
|
||||
|
||||
std::string SimId;
|
||||
if(HasParameter("simulationId",SimId) && Op!="start") {
|
||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||
}
|
||||
|
||||
std::string Error;
|
||||
|
||||
if(Op=="start") {
|
||||
SimulationCoordinator()->StartSim(SimId,Id,Error);
|
||||
} else if(Op=="stop") {
|
||||
SimulationCoordinator()->StopSim(Id,Error);
|
||||
} else if(Op=="pause") {
|
||||
SimulationCoordinator()->PauseSim(Id,Error);
|
||||
} else if(Op=="cancel") {
|
||||
SimulationCoordinator()->CancelSim(Id,Error);
|
||||
} else if(Op=="resume") {
|
||||
SimulationCoordinator()->ResumeSim(Id,Error);
|
||||
}
|
||||
|
||||
if(Error.empty()) {
|
||||
OWLSObjects::SimulationStatus S;
|
||||
SimulationCoordinator()->GetStatus(S);
|
||||
Poco::JSON::Object Answer;
|
||||
S.to_json(Answer);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
return BadRequest(Error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user