Node API

A Node is a virtual machine. To perform actions and to get information, you shall send requests to the node endpoint.

List of OS Images

To get the list of os, send a GET request to the node Endpoint

https://api.e2enetworks.com/myaccount/api/v1/images/category-list/?apikey={{api_key}}&project_id={{project_id}}&location={{location}}
import requests
import json

url = "https://api.e2enetworks.com/myaccount/api/v1/images/category-list/?apikey={{api_key}}&project_id={{project_id}}&location={{location}}"

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

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

print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

List Of Plans

To get the list of all Plans, send a GET request to the node endpoint

https://api.e2enetworks.com/myaccount/api/v1/images/?display_category=Linux%20Virtual%20Node&category=CentOS&osversion=7&gpu_type=&ng_container=null&os=CentOS&apikey={{api_key}}&project_id={{project_id}}&location={{location}}
import requests
import json

url = "https://api.e2enetworks.com/myaccount/api/v1/images/?display_category=Linux%20Virtual%20Node&category=CentOS&osversion=7&gpu_type=&ng_container=null&os=CentOS&apikey={{api_key}}&project_id={{project_id}}&location={{location}}"

payload = {}
headers = {
  'Accept': 'application/json, text/plain, */*',
  'Authorization': 'Bearer {{Token}}',
  }

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

print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Create a New Node

To create a node, send a POST request to the node endpoint

https://api.e2enetworks.com/myaccount/api/v1/nodes/?apikey={{api_key}}&project_id={{project_id}}

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

Name

Type

Description

Required

name

String

A string used as name for the node.

TRUE

region

String

Identifier of the region you wish to create node in. (Currently, only ncr region is available.)

TRUE

plan

String

Unique identifier that specifies the plan name of the node.

TRUE

image

integer (if using an image ID), or String (if using a public image slug)

Unique image ID of public or private image, or identifier of the public image; which would be the base image for the node.

TRUE

ssh_keys

Array

An array of SSH Key fingerprints or IDs that you wish to include in the root account after the node’s creation.

FALSE

backups

Boolean

A boolean indicating to enable or to disable automated backups. Enabling automated backups is possible only when creating the node.

FALSE

tags

Array

An array of tag names in string format to be associated with node after its creation. Tag names can be new or existing names.

FALSE

is_saved_image

Boolean

A boolean indicating image is saved or base image.

saved_image_template_id

Integer

Template Id of saved image.

cn_id

Integer

committed_sku_id of plan

FALSE

number_of_instances

Integer

Number of nodes you want to launch together and default value is taken as 1.

FALSE

import requests
import json

# Generate API key and auth_token from myaccount
YOUR_API_KEY = ''&project_id={{project_id}}
YOUR_AUTH_TOKEN = '{{Auth_token}}'

# Assign your ssh key
ssh_key = 'rsa AAA= user@host'
url = f'https://api.e2enetworks.com/myaccount/api/v1/nodes/'
headers = {'x-api-key': YOUR_API_KEY, 'Content-Type': 'application/json', 'Authorization' : f'Bearer {YOUR_AUTH_TOKEN}' }

def create_node():
    payload = json.dumps({
            "label": "Default",
            "name": "C2-12GB",
            "region": "ncr",
            "plan":"{{Plan_name}}",
            "image": "{{image_name}}",
            "ssh_keys": [],
            "backups": False,
            "enable_bitninja": False,
            "disable_password": False,
            "is_saved_image": False,
            "saved_image_template_id": None,
            "reserve_ip": "",
            "is_ipv6_availed": False,
            "vpc_id": "",
            "number_of_instances" : 2,
            "default_public_ip": False,
            "ngc_container_id": None,
            "security_group_id": 3482,
            "start_scripts": []
              })

    response = requests.request("POST", url, data=payload, headers=headers)
    print(response.status_code)
    resp = response.content
    print("response=",resp)

create_node()
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
"label": "Default",
"name": "C2-12GB",
"region": "ncr",
"plan":"{{Plan_name}}",
"image": "{{image_name}}",
"ssh_keys": [],
"backups": False,
"enable_bitninja": False,
"disable_password": False,
"is_saved_image": False,
"saved_image_template_id": None,
"reserve_ip": "",
"is_ipv6_availed": False,
"vpc_id": "",
"number_of_instances":2,
"default_public_ip": False,
"ngc_container_id": None,
"security_group_id": 3482,
"start_scripts": []
}

Get Node By ID

To get information regarding any node, send a GET request to the endpoint

https://api.e2enetworks.com/myaccount/api/v1/nodes/<$NODE_ID>/?apikey={{api_key}}&project_id={{project_id}}

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

Name

Type

Description

id

integer

A unique integer identifier created and assigned to the node after its creation.

name

string

The name assigned to the node.

vcpus

integer

The number of virtual CPUs of the node.

disk

integer

The disk space of the node in gigabytes.

locked

boolean

A boolean value denoting whether the node is locked or not. When locked, the feature prevents any user actions on the node. (Currently Unavailable)

created_at

string

The time when node created represented in ISO8601 which includes both the date and time.

status

string

A string that denotes the state of the node: ‘created’, ‘running’, ‘power-off’, or ‘terminate’.

backups

boolean

A boolean value that indicates whether backups are enabled.

public_ip_address/ private_ip_address

object

Information regarding the network configuration of the node.

tags

array

Tags associated with the node, represented as an array. (currently not available)

import requests

url = "https://api.e2enetworks.com/myaccount/api/v1/nodes/{{node_id}}/?apikey={{api_key}}&project_id={{project_id}}"

