text: /**
  * lbrp API
  * LoadBalancer Reverse-Proxy Service
  *
  * OpenAPI spec version: 2.0.0
  *
  * NOTE: This class is auto generated by the swagger code generator program.
  * https://github.com/polycube-network/swagger-codegen.git
  * branch polycube
  */
  
  
  /* Do not edit this file manually */
  
  
  
  #include "ServiceBackendJsonObject.h"
  #include <regex>
  
  namespace io {
  namespace swagger {
  namespace server {
  namespace model {
  
  ServiceBackendJsonObject::ServiceBackendJsonObject() {
  
    m_nameIsSet = false;
  
    m_ipIsSet = false;
  
    m_portIsSet = false;
  
    m_weightIsSet = false;
  }
  
  ServiceBackendJsonObject::~ServiceBackendJsonObject() {}
  
  void ServiceBackendJsonObject::validateKeys() {
  
    if (!m_ipIsSet) {
      throw std::runtime_error("Variable ip is required");
    }
  }
  
  void ServiceBackendJsonObject::validateMandatoryFields() {
  
    if (!m_portIsSet) {
      throw std::runtime_error("Variable port is required");
    }
  }
  
  void ServiceBackendJsonObject::validateParams() {
  
    if (m_ipIsSet) {
      std::string patter_value = R"PATTERN((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?)PATTERN";
      std::regex e (patter_value);
      if (!std::regex_match(m_ip, e))
        throw std::runtime_error("Variable ip has not a valid format");
    }
    if (m_portIsSet) {
      if (m_port < 0 || m_port > 65535) {
        throw std::runtime_error("Variable port is not in the range");
      }
    }
  }
  
  nlohmann::json ServiceBackendJsonObject::toJson() const {
    nlohmann::json val = nlohmann::json::object();
  
    if (m_nameIsSet) {
      val["name"] = m_name;
    }
  
    if (m_ipIsSet) {
      val["ip"] = m_ip;
    }
  
    val["port"] = m_port;
    if (m_weightIsSet) {
      val["weight"] = m_weight;
    }
  
  
    return val;
  }
  
  void ServiceBackendJsonObject::fromJson(nlohmann::json& val) {
    for(nlohmann::json::iterator it = val.begin(); it != val.end(); ++it) {
      std::string key = it.key();
      bool found = (std::find(allowedParameters_.begin(), allowedParameters_.end(), key) != allowedParameters_.end());
      if (!found) {
        throw std::runtime_error(key + " is not a valid parameter");
        return;
      }
    }
  
    if (val.find("name") != val.end()) {
      setName(val.at("name"));
    }
  
    if (val.find("ip") != val.end()) {
      setIp(val.at("ip"));
    }
  
    if (val.find("port") != val.end()) {
      setPort(val.at("port"));
    }
  
    if (val.find("weight") != val.end()) {
      setWeight(val.at("weight"));
    }
  }
  
  nlohmann::json ServiceBackendJsonObject::helpKeys() {
    nlohmann::json val = nlohmann::json::object();
  
    val["ip"]["name"] = "ip";
    val["ip"]["type"] = "key";
    val["ip"]["simpletype"] = "string";
    val["ip"]["description"] = R"POLYCUBE(IP address of the backend server of the pool)POLYCUBE";
    val["ip"]["example"] = R"POLYCUBE(10.244.1.23)POLYCUBE";
  
    return val;
  }
  
  nlohmann::json ServiceBackendJsonObject::helpElements() {
    nlohmann::json val = nlohmann::json::object();
  
    val["name"]["name"] = "name";
    val["name"]["type"] = "leaf"; // Suppose that type is leaf
    val["name"]["simpletype"] = "string";
    val["name"]["description"] = R"POLYCUBE(name)POLYCUBE";
    val["name"]["example"] = R"POLYCUBE(backend1)POLYCUBE";
    val["port"]["name"] = "port";
    val["port"]["type"] = "leaf"; // Suppose that type is leaf
    val["port"]["simpletype"] = "integer";
    val["port"]["description"] = R"POLYCUBE(Port where the server listen to (this value is ignored in case of ICMP))POLYCUBE";
    val["port"]["example"] = R"POLYCUBE(80)POLYCUBE";
    val["weight"]["name"] = "weight";
    val["weight"]["type"] = "leaf"; // Suppose that type is leaf
    val["weight"]["simpletype"] = "integer";
    val["weight"]["description"] = R"POLYCUBE(Weight of the backend in the pool)POLYCUBE";
    val["weight"]["example"] = R"POLYCUBE(1)POLYCUBE";
  
    return val;
  }
  
  nlohmann::json ServiceBackendJsonObject::helpWritableLeafs() {
    nlohmann::json val = nlohmann::json::object();
  
    val["name"]["name"] = "name";
    val["name"]["simpletype"] = "string";
    val["name"]["description"] = R"POLYCUBE(name)POLYCUBE";
    val["name"]["example"] = R"POLYCUBE(backend1)POLYCUBE";
    val["port"]["name"] = "port";
    val["port"]["simpletype"] = "integer";
    val["port"]["description"] = R"POLYCUBE(Port where the server listen to (this value is ignored in case of ICMP))POLYCUBE";
    val["port"]["example"] = R"POLYCUBE(80)POLYCUBE";
    val["weight"]["name"] = "weight";
    val["weight"]["simpletype"] = "integer";
    val["weight"]["description"] = R"POLYCUBE(Weight of the backend in the pool)POLYCUBE";
    val["weight"]["example"] = R"POLYCUBE(1)POLYCUBE";
  
    return val;
  }
  
  nlohmann::json ServiceBackendJsonObject::helpComplexElements() {
    nlohmann::json val = nlohmann::json::object();
  
  
    return val;
  }
  
  std::vector<std::string> ServiceBackendJsonObject::helpActions() {
    std::vector<std::string> val;
    return val;
  }
  
  std::string ServiceBackendJsonObject::getName() const {
    return m_name;
  }
  
  void ServiceBackendJsonObject::setName(std::string value) {
    m_name = value;
    m_nameIsSet = true;
  }
  
  bool ServiceBackendJsonObject::nameIsSet() const {
    return m_nameIsSet;
  }
  
  void ServiceBackendJsonObject::unsetName() {
    m_nameIsSet = false;
  }
  
  
  
  std::string ServiceBackendJsonObject::getIp() const {
    return m_ip;
  }
  
  void ServiceBackendJsonObject::setIp(std::string value) {
    m_ip = value;
    m_ipIsSet = true;
  }
  
  bool ServiceBackendJsonObject::ipIsSet() const {
    return m_ipIsSet;
  }
  
  void ServiceBackendJsonObject::unsetIp() {
    m_ipIsSet = false;
  }
  
  
  
  uint16_t ServiceBackendJsonObject::getPort() const {
    return m_port;
  }
  
  void ServiceBackendJsonObject::setPort(uint16_t value) {
    m_port = value;
    m_portIsSet = true;
  }
  
  bool ServiceBackendJsonObject::portIsSet() const {
    return m_portIsSet;
  }
  
  void ServiceBackendJsonObject::unsetPort() {
    m_portIsSet = false;
  }
  
  
  
  uint16_t ServiceBackendJsonObject::getWeight() const {
    return m_weight;
  }
  
  void ServiceBackendJsonObject::setWeight(uint16_t value) {
    m_weight = value;
    m_weightIsSet = true;
  }
  
  bool ServiceBackendJsonObject::weightIsSet() const {
    return m_weightIsSet;
  }
  
  void ServiceBackendJsonObject::unsetWeight() {
    m_weightIsSet = false;
  }
  
  
  
  
  }
  }
  }
  }
  
  