Node

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

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}}

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.

backups

Boolean

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

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.

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

CURL

curl -X POST \
  'https://api.e2enetworks.com/myaccount/api/v1/nodes/?apikey={{api_key}}' \
  -H 'Authorization: Bearer     eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldU....' \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 5a201495-####-####-####-########-ca50e4082bb1' \
  -H 'cache-control: no-cache' \
  -d '{"name":"abc",
"region":"ncr",
"plan":"C-2vCPU-8RAM-60DISK-C2.8GB-CentOS-7.5",
"image":"CentOS-7.5-Distro",
"ssh_keys":["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC88ZxOC......"],
"backups":false,
"disable_password":true}'
"start_scripts":[]}'

PHP

1. PHP HttpRequest Example

$request = new HttpRequest();
$request->setUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'apikey' => '10581cd6-####-####-####-79a75b61ecab'
));

$request->setHeaders(array(
  'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5......',
  'Content-Type' => 'application/json'
));

$request->setBody('{
  "name": "node-awa",
  "region": "ncr",
  "plan": "B-2VCPU-8RAM-115DISK",
  "image":"CentOS-6.10-Distro",
  "ssh_keys": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQ.......",
  "backups": false,
  "tags": [],
"is_saved_image":true,
"saved_image_template_id":4165
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
2. PHP pecl_http Example

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{
  "name": "node-awa",
  "region": "ncr",
  "plan": "B-2VCPU-8RAM-115DISK",
  "image":"CentOS-6.10-Distro",
  "ssh_keys": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC.....",
  "backups": false,
  "tags": [],
"is_saved_image":true,
"saved_image_template_id":4165
}');

$request->setRequestUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setQuery(new http\QueryString(array(
  'apikey' => '{{api_key}}'
)));

$request->setHeaders(array(
  'Authorization' => 'Bearer eyJhbGciOiJSUzI1.....',
  'Content-Type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
3. PHP CURL Example

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.e2enetworks.com/myaccount/api/v1/nodes/?apikey={{api_key}}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\n  \"name\": \"node-awa\",\n  \"region\": \"ncr\",\n  \"plan\": \"B-2VCPU-8RAM-115DISK\",\n  \"image\": \"CentOS-6.10-Distro\",\n  \"ssh_keys\": \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC88ZxOCzW1wP/MRJXdtLmzEgPfVhvHJsrheWtPcsG5qXJ2ztUqSCEIky58qIbbcBnDPySkXMj+VqPKIXcMeV2KwO/QnXS2R3uoO0gHcTEux5IDdmqcEVTmEP3tb0V7EJecLbRDm8uuox+/cjCvLSGEB5bIGhUm8a6kDs+xFpOHgKm4JcF9Vpvev7BjIYWaaLNh5+lCm3uM0t/mGRGacv6mSbm7PXGI2MC7aL2EQdb7/OJe81O6qg9wwNyyrmgAnkYh8yhexIUVzYDO2pKK5IJrp1qZlJQap054h2ihW7u22CQSe9nEwDdNsaFjUwN5eWkUGlhLTNbyl+O2w2a7oNeV e2e@e2e-HP-Laptop-15-da0xxx\",\n  \"backups\": false,\n  \"tags\": []\n ,\n  \"is_saved_image\":true,\n \"saved_image_template_id\":4165}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer eyJhbGciOiJSUzI1NiIsI.....",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

NODEJS

1. Nodejs Native Example

                         var http = require("http");
var options = {
  "method": "POST",
  "hostname": [
    "api",
    "e2enetworks",
    "com"
  ],
  "path": [
    "myaccount",
    "nodes",
    "1.0"
  ],
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5c......"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ name: 'node-awa',
  region: 'ncr',
  plan: 'B-2VCPU-8RAM-115DISK',
  image: 'CentOS-6.10-Distro',
  ssh_keys: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC.......',
  backups: false,
  tags: [],
  is_saved_image:true,
  saved_image_template_id:4165}));
req.end();
        2. NodeJs Request Example
var request = require("request");
  var options = { method: 'POST',
  url: 'https://api.e2enetworks.com/myaccount/api/v1/nodes/',
  qs: { apikey: '{{api_key}}' },
  headers:
   { 'Postman-Token': '6069de25-e756-4c0d-a114-6914559d5ad9',
     'cache-control': 'no-cache',
     Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR.....',
     'Content-Type': 'application/json' },
  body:
   { name: 'node-awa',
     region: 'ncr',
     plan: 'B-2VCPU-8RAM-115DISK',
     image: 'CentOS-6.10-Distro',
     ssh_keys: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB......',
     backups: false,
     tags: [],
         is_saved_image:true,
         saved_image_template_id:4165},
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
3. NodeJs Unirest Example

                         var unirest = require("unirest");
var req = unirest("POST", "https://api.e2enetworks.com/myaccount/api/v1/nodes/");
req.query({
  "apikey": "{{api_key}}"
});
req.headers({
  "Postman-Token": "8ff6015a-300a-444d-b9cf-455333c40fd7",
  "cache-control": "no-cache",
  "Authorization": "Bearer eyJhbGciOiJSUzI1NiI......",
  "Content-Type": "application/json"
});

req.type("json");
req.send({
  "name": "node-awa",
  "region": "ncr",
  "plan": "B-2VCPU-8RAM-115DISK",
  "image": "CentOS-6.10-Distro",
  "ssh_keys": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB......",
  "backups": false,
  "tags": [],
  "is_saved_image":true,
  "saved_image_template_id":4165
});

req.end(function (res) {
  if (res.error) throw new Error(res.error);

  console.log(res.body);
});

PYTHON

1. Python - http.client Example

        import requests
        import json

        # Generate API key and auth_token from myaccount
        YOUR_API_KEY = ''
        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}' }

        def create_node():
            payload = json.dumps({
                    "label": "Default",
                    "name": "C2-12GB",
                    "region": "ncr",
                    "plan": "C-4vCPU-12RAM-100DISK-C2.12GB-CentOS-7",
                    "image": "CentOS-7-Distro",
                    "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": "",
                    "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()

Headers

Request Headers

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

Response Headers

content-type: application/json; charset=utf-8
status: 202 Accepted
ratelimit-limit: 1200
ratelimit-remaining: 965
ratelimit-reset: 1415984218

Body

Request Body

{
  "name": "node-awa",
  "region": "ncr",
  "plan": "B-2VCPU-8RAM-115DISK",
  "image": "CentOS-6.10-Distro",
  "ssh_keys": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC88ZxOCzW1wP......",
  "backups": false,
  "tags": []
}

Response Body

{
        "message": "Success",
        "code": 200,
        "data": {
            "id": 14962,
            "name": "centos-test",
            "created_at": "2019-06-04T12:07:13.436504Z",
            "public_ip_address": "101.53.157.223",
            "private_ip_address": "172.16.107.121",
            "backup": false,
            "disk": "115 GB",
            "status": "Create",
            "vcpus": "2",
            "memory": "8.00 GB",
            "plan": "B-2VCPU-8RAM-115DISK",
            "region": "ncr",
            "is_locked": false
        },
        "errors": {}
    }

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}}

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)

