Load Balancer

Create an API Key and access token:-

For create a API Key and Access Token to refer this link :-

https://www.e2enetworks.com/help/knowledge-base/how-to-create-an-api-access-token/

List of Load Balancer

To find a list of Load Balancer to send a GET request

https://api.e2enetworks.com/myaccount/api/v1/appliances/?location=Delhi&apikey=10a6b7cb-b05d-45cd-b347-78388381633b

The request returns a JSON object that contains the following attributes:

Name Type Description
id Integer A unique integer identifier created and assigned to the LB after its creation.
name string The name assigned to the node
template_id Integer A unique integer identifier created and assigned to the LB after its creation

PYTHON

1. Python - http.client Example

          import http.client

          conn = http.client.HTTPSConnection("api.e2enetworks.com")
          payload = ''
          headers = {
                 'Authorization': ' API_Token ',
                 'Content-Type': 'application/json',

              }
          conn.request("GET", "/myaccount/api/v1/appliances/?location=Delhi&apikey=API_Key", payload, headers)
          res = conn.getresponse()
          data = res.read()
          print(data.decode("utf-8"))
2. Python - Requests Example

           import requests

           url = "https://api.e2enetworks.com/myaccount/api/v1/appliances/?location=Delhi&apikey=API_key"

           payload={}
           headers = {
                   'Authorization': 'API_Token ',
                   'Content-Type': 'application/json',

                }

            response = requests.request("GET", url, headers=headers, data=payload)

            print(response.text)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Response Body

 {
  "code": 200,
  "data": [
      {
          "id": 2449,
          "name": "E2E-LB-1-714",
          "appliance_type": {
              "id": 1,
              "name": "LoadBalancer",
              "appliance_config": [
                  {
                      "hourly": 1,
                      "name": "E2E-LB-1",
                      "vcpu": 2,
                      "price": "730",
                      "ram": "3GB",
                      "user": 1,
                      "disk": "10GB",
                      "template_id": 2248,
                      "description": "",
                      "can_support_bitninja": {
                          "show_bitninja": true,
                          "bitninja_cost": "760.00"
                      },
                      "location": "Delhi"
                  },
                  {
                      "hourly": 2,
                      "name": "E2E-LB-2",
                      "vcpu": 4,
                      "price": "1460",
                      "ram": "6GB",
                      "user": 1,
                      "disk": "10GB",
                      "template_id": 2249,
                      "description": "",
                      "can_support_bitninja": {
                          "show_bitninja": true,
                          "bitninja_cost": "760.00"
                      },
                      "location": "Delhi"
                  },
                  {
                      "hourly": 4,
                      "name": "E2E-LB-3",
                      "vcpu": 8,
                      "price": "2920",
                      "ram": "12GB",
                      "user": 1,
                      "disk": "10GB",
                      "template_id": 2250,
                      "description": "",
                      "can_support_bitninja": {
                          "show_bitninja": true,
                          "bitninja_cost": "760.00"
                      },
                      "location": "Delhi"
                  },
                  {
                      "hourly": 8,
                      "name": "E2E-LB-4",
                      "vcpu": 12,
                      "price": "5840",
                      "ram": "24GB",
                      "user": 1,
                      "disk": "10GB",
                      "template_id": 2251,
                      "description": "",
                      "can_support_bitninja": {
                          "show_bitninja": true,
                          "bitninja_cost": "760.00"
                      },
                      "location": "Delhi"
                  },
                  {
                      "hourly": 16,
                      "name": "E2E-LB-5",
                      "vcpu": 24,
                      "price": "11680",
                      "ram": "48GB",
                      "user": 1,
                      "disk": "10GB",
                      "template_id": 2252,
                      "description": "",
                      "can_support_bitninja": {
                          "show_bitninja": true,
                          "bitninja_cost": "760.00"
                      },
                      "location": "Delhi"
                  },
                  {
                      "hourly": 1,
                      "name": "MUM-E2E-LB-1",
                      "vcpu": 2,
                      "price": "730",
                      "ram": "3GB",
                      "user": 1,
                      "disk": "10GB",
                      "template_id": 10842,
                      "description": "",
                      "can_support_bitninja": {
                          "show_bitninja": true,
                          "bitninja_cost": "760.00"
                      },
                      "location": "Mumbai"
                  },
                  {
                      "hourly": 2,
                      "name": "MUM-E2E-LB-2",
                      "vcpu": 4,
                      "price": "1460",
                      "ram": "6GB",
                      "user": 1,
                      "disk": "10GB",
                      "template_id": 10845,
                      "description": "",
                      "can_support_bitninja": {
                          "show_bitninja": true,
                          "bitninja_cost": "760.00"
                      },
                      "location": "Mumbai"
                  },
                  {
                      "hourly": 4,
                      "name": "MUM-E2E-LB-3",
                      "vcpu": 8,
                      "price": "2920",
                      "ram": "12GB",
                      "user": 1,
                      "disk": "10GB",
                      "template_id": 10844,
                      "description": "",
                      "can_support_bitninja": {
                          "show_bitninja": true,
                          "bitninja_cost": "760.00"
                      },
                      "location": "Mumbai"
                  },
                  {
                      "hourly": 8,
                      "name": "MUM-E2E-LB-4",
                      "vcpu": 12,
                      "price": "5840",
                      "ram": "24GB",
                      "user": 1,
                      "disk": "10GB",
                      "template_id": 10843,
                      "description": "",
                      "can_support_bitninja": {
                          "show_bitninja": true,
                          "bitninja_cost": "760.00"
                      },
                      "location": "Mumbai"
                  },
                  {
                      "hourly": 16,
                      "name": "MUM-E2E-LB-5",
                      "vcpu": 24,
                      "price": "11680",
                      "ram": "48GB",
                      "user": 1,
                      "disk": "10GB",
                      "template_id": 10841,
                      "description": "",
                      "can_support_bitninja": {
                          "show_bitninja": true,
                          "bitninja_cost": "760.00"
                      },
                      "location": "Mumbai"
                  }
              ],
              "bitninja_discount_percentage": 0.0
          },
          "customer": 18933,
          "node_detail": {
              "node_id": 89389,
              "zabbix_host_id": 93024,
              "private_ip": "172.16.112.237",
              "allow_reserve_ip": {
                  "is_limit_available": true,
                  "is_already_reserved": false,
                  "can_we_reserved": true,
                  "reserve_ip_price": "199 infra credits",
                  "can_we_attach_detach_public_ip": true
              },
              "vm_id": 100151,
              "ram": "3 GB",
              "disk": "10 GB",
              "additional_ip": [],
              "public_ip": "164.52.192.128",
              "vcpu": 2,
              "support_bitninja": {
                  "show_bitninja": true,
                  "bitninja_cost": "760.00"
              },
              "is_bitninja_license_active": false,
              "bitninja_discount_percentage": 0.0
          },
          "appliance_instance": [
              {
                  "id": "5845",
                  "run": "2022-03-07 08:40:52.921174+00:00",
                  "context": {
                      "lb_port": "80",
                      "lb_type": "External",
                      "lb_name": "E2E-LB-1-714",
                      "lb_mode": "HTTP",
                      "plan_name": "E2E-LB-1",
                      "vpc_list": [],
                      "acl_list": [],
                      "acl_map": [],
                      "backends": [
                          {
                              "balance": "source",
                              "name": "alpha",
                              "backend_mode": "http",
                              "network_id": null,
                              "servers": [
                                  {
                                      "backend_name": "E2E-LB-1-5555",
                                      "backend_ip": "172.16.112.221",
                                      "backend_port": "8080"
                                  }
                              ],
                              "domain_name": "localhost",
                              "http_check": false,
                              "check_url": "/"
                          }
                      ],
                      "ssl_context": {
                          "ssl_certificate_id": null,
                          "redirect_to_https": false
                      },
                      "node_list_type": "S",
                      "scaler_id": "",
                      "scaler_port": "",
                      "lb_reserve_ip": "",
                      "enable_bitninja": false,
                      "default_backend_name": "alpha",
                      "host_target": "164.52.192.128"
                  }
              }
          ],
          "status": "RUNNING",
          "data_monitor": {
              "status": false,
              "node_status_pair": [
                  {
                      "node_name": "E2E-LB-1-5555",
                      "node_status": "DOWN"
                  }
              ]
          },
          "scaler_id": null,
          "node_list_type": "S",
          "scaler_port": null,
          "created_at": "2022-03-07 08:38:51 AM UTC",
          "updated_at": "2022-03-07 08:38:51 AM UTC",
          "eos_enabled_status": false
      }
  ],
  "errors": {},
  "message": "Success"
}