payload = {}
headers = {
  'Authorization': 'Bearer {{your_auth_token}}',
  'Cookie': 'csrftoken={{your_csrf_token}}; customer_role_auth={{your_customer_role_auth}}; sessionid={{your_session_id}}'
}

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

print(response.text)
// pending

Get Node List

To get the list of nodes in your MyAccount, send a GET request to the endpoint

https://api.e2enetworks.com/myaccount/api/v1/nodes/?apikey={{api_key}}&page_no=1&per_page=2&project_id={{project_id}}

The request returns an array of JSON objects; each JSON object represents the information of each node.

The JSON objects contain the following node attributes:

Name

Type

Description

id

integer

A unique integer identifier created and assigned to the node after its creation.

name

string

The name assigned to the node.

memory

integer

Memory (typically RAM) of the node represented in megabytes.

vcpus

integer

The number of virtual CPUs of the node.

disk

integer

The disk space of the node in gigabytes.

locked

boolean

A boolean value denoting whether the node is locked or not. When locked, the feature prevents any user actions on the node. (Currently Unavailable)

created_at

string

The time when node created represented in ISO8601 which includes both the date and time.

status

string

A string that denotes the state of the node: ‘created’, ‘running’, ‘power-off’, or ‘terminate’.

backup_ids

array

A boolean value that indicates whether backups are enabled.

region

string

Identifier of the region you wish to create node in. (Currently, only ncr region is available.)

image

string

Unique image ID of public or private image, or identifier of the public image; which would be the base image for the node.

public_ip_address/ private_ip_address

string

Information regarding the network configuration of the node.

tags

array

Tags associated with the node, represented as an array.(currenlty not available)

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/nodes/?apikey=API key&location=Delhi&project_id={{project_id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "message": "Success",
    "code": 200,
    "data": [
        {
            "id": 169,
            "name": "node-awa",
            "created_at": "2019-04-23T09:19:28.842209Z",
            "public_ip_address": "101.53.147.102",
            "private_ip_address": "172.16.215.166",
            "backup": false,
            "disk": "60 GB",
            "status": "Create",
            "vcpus": "2",
            "memory": "15.00 GB",
            "plan": "B-2VCPU-8RAM-115DISK",
            "region": "national capitail"
        },
        {
            "id": 170,
            "name": "hgfh",
            "created_at": "2019-04-23T09:48:12.481261Z",
            "public_ip_address": "101.53.147.241",
            "private_ip_address": "172.16.215.84",
            "backup": false,
            "disk": "60 GB",
            "status": "Create",
            "vcpus": "2",
            "memory": "15.00 GB",
            "plan": "B-2VCPU-8RAM-115DISK",
            "region": "national capitail"
        }
    ],
    "errors": {}
}

Delete node

Send a DELETE request to the endpoint to delete a node from your MyAccount.

https://api.e2enetworks.com/myaccount/api/v1/nodes/{{node_id}}/?apikey={{api_key}}&project_id={{project_id}}
import requests
import json

# Generate API key and auth_token from myaccount
YOUR_API_KEY = ''&project_id={{project_id}}
YOUR_AUTH_TOKEN = ''

# Assign your ssh key
ssh_key = 'rsa AAA= user@host'
url = f'https://api.e2enetworks.com/myaccount/api/v1/nodes/'
headers = {'x-api-key': YOUR_API_KEY,'Content-Type': 'application/json', 'Authorization' : f'Bearer {YOUR_AUTH_TOKEN}' }

# Stores the response of the created node
resp = ''

# Stores the id of the VM created
id = ''

# Deletes the node created in the example
def delete_node():
    response = requests.delete(url+f'/{id}/'+f'?apikey={YOUR_API_KEY}', headers = headers)
    print(response.json())

delete_node()
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "message": "Success",
    "code": 200,
    "data": {},
    "errors": {}
}

Update Committed Node Plan

Endpoint:

https://api.e2enetworks.com/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}&project_id={{project_id}}

Request Parameter:

Name

Type

Description

Required

vcn_id

Integer

Node id of customer

True

node_status

String

Values should be auto_renew auto_terminate hourly_billing In auto_renew case, user can pass committed_plan

True

committed_plan

Integer

committed_sku_id of plan

False

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.e2enetworks.com/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}&project_id={{project-id}}',
  'headers': {
    'Content-Type': 'application/json',
    'Cookie': 'csrftoken=EURP4T2iPrftapU6gjAauT7arLzsirOr5t1M1moLgftZDPzM5NEozeVzX43LydVN; sessionid=4h7le9486eesvz70yfppeh02qzwevekn; customer_role_auth=eyJpc19zdGFuZF9hbG9uZV9jdXN0b21lciI6IHRydWUsICJpc19wYXJ0bmVyIjogZmFsc2UsICJpc19wYXJ0bmVyX2N1c3RvbWVyIjogZmFsc2UsICJpc19yb2xlX2VuYWJsZWQiOiB0cnVlLCAiaGlkZV9iaWxsaW5nX2J5X3JvbGUiOiBmYWxzZSwgImlzX3JvbGVfc3VzcGVuZGVkIjogZmFsc2UsICJpc19jdXN0b21lcl9hY3RpdmUiOiB0cnVlLCAiaXNfdmVyaWZpZWQiOiB0cnVlLCAiaXNfc3VzcGVuZGVkIjogZmFsc2V9'
  },
  body: JSON.stringify({"vcn_id":56778,"node_status":"auto_terminate","committed_plan":0})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});