Action On Node¶
To perform an action, such as Power On, Power Off, Reboot, reinstall and enable recovery mode/disable recovery mode on a node.
Enable Recovery mode¶
To enable recovery mode on an existing Node send a POST request to the endpoint
https://api.e2enetworks.com/myaccount/api/v1/nodes/96667/actions/?apikey={{apikey}}
Attributes and respective values required to send this POST request are:
Name | Type | Description | Required |
---|---|---|---|
type | string | A string denotes the type of the node its enable recovery mode or disable recovery mode . | True |
The request returns a JSON object that contains the following attributes:
Name | Type | Description |
---|---|---|
id | Integer | Information regarding the node. |
created_at | integer | A string represents both the date and time when the recovery mode is created. |
state | string | A string that denotes the state of the node. |
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"type": "enable_recovery_mode"
})
headers = {
'Authorization': 'API_Token ',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/nodes/{{Node_id}}/actions/?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/nodes/{{Node_id}}/actions/?apikey=API_Key"
payload = json.dumps({
"type": "enable_recovery_mode"
})
headers = {
'Authorization': 'API_Token ',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Disable Recovery mode¶
To Disable recovery mode on an existing Node send a POST request to the endpoint
https://api.e2enetworks.com/myaccount/api/v1/nodes/{{Node_id}}/actions/?apikey={{apikey}}
Attributes and respective values required to send this POST request are:
Name | Type | Description | Required |
---|---|---|---|
type | string | A string denotes the type of the node its enable recovery mode or disable recovery mode . | True |
The request returns a JSON object that contains the following attributes:
Name | Type | Description |
---|---|---|
id | Integer | Information regarding the node. |
created_at | integer | A string represents both the date and time when the recovery mode is created. |
state | string | A string that denotes the state of the node. |
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"type": "disable_recovery_mode"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/nodes/{{node_id}}/actions/?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/nodes/{{node_id}}/actions/?apikey=API_Key"
payload = json.dumps({
"type": "disable_recovery_mode"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Reinstall Node¶
To Reinstall ** on an existing Node send a **POST request to the endpoint
https://api.e2enetworks.com/myaccount/api/v1/nodes/{{Node_id}}/actions/?apikey={{apikey}}
Attributes and respective values required to send this POST request are:
Name | Type | Description | Required |
---|---|---|---|
type | string | A string denotes the type of the node its reinstall . | True |
The request returns a JSON object that contains the following attributes:
Name | Type | Description |
---|---|---|
id | Integer | Information regarding the node. |
created_at | integer | A string represents both the date and time when the recovery mode is created. |
state | string | A string that denotes the state of the node. |
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"type": "reinstall"
})
headers = {
'Authorization': 'API_Token ',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/nodes/{{Node_id}}/actions/?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/nodes/{{Node_id}}/actions/?apikey=API_Key"
payload = json.dumps({
"type": "reinstall"
})
headers = {
'Authorization': 'API_Token ',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Reboot Node¶
To reboot on an existing Node send a POST request to the endpoint https://api.e2enetworks.com/myaccount/api/v1/nodes/<$NODE_ID>/actions/?apikey={{API_Key}}
Set the “type” attribute to reboot.
Name | Type | Description | Required |
---|---|---|---|
type | string | Must be reboot | TRUE |
CURL¶
curl -X POST 'https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/?apikey={{apikey}}' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSl........'-H 'Content-Type: application/json' -d '{
"type": "reboot"
}'
PHP¶
1. PHP HttpRequest Example:
$request = new HttpRequest();
$request->setUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'apikey' => {{apikey}}
));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVbWZZQ3FvcXRPUWVNZmJoTmxFIn0.eyJqdGkiOiJjYmE3Njc5Zi1mOWFhLTQzZGEtYWNiMi1hNzBlZGEwN2Q3ODkiLCJleHAiOjE1ODc1NDA4MzMsIm5iZiI6MCwiaWF0IjoxNTU2MDA0ODMzLCJpc3MiOiJodHRwOi8vMTcyLjE2LjIxNS45NTo4MDgwL2F1dGgvcmVhbG1zL2FwaW1hbiIsImF1ZCI6ImFwaW1hbiIsInN1YiI6IjMxOWU1ZGExLTZmYzItNDY2ZS1iNDI4LTRmOTViOTRlNDMzMCIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFwaW1hbiIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6ImY2YTUxNTQ5LWRkMjYtNDVkYS04YWI0LTlhNTZjOWY3NTUyYyIsImFjciI6IjEiLCJjbGllbnRfc2Vzc2lvbiI6IjViOWJlMjY4LWE1ZDAtNGMxMC05NWQ0LTdhNzU5NTNkODlhMCIsImFsbG93ZWQtb3JpZ2lucyI6WyIqIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJ1bWFfYXV0aG9yaXphdGlvbiIsImFwaXVzZXIiXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50Iiwidmlldy1wcm9maWxlIl19fSwibmFtZSI6IkF3YWRoZXNoIEt1bWFyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiYXdhZGhlc2gua3VtYXIrMUBlMmVuZXR3b3Jrcy5jb20iLCJnaXZlbl9uYW1lIjoiQXdhZGhlc2giLCJmYW1pbHlfbmFtZSI6Ikt1bWFyIiwiZW1haWwiOiJhd2FkaGVzaC5rdW1hcisxQGUyZW5ldHdvcmtzLmNvbSJ9.Hp9VED8hYAbF9XbNQn_WyhCHUim2ui5jNdSRG_lP9B_7gU1YXLsHotupJr3iEJb7FC1XbeoKobwv9PpPJOtyiNUvEPWBza5ir_U737ujdD-NYSzUX-412sTqktjdKqcR78XfpmCIDE-5MeHf5cC3atSvP20XGh4T7d1CeL3oSRE'
));
$request->setBody('{
"type": "reboot"
}');
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('{
"type": "reboot"
}');
$request->setRequestUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setQuery(new http\QueryString(array(
'apikey' => {{apikey}}
)));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer Token ...'
));
$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/169/actions/?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 \"type\": \"reboot\"\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer Token..",
"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",
"169",
"actions",
""
],
"headers": {
"Authorization": "Bearer Token...",
"Content-Type": "application/json"
}
};
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({ type: 'reboot' }));
req.end();
2. NodeJs Request Example
var request = require("request");
var options = { method: 'POST',
url: 'https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/',
qs: { apikey: 'Api_key' },
headers:
{
'Content-Type': 'application/json',
Authorization: 'Bearer Token...' },
body: { type: 'reboot' },
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/169/actions/");
req.query({
"apikey": "Api_key"
});
req.headers({
"Postman-Token": "eb9afcd9-38ca-4872-9eb4-85c5f3531429",
"cache-control": "no-cache",
"Authorization": "Bearer Token...",
"Content-Type": "application/json"
});
req.type("json");
req.send({
"type": "reboot"
});
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
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"type": "reboot"
})
headers = {
'Authorization': 'API_Token ',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/nodes/{{Node_id}}/actions/?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/nodes/{{Node_id}}/actions/?apikey=API_Key"
payload = json.dumps({
"type": "reboot"
})
headers = {
'Authorization': 'API_Token ',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Power-Off Node¶
To Power-Off on an existing Node send a POST request to the endpoint https://api.e2enetworks.com/myaccount/api/v1/nodes/<$NODE_ID>/actions/?apikey={{Api_key}}
Name | Type | Description | Required |
---|---|---|---|
type | string | Must be power_off | TRUE |
Set the “type” attribute to power_off.
CURL¶
curl -X POST 'https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/?apikey={{Api_Key}}' -H 'Authorization: Bearer Token...'-H 'Content-Type: application/json' -d '{
"type": "power_off"
}
PHP¶
1. PHP HttpRequest Example
$request = new HttpRequest();
$request->setUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'apikey' => {{apikey}}
));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6IC..............'
));
$request->setBody('{
"type": "power_off"
}');
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('{
"type": "power_off"
}');
$request->setRequestUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setQuery(new http\QueryString(array(
'apikey' => {{apikey}}
)));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOi..........'
));
$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/169/actions/?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 \"type\": \"power_off\"\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVbWZZQ3FvcXRPUWVNZmJoTmxFIn0.eyJqdGkiOiJjYmE3Njc5Zi1mOWFhLTQzZGEtYWNiMi1hNzBlZGEwN2Q3ODkiLCJleHAiOjE1ODc1NDA4MzMsIm5iZiI6MCwiaWF0IjoxNTU2MDA0ODMzLCJpc3MiOiJodHRwOi8vMTcyLjE2LjIxNS45NTo4MDgwL2F1dGgvcmVhbG1zL2FwaW1hbiIsImF1ZCI6ImFwaW1hbiIsInN1YiI6IjMxOWU1ZGExLTZmYzItNDY2ZS1iNDI4LTRmOTViOTRlNDMzMCIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFwaW1hbiIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6ImY2YTUxNTQ5LWRkMjYtNDVkYS04YWI0LTlhNTZjOWY3NTUyYyIsImFjciI6IjEiLCJjbGllbnRfc2Vzc2lvbiI6IjViOWJlMjY4LWE1ZDAtNGMxMC05NWQ0LTdhNzU5NTNkODlhMCIsImFsbG93ZWQtb3JpZ2lucyI6WyIqIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJ1bWFfYXV0aG9yaXphdGlvbiIsImFwaXVzZXIiXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50Iiwidmlldy1wcm9maWxlIl19fSwibmFtZSI6IkF3YWRoZXNoIEt1bWFyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiYXdhZGhlc2gua3VtYXIrMUBlMmVuZXR3b3Jrcy5jb20iLCJnaXZlbl9uYW1lIjoiQXdhZGhlc2giLCJmYW1pbHlfbmFtZSI6Ikt1bWFyIiwiZW1haWwiOiJhd2FkaGVzaC5rdW1hcisxQGUyZW5ldHdvcmtzLmNvbSJ9.Hp9VED8hYAbF9XbNQn_WyhCHUim2ui5jNdSRG_lP9B_7gU1YXLsHotupJr3iEJb7FC1XbeoKobwv9PpPJOtyiNUvEPWBza5ir_U737ujdD-NYSzUX-412sTqktjdKqcR78XfpmCIDE-5MeHf5cC3atSvP20XGh4T7d1CeL3oSRE",
"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",
"169",
"actions",
""
],
"headers": {
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVbWZZQ3FvcXRPUWVNZmJoTmxFIn0.eyJqdGkiOiJjYmE3Njc5Zi1mOWFhLTQzZGEtYWNiMi1hNzBlZGEwN2Q3ODkiLCJleHAiOjE1ODc1NDA4MzMsIm5iZiI6MCwiaWF0IjoxNTU2MDA0ODMzLCJpc3MiOiJodHRwOi8vMTcyLjE2LjIxNS45NTo4MDgwL2F1dGgvcmVhbG1zL2FwaW1hbiIsImF1ZCI6ImFwaW1hbiIsInN1YiI6IjMxOWU1ZGExLTZmYzItNDY2ZS1iNDI4LTRmOTViOTRlNDMzMCIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFwaW1hbiIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6ImY2YTUxNTQ5LWRkMjYtNDVkYS04YWI0LTlhNTZjOWY3NTUyYyIsImFjciI6IjEiLCJjbGllbnRfc2Vzc2lvbiI6IjViOWJlMjY4LWE1ZDAtNGMxMC05NWQ0LTdhNzU5NTNkODlhMCIsImFsbG93ZWQtb3JpZ2lucyI6WyIqIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJ1bWFfYXV0aG9yaXphdGlvbiIsImFwaXVzZXIiXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50Iiwidmlldy1wcm9maWxlIl19fSwibmFtZSI6IkF3YWRoZXNoIEt1bWFyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiYXdhZGhlc2gua3VtYXIrMUBlMmVuZXR3b3Jrcy5jb20iLCJnaXZlbl9uYW1lIjoiQXdhZGhlc2giLCJmYW1pbHlfbmFtZSI6Ikt1bWFyIiwiZW1haWwiOiJhd2FkaGVzaC5rdW1hcisxQGUyZW5ldHdvcmtzLmNvbSJ9.Hp9VED8hYAbF9XbNQn_WyhCHUim2ui5jNdSRG_lP9B_7gU1YXLsHotupJr3iEJb7FC1XbeoKobwv9PpPJOtyiNUvEPWBza5ir_U737ujdD-NYSzUX-412sTqktjdKqcR78XfpmCIDE-5MeHf5cC3atSvP20XGh4T7d1CeL3oSRE",
"Content-Type": "application/json"
}
};
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({ type: 'power_off' }));
req.end();
2. NodeJs Request Example
var unirest = require("unirest");
var req = unirest("POST", "https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/");
req.query({
"apikey": {{api_key}}
});
req.headers({
"Postman-Token": "eb9afcd9-38ca-4872-9eb4-85c5f3531429",
"cache-control": "no-cache",
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUI.............",
"Content-Type": "application/json"
});
req.type("json");
req.send({
"type": "power_off"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
3. NodeJs Unirest Example
var unirest = require("unirest");
var req = unirest("POST", "https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/");
req.query({
"apikey": "{{api_key}}"
});
req.headers({
"Postman-Token": "eb9afcd9-38ca-4872-9eb4-85c5f3531429",
"cache-control": "no-cache",
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi.......................",
"Content-Type": "application/json"
});
req.type("json");
req.send({
"type": "reboot"
});
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
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"type": "power_off"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/nodes/{{node_id}}/actions/?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/nodes/{{node_id}}/actions/?apikey=API_Key"
payload = json.dumps({
"type": "power_off"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Power-On Node¶
To Power on an existing Node send a POST request to the endpoint https://api.e2enetworks.com/myaccount/api/v1/nodes/<$NODE_ID>/actions/?apikey={{api_key}}
Name | Type | Description | Required |
---|---|---|---|
type | string | Must be power_on | TRUE |
Set the “type” attribute to power_off.
CURL¶
curl -X POST 'https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/?apikey={{api_key}}' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVbWZZQ3FvcXRPUWVN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R78XfpmCIDE-5MeHf5cC3atSvP20XGh4T7d1CeL3oSRE'-H 'Content-Type: application/json' -d '{
"type": "power_on"
}'
PHP¶
1. PHP HttpRequest Example
$request = new HttpRequest();
$request->setUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'apikey' => '10581cd6-3bb6-4b4c-a5fb-79a75b61ecab'
));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkI........................'
));
$request->setBody('{
"type": "power_on"
}');
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('{
"type": "power_on"
}');
$request->setRequestUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setQuery(new http\QueryString(array(
'apikey' => {{api_key}}
)));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia............'
));
$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/169/actions/?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 \"type\": \"power_on\"\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pU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iNUvEPWBza5ir_U737ujdD-NYSzUX-412sTqktjdKqcR78XfpmCIDE-5MeHf5cC3atSvP20XGh4T7d1CeL3oSRE",
"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",
"169",
"actions",
""
],
"headers": {
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVbWZZQ3FvcXRPUWVNZmJoTmxFIn0.eyJqdGkiOiJjYmE3Njc5Zi1mOWFhLTQzZGEtYWNiMi1hNzBlZGEwN2Q3ODkiLCJleHAiOjE1ODc1NDA4MzMsIm5iZiI6MCwiaWF0IjoxNTU2MDA0ODMzLCJpc3MiOiJodHRwOi8vMTcyLjE2LjIxNS45NTo4MDgwL2F1dGgvcmVhbG1zL2FwaW1hbiIsImF1ZCI6ImFwaW1hbiIsInN1YiI6IjMxOWU1ZGExLTZmYzItNDY2ZS1iNDI4LTRmOTViOTRlNDMzMCIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFwaW1hbiIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6ImY2YTUxNTQ5LWRkMjYtNDVkYS04YWI0LTlhNTZjOWY3NTUyYyIsImFjciI6IjEiLCJjbGllbnRfc2Vzc2lvbiI6IjViOWJlMjY4LWE1ZDAtNGMxMC05NWQ0LTdhNzU5NTNkODlhMCIsImFsbG93ZWQtb3JpZ2lucyI6WyIqIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJ1bWFfYXV0aG9yaXphdGlvbiIsImFwaXVzZXIiXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50Iiwidmlldy1wcm9maWxlIl19fSwibmFtZSI6IkF3YWRoZXNoIEt1bWFyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiYXdhZGhlc2gua3VtYXIrMUBlMmVuZXR3b3Jrcy5jb20iLCJnaXZlbl9uYW1lIjoiQXdhZGhlc2giLCJmYW1pbHlfbmFtZSI6Ikt1bWFyIiwiZW1haWwiOiJhd2FkaGVzaC5rdW1hcisxQGUyZW5ldHdvcmtzLmNvbSJ9.Hp9VED8hYAbF9XbNQn_WyhCHUim2ui5jNdSRG_lP9B_7gU1YXLsHotupJr3iEJb7FC1XbeoKobwv9PpPJOtyiNUvEPWBza5ir_U737ujdD-NYSzUX-412sTqktjdKqcR78XfpmCIDE-5MeHf5cC3atSvP20XGh4T7d1CeL3oSRE",
"Content-Type": "application/json"
}
};
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({ type: 'power_on' }));
req.end();
var request = require("request");
var options = { method: 'POST',
url: 'https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/',
qs: { apikey: {{api_key}} },
headers:
{
'Content-Type': 'application/json',
Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiA...............' },
body: { type: 'power_on' },
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/169/actions/");
req.query({
"apikey": "10581cd6-3bb6-4b4c-a5fb-79a75b61ecab"
});
req.headers({
"Postman-Token": "eb9afcd9-38ca-4872-9eb4-85c5f3531429",
"cache-control": "no-cache",
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVbWZZQ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X-412sTqktjdKqcR78XfpmCIDE-5MeHf5cC3atSvP20XGh4T7d1CeL3oSRE",
"Content-Type": "application/json"
});
req.type("json");
req.send({
"type": "power_on",
"name": "nifty-new-name"
});
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
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"type": "power_on"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/nodes/{{node_id}}/actions/?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/nodes/{{node_id}}/actions/?apikey=API_Key"
payload = json.dumps({
"type": "power_on"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Rename Node¶
To Rename on an existing Node send a POST request to the endpoint https://api.e2enetworks.com/myaccount/api/v1/nodes/<$NODE_ID>/actions/?apikey=10581cd6-3bb6-4b4c-a5fb-79a75b61ecab
Name | Type | Description | Required |
---|---|---|---|
type | string | Must be rename | TRUE |
name | string | The new name for the node. | TRUE |
Set the “type” attribute to power_off.
CURL¶
curl -X POST 'https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/?apikey={{api_key}}' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSj....................'-H 'Content-Type: application/json' -d '{
"type": "rename",
"name": "nifty-new-name"
}'
PHP¶
1. PHP HttpRequest Example
$request = new HttpRequest();
$request->setUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node>>/actions/');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'apikey' => '{{api_key}}'
));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldU...........................'
));
$request->setBody('{
"type": "rename",
"name": "nifty-new-name"
}');
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('{
"type": "rename",
"name": "nifty-new-name"
}');
$request->setRequestUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setQuery(new http\QueryString(array(
'apikey' => '{{api_key}}'
)));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIi..............'
));
$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/169/actions/?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 \"type\": \"rename\",\n \"name\": \"nifty-new-name\"\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ..................",
"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",
"169",
"actions",
""
],
"headers": {
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsI....................",
"Content-Type": "application/json"
}
};
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({ type: 'rename', name: 'nifty-new-name' }));
req.end();
2. NodeJs Request Example
var request = require("request");
var options = { method: 'POST',
url: 'https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/',
qs: { apikey: '{{api_key}}' },
headers:
{
'Content-Type': 'application/json',
Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSl..............' },
body: { type: 'rename', name: 'nifty-new-name' },
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/<<node_id>>/actions/");
req.query({
"apikey": "{{api_key}}"
});
req.headers({
"Postman-Token": "eb9afcd9-38ca-4872-9eb4-85c5f3531429",
"cache-control": "no-cache",
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI....................",
"Content-Type": "application/json"
});
req.type("json");
req.send({
"type": "rename",
"name": "nifty-new-name"
});
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
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"name": "C2-12-set1",
"type": "rename"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/nodes/{{Node_id}}/actions/?apikey=API_Key&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/nodes/{{Node_id}}/actions/?apikey=API_Key&location=Delhi"
payload = json.dumps({
"name": "C2-12-set1",
"type": "rename"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Lock VM¶
To lock an existing Node send a POST request to the endpoint https://api.e2enetworks.com/myaccount/api/v1/nodes/<$NODE_ID>/actions/?apikey={{api_key}}
Name | Type | Description | Required |
---|---|---|---|
type | string | Must be lock_vm | TRUE |
name | string | The new name for the node. | TRUE |
Set the “type” attribute to power_off.
CURL¶
curl -X POST 'https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/?apikey={{api_key}}' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5................'-H 'Content-Type: application/json' -d '{
"type": "lock_vm"
}'
PHP¶
1. PHP HttpRequest Example
$request = new HttpRequest();
$request->setUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'apikey' => '{{api_key}}'
));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIg...............'
));
$request->setBody('{
"type": "lock_vm"
}');
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('{
"type": "lock_vm"
}');
$request->setRequestUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setQuery(new http\QueryString(array(
'apikey' => '{{api_key}}'
)));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSj.............'
));
$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>>/actions/?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 \"type\": \"lock_vm\"\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgO...................",
"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",
"169",
"actions",
""
],
"headers": {
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5c.........",
"Content-Type": "application/json"
}
};
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({ type: 'lock_vm' }));
req.end();
2. NodeJs Request Example
var request = require("request");
var options = { method: 'POST',
url: 'https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/',
qs: { apikey: '{{api_key}}' },
headers:
{
'Content-Type': 'application/json',
Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR.........' },
body: { type: 'rename', name: 'nifty-new-name' },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
3. NodeJs Unirest Example
var request = require("request");
var options = { method: 'POST',
url: 'https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/',
qs: { apikey: '{{api_key}}' },
headers:
{
'Content-Type': 'application/json',
Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIg.........' },
body: { type: 'lock_vm' },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"type": "lock_vm"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/nodes/<<node_id>>/actions/?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/nodes/{{node_id}}/actions/?apikey=API_key"
payload = json.dumps({
"type": "lock_vm"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Unlock VM¶
To unlock an existing Node send a POST request to the endpoint https://api.e2enetworks.com/myaccount/api/v1/nodes/<$NODE_ID>/actions/?apikey={{api_key}}
Name | Type | Description | Required |
---|---|---|---|
type | string | Must be lock_vm | TRUE |
name | string | The new name for the node. | TRUE |
Set the “type” attribute to power_off.
CURL¶
curl -X POST 'https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/?apikey={{api_key}}' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsIn.........'-H 'Content-Type: application/json' -d '{
"type": "unlock_vm"
}'
PHP¶
1. PHP HttpRequest Example
$request = new HttpRequest();
$request->setUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'apikey' => '{{api_key}}'
));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiS.........'
));
$request->setBody('{
"type": "unlock_vm"
}');
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('{
"type": "unlock_vm"
}');
$request->setRequestUrl('https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setQuery(new http\QueryString(array(
'apikey' => '{{api_key}}'
)));
$request->setHeaders(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI......'
));
$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/169/actions/?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 \"type\": \"unlock_vm\"\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSl........",
"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",
"169",
"actions",
""
],
"headers": {
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwi......",
"Content-Type": "application/json"
}
};
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({ type: 'unlock_vm' }));
req.end();
2. NodeJs Request Example
var request = require("request");
var options = { method: 'POST',
url: 'https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/',
qs: { apikey: {{api_key}} },
headers:
{
'Content-Type': 'application/json',
Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIg......' },
body: { type: 'unlock_vm'},
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
3. NodeJs Unirest Example
var request = require("request");
var options = { method: 'POST',
url: 'https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/actions/',
qs: { apikey: '{{api_key}}' },
headers:
{
'Content-Type': 'application/json',
Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiS...' },
body: { type: 'unlock_vm' },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"type": "unlock_vm"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/nodes/{{node_id}}/actions/?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/nodes/{{node_id}}/actions/?apikey=API_Key"
payload = json.dumps({
"type": "unlock_vm"
})
headers = {
'Authorization': 'API_Token',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)