Create a new Load Balancer

To Create a new Load Balancer to send a Post request

https://api.e2enetworks.com/myaccount/api/v1/appliances/load-balancers/?apikey=10a6b7cb-b05d-45cd-b347-78388381633b

Attributes and respective values required to send this POST request are:

The request returns a JSON object that contains the following attributes:

Name Type Description
ip Integer Information regarding the network configuration.
appliance_id Integer A unique integer identifier created and assigned to the LB after its creation.

PYTHON

1. Python - http.client Example

   import http.client
   import json

   conn = http.client.HTTPSConnection("api.e2enetworks.com")
   payload = json.dumps({
                "acl_list": [],
 "acl_map": [],
 "backends": [
   {
     "balance": "source",
     "check_url": "/",
     "domain_name": "localhost",
     "http_check": False,
     "servers": [
       {
         "backend_ip": "172.16.112.221",
         "backend_name": "E2E-LB-1-5555",
         "backend_port": "8080"
       }
     ]
   }
 ],
 "enable_bitninja": False,
 "host_target": "",
 "lb_mode": "HTTP",
 "lb_name": "E2E-LB-1-714",
 "lb_port": 80,
 "lb_reserve_ip": "",
 "lb_type": "External",
 "node_list_type": "S",
 "plan_name": "E2E-LB-1",
 "scaler_id": "",
 "scaler_port": "",
 "ssl_certificate_id": "",
 "ssl_context": {
   "redirect_to_https": False
 },
 "vpc_list": []
 })
 headers = {
          'Authorization': 'API_Token ',
          'Content-Type': 'application/json',
       }
 conn.request("POST", "/myaccount/api/v1/appliances/load-balancers/?apikey=API_Key", payload, headers)
 res = conn.getresponse()
 data = res.read()
 print(data.decode("utf-8"))
