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}}&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. |
|
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 |
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}' }
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()
curl 'https://api.e2enetworks.com/myaccount/api/v1/nodes/{{node_id}}/actions/?apikey={{api_key}}&project_id={{project_id}}&location=Delhi' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {{api_key}}' \
--header 'Authorization: Bearer eyBDd568Y0vydLGvU18SPWHHzbzAgI-id-Ew6ZQdekcf08X1qrOKhVj-066N-skAEwrQcGKuv0aCrfm2-YC_bhbp2O5IX2XAkJjqlqleyGpiwyUGfCq1y1M' \
--data '
{
"label": "Default",
"name": "C2-3GB-CentOS7-241",
"region": "ncr",
"plan": "",
"image": "",
"ssh_keys": [],
"start_scripts": [],
"backups": false,
"enable_bitninja": false,
"disable_password": false,
"is_saved_image": false,
"saved_image_template_id": null,
"reserve_ip": "",
"reserve_ip_pool": "",
"is_ipv6_availed": false,
"vpc_id": "",
"default_public_ip": false,
"ngc_container_id": null,
"security_group_id": 1548,
"is_encryption_required": false
}'
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
content-type: application/json; charset=utf-8
status: 202 Accepted
ratelimit-limit: 1200
ratelimit-remaining: 965
ratelimit-reset: 1415984218
{
"name": "node-awa",
"region": "ncr",
"plan": "B-2VCPU-8RAM-115DISK",
"image": "CentOS-6.10-Distro",
"ssh_keys": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC88ZxOCzW1wP......",
"backups": false,
"tags": []
}
{
"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}}&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) |
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"))
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 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()
curl 'https://api.e2enetworks.com/myaccount/api/v1/nodes/{{node_id}}/actions/?apikey={{api_key}}&project_id={{project_id}}&location=Delhi' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {{api_key}}' \
--header 'Authorization: Bearer eyJhbGciOimVkaUBlMmVuZXR3b3Jrcy5jb20iLCJnaXZlbl9uYW1lIjoic2h1YmhhbSIsImZhbWlseV9uYW1lIjoiQ2hhdHVldHdvcmtzLmNvbSJ9.QCW9zUYn7usXmhLp3kcf08X1qrOKhVj-066N-skAEwrQcGKuv0aCrfm2-YC_bhbp2O5IX2XAkJjqlqleyGpiwyUGfCq1y1M'
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
content-type: application/json; charset=utf-8
status: 202 Accepted
ratelimit-limit: 1200
ratelimit-remaining: 965
ratelimit-reset: 1415984218
{
"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. .. code-block:: bash
https://api.e2enetworks.com/myaccount/api/v1/nodes/<$NODE_ID>/?apikey=10581cd6-####-####-####-79a75b61ecab**&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()
curl --location --request DELETE 'https://api.e2enetworks.com/myaccount/api/v1/nodes/{{node_id}}/actions/?apikey={{api_key}}&project_id={{project_id}}&location=Delhi' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiWlsX3ZlcmlmaWVkIjpmYWxzZSwibmFtZSI6InNodWJoYW0gQ2hhdHVydmVkaSIsInByZWZlcIsImZhbWlseV9uYW1lIjoiQ2hhdHVydmVkaSIsImVyUGfCq1y1M'
--header 'Content-Type: application/json' \
--header 'x-api-key: {{api_key}}' \
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
content-type: application/json; charset=utf-8
status: 202 Accepted
ratelimit-limit: 1200
ratelimit-remaining: 965
ratelimit-reset: 1415984218
{
"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);
});
curl 'https://api.e2enetworks.com/myaccount/api/v1/nodes/{{node_id}}/actions/?apikey={{api_key}}&project_id={{project_id}}&location=Delhi' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {{api_key}}' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1dHVydmVkaSIsImVtYWlsIjoic2h1YmhhbS5jaGF0dXJ2ZWRpQGUyZW5ldHdvcmtzLmNvbCrfm2-YC_bhbp2O5IX2XAkJjqlqleyGpiwyUGfCq1y1M' \
--data '{
"sku_day_id": 229
}'