Save Image¶
To Save Image of 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 save_images .
List all Images¶
# | Name | Type | Description | Required |
---|---|---|---|---|
1 | type | String | Name of node images | TRUE |
2 | name | string | The name of the save image. | TRUE |
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"name": "C2-12GB-CentOS-Stream-412-11",
"type": "save_images"
})
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({
"name": "C2-12GB-CentOS-Stream-412-11",
"type": "save_images"
})
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
CURL¶
curl -X POST 'https://api.e2enetworks.com/myaccount/api/v1/nodes/169/actions/?apikey={{api_key}}' -H 'Authorization: Bearer eyJhbGciOiJSUz.....'-H 'Content-Type: application/json' -d '{
"type": "save_images",
"name": "nifty-save-image-name"
}'
PHP¶
1. PHP HttpRequest Example
$request = new HttpRequest();
$request->setUrl('http://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 eyJhbGciOiJSUzI1NiIsInR5cC.....'
));
$request->setBody('{
"type" : "save_images",
"name" : "testsaveimage"
}');
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" : "save_images",
"name" : "testsaveimage"
}');
$request->setRequestUrl('http://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 eyJhbGciOiJSUzI1NiIsInR5c.....'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
3. PHP CURL Example
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://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\t\"type\" : \"save_images\",\n\t\"name\" : \"testsaveimage\"\n}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiA.....",
"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",
"port": null,
"path": "//myaccount/api/v1/nodes/34339/actions/?apikey={{api_key}}",
"headers": {
"authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUI......",
"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: 'save_images', name: 'testsaveimage' }));
req.end();
2. NodeJs Request Example
var request = require("request");
var options = { method: 'POST',
url: 'http://api.e2enetworks.com//myaccount/api/v1/nodes/<<node_id>>/actions/',
qs: { apikey: '{{api_key}}' },
headers:
{ 'content-type': 'application/json',
authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOi......' },
body: { type: 'save_images', name: 'testsaveimage' },
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", "http://api.e2enetworks.com//myaccount/api/v1/nodes/<<id>>/actions/");
req.query({
"apikey": "{{api_key}}"
});
req.headers({
"postman-token": "931d7e7d-ebec-e652-b201-b0ef36bbad6d",
"cache-control": "no-cache",
"content-type": "application/json",
"authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgO....."
});
req.type("json");
req.send({
"type": "save_images",
"name": "testsaveimage"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Saved Image Listing¶
To get the list of Saved Image in your MyAccount, send a GET request to the endpoint https://api.e2enetworks.com/myaccount/api/v1/images/?apikey={{api_key}}.
The response returns an array of JSON objects; each JSON object represents the information of each saved image.
The JSON objects contain the following attributes:
# | Name | Type | Description |
---|---|---|---|
1 | image_state | String | State of the image |
2 | name | String | The name of the saved image. |
3 | running_vms | integer | Running VM count with this image |
4 | creation_time | String | The time when node created represented in ISO8601 which includes both the date and time. |
5 | image_id | integer | The ID of the saved image. |
6 | vm_info | String | Running VM’s Information |
7 | image_size | String | Size of the image in GB |
8 | os_distribution | String | The name of the saved image. |
9 | template_id | integer | The template id of the image |
10 | distro | String | The Distro details of the image |
PYTHON¶
1. Python - http.client Example
import http.client
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
'Authorization': 'api_token'
}
conn.request("GET", "/myaccount/api/v1/images/saved-images/?apikey={{api_key}}&location=Delhi", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
url = "https://api.e2enetworks.com/myaccount/api/v1/images/saved-images/?apikey={{api_key}}&location=Delhi"
payload={}
headers = {
'Authorization': 'api_token'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
CURL¶
curl -X GET 'https://api.e2enetworks.com/myaccount/api/v1/images/saved-images/?apikey={{api_key}}’ -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIg.....'
PHP¶
1. PHP HttpRequest Example
$request = new HttpRequest();
$request->setUrl('http://api.e2enetworks.com//myaccount/api/v1/images/saved-images/');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'apikey' => '{{api_key}}'
));
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgO....'
));
$request->setBody('{
"type": "rename",
"name": "testing4test"
}
');
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": "testing4test"
}
');
$request->setRequestUrl('http://api.e2enetworks.com//myaccount/api/v1/images/saved-images/');
$request->setRequestMethod('GET');
$request->setBody($body);
$request->setQuery(new http\QueryString(array(
'apikey' => '{{api_key}}'
)));
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5....'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
3. PHP CURL Example
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://api.e2enetworks.com//myaccount/api/v1/images/saved-images/?apikey={{api_key}}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "{\r\n \"type\": \"rename\",\r\n \"name\": \"testing4test\"\r\n}\r\n",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia.......",
"cache-control: no-cache",
"content-type: application/json",
"postman-token: c4b090aa-1ec8-9696-9c6c-db146ab04bba"
),
));
$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",
"port": null,
"path": "//myaccount/api/v1/images/saved-images/?apikey={{api_key}}",
"headers": {
"authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJjej.....",
"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: 'testing4test' }));
req.end();
2. NodeJs Request Example
var request = require("request");
var options = { method: 'GET',
url: 'http://api.e2enetworks.com//myaccount/api/v1/images/saved-images/',
qs: { apikey: '{{api_key}}' },
headers:
{ 'content-type': 'application/json',
authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5.......' },
body: { type: 'rename', name: 'testing4test' },
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("GET", "http://api.e2enetworks.com//myaccount/api/v1/images/saved-images/");
req.query({
"apikey": "{{api_key}}"
});
req.headers({
"content-type": "application/json",
"authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR......"
});
req.type("json");
req.send({
"type": "rename",
"name": "testing4test"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Headers¶
Request Headers¶
Content-Type: application/json
Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582
Response Headers¶
content-type: application/json; charset=utf-8
status: 200 OK
Body¶
Response Body¶
{
"message": "Success",
"code": 200,
"data": [
{
"image_state": "Ready",
"name": "test-disk-0",
"running_vms": "0",
"creation_time": "31-10-2019 11:59:58",
"image_id": "2292",
"vm_info": null,
"image_size": "57 GB",
"os_distribution": "test",
"template_id": "3638",
"distro": "CentOS-7.5"
}
],
"errors": {}
}
Rename Saved Image¶
Send a POST request to the endpoint to rename a saved image from your MyAccount. https://api.e2enetworks.com/myaccount/api/v1/images/<$IMAGE_ID>/?apikey={{api_key}}.
# | Name | Type | Description | Required |
---|---|---|---|---|
1 | action_type | String | Must be rename | TRUE |
2 | name | String | The new name of the saved image. | TRUE |
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"action_type": "rename",
"name": "c2-12gb-centos-image-set1"
})
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/images/{{image_id}}/?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/images/{{image_id}}/?apikey={{api_key}}&location=Delhi"
payload = json.dumps({
"action_type": "rename",
"name": "c2-12gb-centos-image-set1"
})
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
CURL¶
curl -X POST 'https://api.e2enetworks.com/myaccount/api/v1/images/519/?apikey={{api_key}}' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsI......'-H 'Content-Type: application/json' -d '{
"action_type": "rename",
“Name”: “new-name”
}'
PHP¶
1. PHP HttpRequest Example
$request = new HttpRequest();
$request->setUrl('http://api.e2enetworks.com//myaccount/api/v1/images/2294/');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'apikey' => '{{api_key}}'
));
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5c....'
));
$request->setBody('{
"action_type":"rename",
"name":"my-zabbix-image"
}');
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('{
"action_type":"rename",
"name":"my-zabbix-image"
}');
$request->setRequestUrl('http://api.e2enetworks.com//myaccount/api/v1/images/2294/');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setQuery(new http\QueryString(array(
'apikey' => '{{api_key}}'
)));
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5c.........'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
3. PHP CURL Example
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://api.e2enetworks.com//myaccount/api/v1/images/2294/?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\t\"action_type\":\"rename\",\n\t\"name\":\"my-zabbix-image\"\n}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJj......",
"cache-control: no-cache",
"content-type: application/json",
"postman-token: e7f14c48-efc8-ad23-6fd5-c0fbe096d39e"
),
));
$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",
"port": null,
"path": "//myaccount/api/v1/images/2294/?apikey={{api_key}}",
"headers": {
"authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldU......",
"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({ action_type: 'rename', name: 'my-zabbix-image' }));
req.end();
2. NodeJs Request Example
var request = require("request");
var options = { method: 'POST',
url: 'http://api.e2enetworks.com//myaccount/api/v1/images/2294/',
qs: { apikey: '{{api_key}}' },
headers:
{ 'content-type': 'application/json',
authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgO.....' },
body: { action_type: 'rename', name: 'my-zabbix-image' },
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", "http://api.e2enetworks.com//myaccount/api/v1/images/2294/");
req.query({
"apikey": "{{api_key}}"
});
req.headers({
"content-type": "application/json",
"authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiA......"
});
req.type("json");
req.send({
"action_type": "rename",
"name": "my-zabbix-image"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Delete Saved Image¶
Send a POST request to the endpoint to delete a saved image from your MyAccount. https://api.e2enetworks.com/myaccount/api/v1/images/<$IMAGE_ID>/?apikey={{api_key}}.
# | Name | Type | Description | Required |
---|---|---|---|---|
1 | action_type | String | Must be delete_image | TRUE |
PYTHON¶
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"action_type": "delete_image"
})
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
conn.request("POST", "/myaccount/api/v1/images/{{image_id}}/?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/images/{{image_id}}/?apikey={{api-key}}&location=Delhi"
payload = json.dumps({
"action_type": "delete_image"
})
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
CURL¶
curl -X POST 'https://api.e2enetworks.com/myaccount/api/v1/images/519/?apikey={{api_key}}' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiS.....'-H 'Content-Type: application/json' -d '{
"action_type": "delete_image",
}'
PHP¶
1. PHP HttpRequest Example
$request = new HttpRequest();
$request->setUrl('http://api.e2enetworks.com//myaccount/api/v1/images/2294/');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'apikey' => '{{api_key}}'
));
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIg.....'
));
$request->setBody('{
"action_type": "delete_image"
}');
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('{
"action_type": "delete_image"
}');
$request->setRequestUrl('http://api.e2enetworks.com//myaccount/api/v1/images/2294/');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setQuery(new http\QueryString(array(
'apikey' => '{{api_key}}'
)));
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cC.......'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
3. PHP CURL Example
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://api.e2enetworks.com//myaccount/api/v1/images/2294/?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 => "{\r\n \"action_type\": \"delete_image\"\r\n}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6IC......",
"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",
"port": null,
"path": "//myaccount/api/v1/images/2294/?apikey={{api_key}}",
"headers": {
"authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUI.......",
"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({ action_type: 'delete_image' }));
req.end();
2. NodeJs Request Example
var request = require("request");
var options = { method: 'POST',
url: 'http://api.e2enetworks.com//myaccount/api/v1/images/2294/',
qs: { apikey: '{{api_key}}' },
headers:
{ 'content-type': 'application/json',
authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiA..........' },
body: { action_type: 'delete_image' },
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", "http://api.e2enetworks.com//myaccount/api/v1/images/2294/");
req.query({
"apikey": "{{api_key}}"
});
req.headers({
"content-type": "application/json",
"authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUI......"
});
req.type("json");
req.send({
"action_type": "delete_image"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});