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 avaliable plans of scale group

To get List of avaliable plans of scale group it send a get request:-

https://api.e2enetworks.com/myaccount/api/v1/images/upgradeimage/27261/?apikey=
{{apikey}}&project_id={{project_id}}&location={{location}}
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/images/upgradeimage/27261/?apikey={{api_key}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
    {
    "name": "C3.8GB",
    "plan": "C3-4vCPU-8RAM-100DISK-C3.96GB-Ubuntu18.04-Delhi",
    "image": "Ubuntu-18.04-Distro",
    "os": {
        "name": "Ubuntu",
        "version": "18.04",
        "image": "Ubuntu-18.04-Distro",
        "category": "Ubuntu"
    },
    "location": "Delhi",
    "specs": {
        "id": "1088",
        "sku_name": "C3.8GB",
        "ram": "8.00",
        "cpu": 4,
        "disk_space": 100,
        "price_per_month": 2263.0,
        "price_per_hour": 3.1,
        "series": "C3",
        "minimum_billing_amount": 0,
        "committed_sku": [
            {
                "committed_sku_id": 2711,
                "committed_sku_name": "90 Days Committed , Rs. 6026.0",
                "committed_node_message": "This committed node will be reserved for next 90 days ( till 04-September-2024 10:14). The cost Rs. 6026.0 of this node will be added in next invoice.",
                "committed_sku_price": 6026.0,
                "committed_upto_date": "04-September-2024 10:14",
                "committed_days": 90
            },
            {
                "committed_sku_id": 2712,
                "committed_sku_name": "183 Days Committed , Rs. 11573.0",
                "committed_node_message": "This committed node will be reserved for next 183 days ( till 06-December-2024 10:14). The cost Rs. 11573.0 of this node will be added in next invoice.",
                "committed_sku_price": 11573.0,
                "committed_upto_date": "06-December-2024 10:14",
                "committed_days": 183
            },
            {
                "committed_sku_id": 2713,
                "committed_sku_name": "365 Days Committed , Rs. 21725.0",
                "committed_node_message": "This committed node will be reserved for next 365 days ( till 06-June-2025 10:14). The cost Rs. 21725.0 of this node will be added in next invoice.",
                "committed_sku_price": 21725.0,
                "committed_upto_date": "06-June-2025 10:14",
                "committed_days": 365
            },
            {
                "committed_sku_id": 2714,
                "committed_sku_name": "1095 Days Committed , Rs. 48880.8",
                "committed_node_message": "This committed node will be reserved for next 1095 days ( till 06-June-2027 10:14). The cost Rs. 48880.8 of this node will be added in next invoice.",
                "committed_sku_price": 48880.8,
                "committed_upto_date": "06-June-2027 10:14",
                "committed_days": 1095
            }
        ],
        "family": "CPU Intensive 3rd Generation"
    },
    "cpu_type": "vCPU",
    "gpu_card_details": {},
    "node_description": "",
    "installed_application_version": {},
    "can_support_bitninja": {
        "show_bitninja": true,
        "bitninja_cost": 760.0
    },
    "bitninja_discount_percentage": 0.0,
    "available_inventory_status": true,
    "currency": "INR",
    "is_blockstorage_attachable": true
}
    }

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={{api_key}}&location=Delhi&project_id={{id}}
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&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
"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

With Elastic Policy

To create an auto scale service with elstic policy set send a POST request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?
apikey={{api_key}}&project_id={{id}}
import http.client
import json

conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"name": "elastic_scale",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"policy": [
    {
    "type": "CHANGE",
    "adjust": 1,
    "expression": "CPU>60",
    "period_number": "3",
    "period": "10",
    "cooldown": "150"
    },
    {
    "type": "CHANGE",
    "adjust": -1,
    "expression": "CPU<30",
    "period_number": "3",
    "period": "10",
    "cooldown": "150"
    }
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
})
headers = {
            'Content-Type': 'application/json',
            'Authorization': 'api_token'
            }
conn.request("POST", "/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "name": "elastic_scale",
    "min_nodes": "2",
    "desired": "2",
    "max_nodes": "5",
    "plan_id": "188",
    "plan_name": "C2.40GB",
    "sku_id": "188",
    "policy": [
        {
            "type": "CHANGE",
            "adjust": 1,
            "expression": "CPU>60",
            "period_number": "3",
            "period": "10",
            "cooldown": "150"
        },
        {
            "type": "CHANGE",
            "adjust": -1,
            "expression": "CPU<30",
            "period_number": "3",
            "period": "10",
            "cooldown": "150"
        }
    ],
    "vm_image_id": "14523",
    "vm_image_name": "C2-40GB-cu-4-image-disk-0",
    "vm_template_id": 19755,
    "my_account_sg_id": 30767
    }

With Schedule Policy

To create an auto scale with schedule policy set send a POST request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?
apikey={{api_key}}&project_id={{id}}
import http.client
import json

conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"name": "schedule_policy",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"scheduled_policy": [
    {
    "type": "CARDINALITY",
    "adjust": 4,
    "recurrence": "0 0 1 * *"
        },
        {
        "type": "CARDINALITY",
        "adjust": "2",
        "recurrence": "0 0 12 1 1"
        }
    ],
    "vm_image_id": "14523",
    "vm_image_name": "C2-40GB-cu-4-image-disk-0",
    "vm_template_id": 19755,
    "my_account_sg_id": 30767
    })
    headers = {
    'Content-Type': 'application/json',
    'Authorization': 'api_token',
    }
    conn.request("POST", "/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}&project_id={{id}}", payload, headers)
    res = conn.getresponse()
    data = res.read()
    print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "name": "schedule_policy",
    "min_nodes": "2",
    "desired": "2",
    "max_nodes": "5",
    "plan_id": "188",
    "plan_name": "C2.40GB",
    "sku_id": "188",
    "scheduled_policy": [
        {
            "type": "CARDINALITY",
            "adjust": 3,
            "recurrence": "0 0 1 * *"
        },
        {
            "type": "CARDINALITY",
            "adjust": "2",
            "recurrence": "0 0 12 1 1"
        }
    ],
    "vm_image_id": "14523",
    "vm_image_name": "C2-40GB-cu-4-image-disk-0",
    "vm_template_id": 19755,
    "my_account_sg_id": 30767
}

With Elastic and Schedule Policy

To create an scale service which has both elastic and schedule policy set send a POST request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/?
apikey={{api_key}}&project_id={{id}}
import http.client
import json

conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"name": "elastic_with_schedule",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"policy": [
    {
    "type": "CHANGE",
    "adjust": 1,
    "expression": "CPU>60",
    "period_number": "3",
    "period": "10",
    "cooldown": "150"
    },
    {
    "type": "CHANGE",
    "adjust": -1,
    "expression": "CPU<30",
    "period_number": "3",
    "period": "10",
    "cooldown": "150"
    }
],
"scheduled_policy": [
    {
    "type": "CARDINALITY",
    "adjust": 3,
    "recurrence": "0 0 1 * *"
    },
    {
    "type": "CARDINALITY",
    "adjust": "2",
    "recurrence": "0 0 12 1 1"
    }
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'api_token',
}
conn.request("POST", "/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "name": "elastic_with_schedule",
    "min_nodes": "2",
    "desired": "2",
    "max_nodes": "5",
    "plan_id": "188",
    "plan_name": "C2.40GB",
    "sku_id": "188",
    "policy": [
        {
            "type": "CHANGE",
            "adjust": 1,
            "expression": "CPU>60",
            "period_number": "3",
            "period": "10",
            "cooldown": "150"
        },
        {
            "type": "CHANGE",
            "adjust": -1,
            "expression": "CPU<30",
            "period_number": "3",
            "period": "10",
            "cooldown": "150"
        }
    ],
    "scheduled_policy": [
        {
            "type": "CARDINALITY",
            "adjust": 3,
            "recurrence": "0 0 1 * *"
        },
        {
            "type": "CARDINALITY",
            "adjust": "2",
            "recurrence": "0 0 12 1 1"
        }
    ],
    "vm_image_id": "14523",
    "vm_image_name": "C2-40GB-cu-4-image-disk-0",
    "vm_template_id": 19755,
    "my_account_sg_id": 30767
}

Delete Auto scaling

To Delete auto scaling to send a DELETE request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/1516/
?apikey={{api_key}}&project_id={{id}}
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}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
"code": 204,
"data": {},
"errors": {},
"message": "Success"
}

Resize Scale Group

To Resize Scale Group it send a PUT request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/11377?apikey=
{{apikey}}&project_id={{project_id}}&location={{location}}
import http.client
import json

conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
conn.request("PUT", "/myaccount/api/v1/scaler/scalegroups/11377?apikey={{api_key}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
"cardinality" = 2
}

Stop Auto Scale Group

To Stop Auto Group it send a PUT request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/11377/stop/?apikey=
{{apikey}}&project_id={{project_id}}&location={{location}}
import http.client
import json

conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
conn.request("PUT", "/myaccount/api/v1/scaler/scalegroups/11377/stop/?apikey={{api_key}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{}

Attach new security group

To Attach a new security group it send a PUT request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/security_groups/11377/?apikey=
{{apikey}}&project_id={{project_id}}&location={{location}}
import http.client
import json

conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
conn.request("PUT", "/myaccount/api/v1/scaler/scalegroups/11377?apikey={{api_key}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
"security_group_id" : 54180
}

Detach new security group

To Detach a new security group it send a DELETE request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/security_groups/11377/?security_group_id=53396&apikey=
{{apikey}}&project_id={{project_id}}&location={{location}}
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/11377?apikey={{api_key}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
"code": 204,
"data": {},
"errors": {},
"message": "Success"
}

List of attached Load Balancers

To get List of attached Load Balancers it send a get request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/lb_details/11377?apikey=
{{apikey}}&project_id={{project_id}}&location={{location}}
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/lb_details/11377?apikey={{api_key}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
 {
"code":200,
"data":[],
"errors":{},
"message":"Currently no Attached Load Balancer available."
 }

List of avaliable security groups

To get List of avaliable security groups it send a get request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/remaining_security_group/11377?apikey=
{{apikey}}&project_id={{project_id}}&location={{location}}
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/remaining_security_group/11377?apikey={{api_key}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
"code": 400,
"data": {},
"errors": "Logs Does not exist!",
"message": "Bad Request"
}

Logs

To get Logs of a scale group it send a get request:-

https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/logs/11377?apikey=
{{apikey}}&project_id={{project_id}}&location={{location}}
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/logs/11377?apikey={{api_key}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "code": 200,
    "data": [
        {
            "created_at": "2024-06-06T15:33:01",
            "state": "New state: DEPLOYING_NETS"
        },
        {
            "created_at": "2024-06-06T15:33:01",
            "state": "New state: DEPLOYING"
        }
    ],
    "errors": {},
    "message": "Success"
}