CURL

curl -X GET 'https://api.e2enetworks.com/myaccount/api/v1/nodes/169/?apikey={{api_key}}' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVbWZZQ3FvcXRPUWVNZmJoTmxFIn0.eyJqdGkiOiJjYmE3Njc5Zi1mOWFhLTQzZGEtYWNiMi1hNzBlZGEwN2Q3ODkiLCJleHAiOjE1ODc1NDA4MzMsIm5iZiI6MCwiaWF0IjoxNTU2MDA0ODMzLCJpc3MiOiJodHRwOi8vMTcyLjE2LjIxNS45NTo4MDgwL2F1dGgvcmVhbG1zL2FwaW1hbiIsImF1ZCI6ImFwaW1hbiIsInN1YiI6IjMxOWU1ZGExLTZmYzItNDY2ZS1iNDI4LTRmOTViOTRlNDMzMCIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFwaW1hbiIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6ImY2YTUxNTQ5LWRkMjYtNDVkYS04YWI0LTlhNTZjOWY3NTUyYyIsImFjciI6IjEiLCJjbGllbnRfc2Vzc2lvbiI6IjViOWJlMjY4LWE1ZDAtNGMxMC05NWQ0LTdhNzU5NTNkODlhMCIsImFsbG93ZWQtb3JpZ2lucyI6WyIqIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJ1bWFfYXV0aG9yaXphdGlvbiIsImFwaXVzZXIiXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50Iiwidmlldy1wcm9maWxlIl19fSwibmFtZSI6IkF3YWRoZXNoIEt1bWFyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiYXdhZGhlc2gua3VtYXIrMUBlMmVuZXR3b3Jrcy5jb20iLCJnaXZlbl9uYW1lIjoiQXdhZGhlc2giLCJmYW1pbHlfbmFtZSI6Ikt1bWFyIiwiZW1haWwiOiJhd2FkaGVzaC5rdW1hcisxQGUyZW5ldHdvcmtzLmNvbSJ9.Hp9VED8hYAbF9XbNQn_WyhCHUim2ui5jNdSRG_lP9B_7gU1YXLsHotupJr3iEJb7FC1XbeoKobwv9PpPJOtyiNUvEPWBza5ir_U737ujdD-NYSzUX-412sTqktjdKqcR78XfpmCIDE-5MeHf5cC3atSvP20XGh4T7d1CeL3oSRE'

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.

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)

CURL

curl -X GET 'https://api.e2enetworks.com/myaccount/api/v1/nodes/?apikey={{api_key}}&page=1&per_page=2' -H 'Authorization: Bearer eyJhbGciOiJSUzI1N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_lP9B_7gU1YXLsHotupJr3iEJb7FC1XbeoKobwv9PpPJOtyiNUvEPWBza5ir_U737ujdD-   NYSzUX-412sTqktjdKqcR78XfpmCIDE-5MeHf5cC3atSvP20XGh4T7d1CeL3oSRE'

PHP

1. PHP HttpRequest Example

                        $request = new HttpRequest();
$request->setUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'apikey' => '10581cd6-####-####-####-79a75b61ecab',
  'page_no' => '1',
  'per_page' => '2'
));

$request->setHeaders(array(
  'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI.....'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
2. PHP pecl_http Example

                        $client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
  'apikey' => '{{api_key}}',
  'page_no' => '1',
  'per_page' => '2'
)));

$request->setHeaders(array(
  'Authorization' => 'Bearer eyJhbGciOiJSUzI1Ni.......'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
3. PHP CURL Example

                        $curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.e2enetworks.com/myaccount/api/v1/nodes/?apikey={{api_key}}&page_no=1&per_page=2",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5...."
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

NODEJS

1. Nodejs Native Example

var http = require("http");
var options = {
  "method": "GET",
  "hostname": [
    "api",
    "e2enetworks",
    "com"
  ],
  "path": [
    "myaccount",
    "nodes",
    "1.0"
  ],
  "headers": {
    "Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5....."
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
2. NodeJs Request Example:

var request = require("request");
var options = { method: 'GET',
  url: 'https://api.e2enetworks.com/myaccount/api/v1/nodes/',
  qs:
   { apikey: '{{api_key}}',
     page_no: '1',
     per_page: '2' },
  headers:
   { 'Postman-Token': '1cf35aa2-567b-44d6-aacd-ec9cfdb7b76d',
     'cache-control': 'no-cache',
     Authorization: 'Bearer eyJhbGciOiJSUz.......' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
3. NodeJs Unirest Example:

 var unirest = require("unirest");
var req = unirest("GET", "https://api.e2enetworks.com/myaccount/api/v1/nodes/");

req.query({
  "apikey": "{{api_key}}",
  "page_no": "1",
  "per_page": "2"
});

req.headers({
  "Postman-Token": "97eade46-a2c2-4362-9bda-a35a720742b8",
  "cache-control": "no-cache",
  "Authorization": "Bearer eyJhbGciOiJSUzI1NiIsIn....."
});


req.end(function (res) {
  if (res.error) throw new Error(res.error);

  console.log(res.body);
});

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/nodes/?apikey=API key&location=Delhi", payload, headers)
       res = conn.getresponse()
       data = res.read()
       print(data.decode("utf-8"))

To check the status of node

import requests
import json

# Generate API key and auth_token from myaccount
YOUR_API_KEY = ''
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 id of the VM created
id = ''

# Shows the status of the node
def check_node():
    response = requests.get(url+f'/{id}/'+f'?apikey={YOUR_API_KEY}', headers = headers)
    print(response)

check_node()

Headers

Request Headers

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

Response Headers

content-type: application/json; charset=utf-8
status: 200 OK
ratelimit-limit: 1200
ratelimit-remaining: 947
ratelimit-reset: 1415984218

Body

Response Body

Response:
{
    "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=10581cd6-####-####-####-79a75b61ecab

CURL

curl -X DELETE 'https://api.e2enetworks.com/myaccount/api/v1/nodes/171/?apikey={{api_key}}' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVbWZZQ3FvcXRPUWVNZmJoTmxFIn0.eyJqdGkiOiJjYmE3Njc5Zi1mOWFhLTQ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HP

1. PHP HttpRequest Example

                                $request = new HttpRequest();
$request->setUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/171/');
$request->setMethod(HTTP_METH_DELETE);

$request->setQueryData(array(
  'apikey' => '{{api_key}}'
));

$request->setHeaders(array(
  'Authorization' => 'Bearer eyJhbGciOiJSUzI......'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
2. PHP pecl_http Example

                                $client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/171/');
$request->setRequestMethod('DELETE');
$request->setQuery(new http\QueryString(array(
  'apikey' => '{{api_key}}'
)));

$request->setHeaders(array(
  'Authorization' => 'Bearer eyJhbGciOiJSUzI1Ni.......'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
3. PHP CURL Example

                                $curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/?apikey={{api_key}}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer eyJhbGciOiJSUzI1NiIs......"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

NODEJS

1. Nodejs Native Example

var http = require("http");

var options = {
  "method": "DELETE",
  "hostname": [
    "api",
    "e2enetworks",
    "com"
  ],
  "path": [
    "myaccount",
    "nodes",
    "1.0",
    "171",
    ""
  ],
  "headers": {
    "Authorization": "Bearer eyJhbGciOiJSUzI........"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
2. NodeJs Request Example:

var request = require("request");

var options = { method: 'DELETE',
  url: 'https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/',
  qs: { apikey: '{{api_key}}' },
  headers:
   {
     Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsIn.....' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
3. NodeJs Unirest Example:

var unirest = require("unirest");
var req = unirest("DELETE", "https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/");

req.query({
  "apikey": "{{api_key}}"
});

req.headers({
  "Authorization": "Bearer eyJhbGciOiJSUzI1Ni...."
});


req.end(function (res) {
  if (res.error) throw new Error(res.error);

  console.log(res.body);
});

PYTHON

1. Python - http.client Example

           import requests
           import json

           # Generate API key and auth_token from myaccount
           YOUR_API_KEY = ''
           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()

Headers

Request Headers

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

Response Headers

content-type: application/octet-stream
status: 204 No Content
ratelimit-limit: 1200
ratelimit-remaining: 901
ratelimit-reset: 1415984218

Body

Response Body

Response:
{
    "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}}

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

Response Result:

CURL

curl --location --request POST 'https://api.e2enetworks.com/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}' \
-header 'Content-Type: application/json' \
--header 'Cookie: csrftoken=EURP4T2iPrftapU6gjAauT7arLzsirOr5t1M1moLgftZDPzM5NEozeVzX43LydVN; sessionid=4h7le9486eesvz70yfppeh02qzwevekn; customer_role_auth=eyJpc19zdGFuZF9hbG9uZV9jdXN0b21lciI6IHRydWUsICJpc19wYXJ0bmVyIjogZmFsc2UsICJpc19wYXJ0bmVyX2N1c3RvbWVyIjogZmFsc2UsICJpc19yb2xlX2VuYWJsZWQiOiB0cnVlLCAiaGlkZV9iaWxsaW5nX2J5X3JvbGUiOiBmYWxzZSwgImlzX3JvbGVfc3VzcGVuZGVkIjogZmFsc2UsICJpc19jdXN0b21lcl9hY3RpdmUiOiB0cnVlLCAiaXNfdmVyaWZpZWQiOiB0cnVlLCAiaXNfc3VzcGVuZGVkIjogZmFsc2V9' \
--data-raw '{"vcn_id":56778,"node_status":"auto_terminate","committed_plan":0}'

PHP_CURL

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.e2enetworks.com/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{"vcn_id":56778,"node_status":"auto_terminate","committed_plan":0}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Cookie: csrftoken=EURP4T2iPrftapU6gjAauT7arLzsirOr5t1M1moLgftZDPzM5NEozeVzX43LydVN; sessionid=4h7le9486eesvz70yfppeh02qzwevekn; customer_role_auth=eyJpc19zdGFuZF9hbG9uZV9jdXN0b21lciI6IHRydWUsICJpc19wYXJ0bmVyIjogZmFsc2UsICJpc19wYXJ0bmVyX2N1c3RvbWVyIjogZmFsc2UsICJpc19yb2xlX2VuYWJsZWQiOiB0cnVlLCAiaGlkZV9iaWxsaW5nX2J5X3JvbGUiOiBmYWxzZSwgImlzX3JvbGVfc3VzcGVuZGVkIjogZmFsc2UsICJpc19jdXN0b21lcl9hY3RpdmUiOiB0cnVlLCAiaXNfdmVyaWZpZWQiOiB0cnVlLCAiaXNfc3VzcGVuZGVkIjogZmFsc2V9'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

PHP_HTTP_REQUEST_2

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.e2enetworks.com/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Content-Type' => 'application/json',
  'Cookie' => 'csrftoken=EURP4T2iPrftapU6gjAauT7arLzsirOr5t1M1moLgftZDPzM5NEozeVzX43LydVN; sessionid=4h7le9486eesvz70yfppeh02qzwevekn; customer_role_auth=eyJpc19zdGFuZF9hbG9uZV9jdXN0b21lciI6IHRydWUsICJpc19wYXJ0bmVyIjogZmFsc2UsICJpc19wYXJ0bmVyX2N1c3RvbWVyIjogZmFsc2UsICJpc19yb2xlX2VuYWJsZWQiOiB0cnVlLCAiaGlkZV9iaWxsaW5nX2J5X3JvbGUiOiBmYWxzZSwgImlzX3JvbGVfc3VzcGVuZGVkIjogZmFsc2UsICJpc19jdXN0b21lcl9hY3RpdmUiOiB0cnVlLCAiaXNfdmVyaWZpZWQiOiB0cnVlLCAiaXNfc3VzcGVuZGVkIjogZmFsc2V9'
));
$request->setBody('{"vcn_id":56778,"node_status":"auto_terminate","committed_plan":0}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}

PHP_PECL_HTTP

<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://api.e2enetworks.com/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{"vcn_id":56778,"node_status":"auto_terminate","committed_plan":0}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
  'Content-Type' => 'application/json',
  'Cookie' => 'csrftoken=EURP4T2iPrftapU6gjAauT7arLzsirOr5t1M1moLgftZDPzM5NEozeVzX43LydVN; sessionid=4h7le9486eesvz70yfppeh02qzwevekn; customer_role_auth=eyJpc19zdGFuZF9hbG9uZV9jdXN0b21lciI6IHRydWUsICJpc19wYXJ0bmVyIjogZmFsc2UsICJpc19wYXJ0bmVyX2N1c3RvbWVyIjogZmFsc2UsICJpc19yb2xlX2VuYWJsZWQiOiB0cnVlLCAiaGlkZV9iaWxsaW5nX2J5X3JvbGUiOiBmYWxzZSwgImlzX3JvbGVfc3VzcGVuZGVkIjogZmFsc2UsICJpc19jdXN0b21lcl9hY3RpdmUiOiB0cnVlLCAiaXNfdmVyaWZpZWQiOiB0cnVlLCAiaXNfc3VzcGVuZGVkIjogZmFsc2V9'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

NodeJS_Native

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'api.e2enetworks.com',
  'path': '/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}',
  'headers': {
    'Content-Type': 'application/json',
    'Cookie': 'csrftoken=EURP4T2iPrftapU6gjAauT7arLzsirOr5t1M1moLgftZDPzM5NEozeVzX43LydVN; sessionid=4h7le9486eesvz70yfppeh02qzwevekn; customer_role_auth=eyJpc19zdGFuZF9hbG9uZV9jdXN0b21lciI6IHRydWUsICJpc19wYXJ0bmVyIjogZmFsc2UsICJpc19wYXJ0bmVyX2N1c3RvbWVyIjogZmFsc2UsICJpc19yb2xlX2VuYWJsZWQiOiB0cnVlLCAiaGlkZV9iaWxsaW5nX2J5X3JvbGUiOiBmYWxzZSwgImlzX3JvbGVfc3VzcGVuZGVkIjogZmFsc2UsICJpc19jdXN0b21lcl9hY3RpdmUiOiB0cnVlLCAiaXNfdmVyaWZpZWQiOiB0cnVlLCAiaXNfc3VzcGVuZGVkIjogZmFsc2V9'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({"vcn_id":56778,"node_status":"auto_terminate","committed_plan":0});

req.write(postData);

req.end();

NodeJS Request

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.e2enetworks.com/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}',
  '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);
});

NodeJS Unirest

var unirest = require('unirest');
var req = unirest('POST', 'https://api.e2enetworks.com/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}')
  .headers({
    'Content-Type': 'application/json',
    'Cookie': 'csrftoken=EURP4T2iPrftapU6gjAauT7arLzsirOr5t1M1moLgftZDPzM5NEozeVzX43LydVN; sessionid=4h7le9486eesvz70yfppeh02qzwevekn; customer_role_auth=eyJpc19zdGFuZF9hbG9uZV9jdXN0b21lciI6IHRydWUsICJpc19wYXJ0bmVyIjogZmFsc2UsICJpc19wYXJ0bmVyX2N1c3RvbWVyIjogZmFsc2UsICJpc19yb2xlX2VuYWJsZWQiOiB0cnVlLCAiaGlkZV9iaWxsaW5nX2J5X3JvbGUiOiBmYWxzZSwgImlzX3JvbGVfc3VzcGVuZGVkIjogZmFsc2UsICJpc19jdXN0b21lcl9hY3RpdmUiOiB0cnVlLCAiaXNfdmVyaWZpZWQiOiB0cnVlLCAiaXNfc3VzcGVuZGVkIjogZmFsc2V9'
  })
  .send(JSON.stringify({"vcn_id":56778,"node_status":"auto_terminate","committed_plan":0}))
  .end(function (res) {
    if (res.error) throw new Error(res.error);
    console.log(res.raw_body);
  });