2. Python - Requests Example

           import requests
           import json

           url = "https://api.e2enetworks.com/myaccount/api/v1/appliances/load-balancers/?apikey=API_Key"

           payload = json.dumps({
                             "acl_list": [],
                             "acl_map": [],
                             "backends": [
                                {
                                "balance": "source",
                                "check_url": "/",
                                "domain_name": "localhost",
                                " http_check": False,
                                "servers": [
                                {
                                    "backend_ip": "172.16.112.221",
                                    "backend_name": "E2E-LB-1-5555",
                                    "backend_port": "8080"
                                }
                              ]
                           }
                        ],
                 "enable_bitninja": False,
                "host_target": "",
                 "lb_mode": "HTTP",
                 "lb_name": "E2E-LB-1-714",
                 "lb_port": 80,
                 "lb_reserve_ip": "",
                 "lb_type": "External",
                 "node_list_type": "S",
                 "plan_name": "E2E-LB-1",
                 "scaler_id": "",
                 "scaler_port": "",
                 "ssl_certificate_id": "",
                 "ssl_context": {
                 "redirect_to_https": False
                 },
                "vpc_list": []
                 })
               headers = {
                       'Authorization': 'API_Token',
                       'Content-Type': 'application/json',
                }

              response = requests.request("POST", url, headers=headers, data=payload)

              print(response.text)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Request Body-

{
  "acl_list": [],
  "acl_map": [],
  "backends": [
      {
          "balance": "source",
          "check_url": "/",
          "domain_name": "localhost",
          "http_check": false,
          "servers": [
              {
                  "backend_ip": "172.16.112.221",
                  "backend_name": "E2E-LB-1-5555",
                  "backend_port": "8080"
              }
          ]
      }
  ],
  "enable_bitninja": false,
  "host_target": "",
  "lb_mode": "HTTP",
  "lb_name": "E2E-LB-1-714",
  "lb_port": 80,
  "lb_reserve_ip": "",
  "lb_type": "External",
  "node_list_type": "S",
  "plan_name": "E2E-LB-1",
  "scaler_id": "",
  "scaler_port": "",
  "ssl_certificate_id": "",
  "ssl_context": {
      "redirect_to_https": false
  },
  "vpc_list": []
}

Response Body

{
  "code": 200,
  "data": {
      "appliance_id": 2449,
      "is_credit_sufficient": true,
      "IP": "164.52.192.128"
  },
  "errors": {},
  "message": "Success"
}

Delete a Load Balancer

To Delete a Load Balancer to send a Delete request

https://api.e2enetworks.com/myaccount/api/v1/appliances/2447/?apikey=10a6b7cb-b05d-45cd-b347-78388381633b

PYTHON

1. Python - http.client Example

   import http.client

   conn = http.client.HTTPSConnection("api.e2enetworks.com")
   payload = ''
   headers = {
           'Authorization': 'API_Token ',
         }
   conn.request("DELETE", "/myaccount/api/v1/appliances/2447/?apikey=API_Key", payload, headers)
   res = conn.getresponse()
   data = res.read()
   print(data.decode("utf-8"))
2. Python - Requests Example

    import requests

    url = "https://api.e2enetworks.com/myaccount/api/v1/appliances/2447/?apikey=API_Key"

    payload={}
    headers = {
                'Authorization': 'API_Token ',

            }

    response = requests.request("DELETE", url, headers=headers, data=payload)

    print(response.text)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Response Body

