initial commit
This commit is contained in:
commit
811f80c92c
17 changed files with 549 additions and 0 deletions
41
source/gns3/GnsNode.cpp
Normal file
41
source/gns3/GnsNode.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include "GnsNode.hpp"
|
||||
#include "GnsPort.hpp"
|
||||
#include "GnsProject.hpp"
|
||||
|
||||
#include <cpr/cpr.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace gns {
|
||||
|
||||
|
||||
GnsNode::GnsNode(const GnsProject *project, std::string uuid, const std::vector<GnsPort>& ports) {
|
||||
this->project = project;
|
||||
this->uuid = std::move(uuid);
|
||||
this->ports = ports;
|
||||
}
|
||||
|
||||
std::string GnsNode::getApiBase() const {
|
||||
return this->project->getApiBase() + "nodes/" + this->uuid;
|
||||
}
|
||||
|
||||
std::string GnsNode::getUuid() const {
|
||||
return this->uuid;
|
||||
}
|
||||
|
||||
std::vector<GnsPort> GnsNode::getPorts() const {
|
||||
return this->ports;
|
||||
}
|
||||
|
||||
void GnsNode::start() const {
|
||||
// request the API endpoint
|
||||
cpr::Url endpoint = this->getApiBase() + "start";
|
||||
cpr::Response response = Post(endpoint);
|
||||
|
||||
// check for a valid response
|
||||
if (response.error.code != cpr::ErrorCode::OK)
|
||||
throw std::runtime_error(response.error.message);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue