Auto Scaling

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 Auto Scaling

To get the list of auto scaling send a GET request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey=3fefcfaa-02ef-4be0-b733-f3c3518ee9a0&location=Delhi

PYTHON

1. Python - http.client Example

  import http.client
  import json

  conn = http.client.HTTPSConnection("api.e2enetworks.com")
  payload = ''
 headers = {
 'Authorization': 'api_token',
 'Content-Type': 'application/json',
 }
 conn.request("GET", "/myaccount/api/v1/scaler/scalegroups?apikey={{api}}&location=Delhi", 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/scaler/scalegroups?apikey={{api_key}}&location=Delhi"

   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": "1518",
          "name": "image1-disk-0-301",
          "policy": "CPU>60",
          "policy_measure": "CPU",
          "policy_op": ">",
          "upscale_policy_value": 60,
          "downscale_policy_value": 30,
          "running": 2,
          "desired": 2,
          "provision_status": "Deploying",
          "tags": "",
          "min_nodes": 2,
          "max_nodes": 5,
          "plan_name": "C2.12GB",
          "vm_image_name": "image1-disk-0",
          "wait_for_period": 3,
          "wait_period": 10,
          "cooldown": 150
      },
                  ],
  "errors": {},
  "message": "Success"
}

Create Auto scaling

To create auto scaling to send a POST request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey=3fefcfaa-02ef-4be0-b733-f3c3518ee9a0

PYTHON

1. Python - http.client Example

  import http.client
  import json

  conn = http.client.HTTPSConnection("api.e2enetworks.com")
  payload = json.dumps({
 "desired": 2,
 "max_nodes": 5,
 "min_nodes": 2,
 "name": "image1-disk-0-301",
 "plan_id": "184",
 "plan_name": "C2.12GB",
 "policy": [
   {
     "adjust": 1,
     "cooldown": 150,
     "expression": "CPU>60",
     "period": 10,
     "period_number": 3,
     "type": "CHANGE"
   },
   {
     "adjust": -1,
     "cooldown": 150,
     "expression": "CPU<30",
     "period": 10,
     "period_number": 3,
     "type": "CHANGE"
   }
 ],
 "sku_id": "184",
 "vm_image_id": "8515",
 "vm_image_name": "image1-disk-0",
 "vm_template_id": 11959
 })
 headers = {
 'Authorization': 'api_token',
 'Content-Type': 'application/json',
 }
 conn.request("POST", "/myaccount/api/v1/scaler/scalegroups?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/scaler/scalegroups?apikey={{api_key}}"

   payload = json.dumps({
                         "desired": 2,
                         "max_nodes": 5,
                         "min_nodes": 2,
                         "name": "image1-disk-0-301",
                         "plan_id": "184",
                         "plan_name": "C2.12GB",
                  "policy": [
                          {
                       "adjust": 1,
                       "cooldown": 150,
                       "expression": "CPU>60",
                       "period": 10,
                       "period_number": 3,
                       "type": "CHANGE"
                            },
                     {
                        "adjust": -1,
                        "cooldown": 150,
                        "expression": "CPU<30",
                        "period": 10,
                        "period_number": 3,
                        "type": "CHANGE"
                        }
                       ],
                "sku_id": "184",
               "vm_image_id": "8515",
               "vm_image_name": "image1-disk-0",
               "vm_template_id": 11959
                              })
     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-

{
  "desired": 2,
  "max_nodes": 5,
  "min_nodes": 2,
  "name": "image1-disk-0-301",
  "plan_id": "184",
  "plan_name": "C2.12GB",
  "policy": [
      {
          "adjust": 1,
          "cooldown": 150,
          "expression": "CPU>60",
          "period": 10,
          "period_number": 3,
          "type": "CHANGE"
      },
      {
          "adjust": -1,
          "cooldown": 150,
          "expression": "CPU<30",
          "period": 10,
          "period_number": 3,
          "type": "CHANGE"
      }
  ],
  "sku_id": "184",
  "vm_image_id": "8515",
  "vm_image_name": "image1-disk-0",
  "vm_template_id": 11959
}

Response Body

{
  "code": 200,
  "data": {
      "id": "1518",
      "name": "image1-disk-0-301",
      "plan_name": "C2.12GB",
      "vm_image_name": "image1-disk-0",
      "provision_status": "Deploying",
      "policy": "CPU>60",
      "policy_measure": "CPU",
      "policy_op": ">",
      "upscale_policy_value": 60,
      "downscale_policy_value": 30,
      "running": 0,
      "desired": 2,
      "tags": "",
      "min_nodes": 2,
      "max_nodes": 5,
      "wait_for_period": 3,
      "wait_period": 10,
      "cooldown": 150,
      "customer_id": 0,
      "image_id": 0,
      "plan_id": 0,
      "nodes": []
  },
  "errors": {},
  "message": "Success"
}

Delete Auto scaling

To Delete auto scaling to send a DELETE request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/1516?apikey=3fefcfaa-02ef-4be0-b733-f3c3518ee9a0

PYTHON

1. Python - http.client Example

  import http.client
  import json

  conn = http.client.HTTPSConnection("api.e2enetworks.com")
  payload = ''
 headers = {
 'Authorization': 'api_token',
 'Content-Type': 'application/json',
 }
 conn.request("DELETE", "/myaccount/api/v1/scaler/scalegroups/1516?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/scaler/scalegroups/1516?apikey={{api_key}}"

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


    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": 204,
  "data": {},
  "errors": {},
  "message": "Success"
}