{
  "code": 200,
  "data": {
      "appliance_id": 2449,
      "is_credit_sufficient": true,
      "IP": "164.52.192.128"
  },
  "errors": {},
  "message": "Success"
}

Edit your Load Balancer

To modify a Load Balancer to send a PUT request

https://api.e2enetworks.com/myaccount/api/v1/appliances/load-balancers/2448/?apikey=10a6b7cb-b05d-45cd-b347-78388381633b

Attributes and respective values required to send this POST request are:

The request returns a JSON object that contains the following attributes:

Name Type Description
ip Integer Information regarding the network configuration.
appliance_id Integer A unique integer identifier created and assigned to the LB after its creation.

PYTHON

1. Python - http.client Example

   import http.client
   import json

   conn = http.client.HTTPSConnection("api.e2enetworks.com")
   payload = json.dumps({
     "acl_list": [],
     "acl_map": [],
     "backends": [
   {
     "balance": "source",
     "check_url": "/",
     "domain_name": "localhost",
     "http_check": False,
     "servers": [
       {
         "backend_ip": "172.16.112.221",
         "backend_name": "E2E-LB-1-5555",
         "backend_port": "8080"
       }
     ]
   }
 ],
 "default_backend_name": "alpha",
 "enable_bitninja": False,
 "host_target": "164.52.192.128",
 "lb_mode": "HTTP",
 "lb_name": "E2E-LB-155",
 "lb_port": 80,
 "lb_reserve_ip": "",
 "lb_type": "External",
 "node_list_type": "S",
 "plan_name": "E2E-LB-1",
 "scaler_id": "",
 "scaler_port": "",
 "ssl_certificate_id": "",
 "ssl_context": {
   "redirect_to_https": False
 },
 "vpc_list": []
 })
  headers = {
      'Authorization': 'API_Token' ,
      'Content-Type': 'application/json',
    }
  conn.request("PUT", "/myaccount/api/v1/appliances/load-balancers/2448/?apikey=API_Key", payload, headers)
  res = conn.getresponse()
  data = res.read()
  print(data.decode("utf-8"))
2. Python - Requests Example

    import requests
    import json

    url = "https://api.e2enetworks.com/myaccount/api/v1/appliances/load-balancers/2448/?apikey=API_Key"

    payload = json.dumps({
         "acl_list": [],
         "acl_map": [],
         "backends": [
        {
     "balance": "source",
     "check_url": "/",
     "domain_name": "localhost",
     "http_check": False,
     "servers": [
       {
         "backend_ip": "172.16.112.221",
         "backend_name": "E2E-LB-1-5555",
         "backend_port": "8080"
       }
     ]
   }
 ],
 "default_backend_name": "alpha",
 "enable_bitninja": False,
 "host_target": "164.52.192.128",
 "lb_mode": "HTTP",
 "lb_name": "E2E-LB-155",
 "lb_port": 80,
 "lb_reserve_ip": "",
 "lb_type": "External",
 "node_list_type": "S",
 "plan_name": "E2E-LB-1",
 "scaler_id": "",
 "scaler_port": "",
 "ssl_certificate_id": "",
 "ssl_context": {
   "redirect_to_https": False
 },
 "vpc_list": []
 })
   headers = {
           'Authorization': 'API_Token ',
           'Content-Type': 'application/json',
       }

    response = requests.request("PUT", url, headers=headers, data=payload)

    print(response.text)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Request Body-

{
    "backends": [
      {
          "balance": "source",
          "check_url": "/",
          "domain_name": "localhost",
          "http_check": false,
          "servers": [
              {
                  "backend_ip": "172.16.112.221",
                  "backend_name": "E2E-LB-1-5555",
                  "backend_port": "8080"
              }
          ]
      }
  ],
  "default_backend_name": "alpha",
  "enable_bitninja": false,
  "host_target": "164.52.192.128",
  "lb_mode": "HTTP",
  "lb_name": "E2E-LB-155",
  "lb_port": 80,
  "lb_reserve_ip": "",
  "lb_type": "External",
  "node_list_type": "S",
  "plan_name": "E2E-LB-1",
  "scaler_id": "",
  "scaler_port": "",
  "ssl_certificate_id": "",
  "ssl_context": {
      "redirect_to_https": false
  },
  "vpc_list": []
}

Response Body

{
  "code": 200,
  "data": {
      "appliance_id": 2448,
      "is_credit_sufficient": true
  },
  "errors": {},
  "message": "Success"
}