==== 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 .. code-block:: bash 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: .. csv-table:: :file: node.csv :widths: 10, 20, 60, 10 :header-rows: 1 .. tabs:: .. code-tab:: python Python 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":"{{Plan_name}}", "image": "{{image_name}}", "ssh_keys": [], "backups": False, "enable_bitninja": False, "disable_password": False, "is_saved_image": False, "saved_image_template_id": None, "reserve_ip": "", "is_ipv6_availed": False, "vpc_id": "", "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() .. code-tab:: Python Curl curl 'https://api.e2enetworks.com/myaccount/api/v1/nodes/?apikey={{api_key}}&project_id=17925&location=Delhi-NCR-2' \ -H 'Accept: application/json, text/plain, */*' \ -H 'Accept-Language: en-gb' \ -H 'Authorization: Bearer {{token}}' \ -H 'Content-Type: application/json' \ -H 'Origin: https://myaccount.e2enetworks.com' \ -H 'Pragma: no-cache' \ -H 'Referer: https://myaccount.e2enetworks.com/' \ -H 'x-api-key: 477794a4-3c10-495d-a51b-c63a26dc6aa3' \ --data-raw '{"label":"Default","name":"C3-8GB-102","region":"ncr","plan":"C3-4vCPU-8RAM-100DISK-C3.250GB-CentOS-Stream8-Delhi-NCR-2","image":"CentOS-Stream-Distro","ssh_keys":["ssh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J4fBkby5qmfVRFgvipwiqHgLcy+PJkK0kXrWZKH9/bcYmQqDbnqHBw9z3s3x13GiWSgl5eyr8ihR0ASi2SHZjP25ffskkDVsKD/yEWxH3lHnPlGai9tpPQzigJZXoMKs7knRhZG8IhdbYNTBMe+bNf3FTyEXrR57f6pN+IuCHMLO1PqQqxXF4UsJq+Tnr0= shubh@HPLaptop14sdq2xxx3f8616bf"],"start_scripts":[],"backups":false,"enable_bitninja":false,"disable_password":true,"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":50830,"is_encryption_required":false}' \ --compressed .. tabs:: .. code-tab:: python Request Headers Content-Type: application/json Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi... .. code-tab:: python Response Headers content-type: application/json; charset=utf-8 status: 202 Accepted ratelimit-limit: 1200 ratelimit-remaining: 965 ratelimit-reset: 1415984218 .. tabs:: .. code-tab:: python Request Body { "label": "Default", "name": "C2-12GB", "region": "ncr", "plan":"{{Plan_name}}", "image": "{{image_name}}", "ssh_keys": [], "backups": False, "enable_bitninja": False, "disable_password": False, "is_saved_image": False, "saved_image_template_id": None, "reserve_ip": "", "is_ipv6_availed": False, "vpc_id": "", "default_public_ip": False, "ngc_container_id": None, "security_group_id": 3482, "start_scripts": [] } .. code-tab:: python 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 .. code-block:: bash 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: .. csv-table:: :file: getnodeid.csv :widths: 20, 20, 60 :header-rows: 1 Get Node List ------------- To get the list of nodes in your MyAccount, send a GET request to the endpoint .. code-block:: bash 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: .. csv-table:: :file: tables/getnodelist.csv :widths: 30, 60, 10 :header-rows: 1 .. tabs:: .. code-tab:: python Python 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")) .. code-tab:: python Request 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() .. code-tab:: Python Curl curl 'https://api.e2enetworks.net/myaccount/api/v1/nodes/{{node_id}}/?apikey={{api_key}}&project_id=2157&location=Delhi' \ -H 'Accept: application/json, text/plain, */*' \ -H 'Accept-Language: en-gb' \ -H 'Authorization: Bearer {{Token}}' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/json' \ -H 'Origin: https://myaccount.e2enetworks.com' \ -H 'Pragma: no-cache' \ -H 'Referer: https://myaccount.e2enetworks.com/' \ -H 'x-api-key: 9d5383a1-69e3-4871-b32c-6bb8ad882000' \ --compressed .. tabs:: .. code-tab:: python Request Headers Content-Type: application/json Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi... .. code-tab:: python Response Headers content-type: application/json; charset=utf-8 status: 202 Accepted ratelimit-limit: 1200 ratelimit-remaining: 965 ratelimit-reset: 1415984218 .. tabs:: .. code-tab:: python Response Body { "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}} .. tabs:: .. code-tab:: python Python 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() .. code-tab:: Python Curl curl 'https://api.e2enetworks.com/myaccount/api/v1/nodes/{{node_id}}/?reserve_ip_required=&reserve_ip_pool_required=&apikey={{api_key&project_id=2157&location=Delhi' \ -X 'DELETE' \ -H 'Accept: application/json, text/plain, */*' \ -H 'Accept-Language: en-gb' \ -H 'Authorization: Bearer {{token}}' -H 'Content-Type: application/json' \ -H 'Origin: https://myaccount.e2enetworks.com' \ -H 'Pragma: no-cache' \ -H 'Referer: https://myaccount.e2enetworks.com/' \ -H 'x-api-key: 9d5383a1-69e3-4871-b32c-6bb8ad882000' \ --compressed .. tabs:: .. code-tab:: python Request Headers Content-Type: application/json Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi... .. code-tab:: python Response Headers content-type: application/json; charset=utf-8 status: 202 Accepted ratelimit-limit: 1200 ratelimit-remaining: 965 ratelimit-reset: 1415984218 .. tabs:: .. code-tab:: python Response Body { "message": "Success", "code": 200, "data": {}, "errors": {} } Update Committed Node Plan -------------------------- **Endpoint:** .. code-block:: bash https://api.e2enetworks.com/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}&project_id={{project_id}} **Request Parameter:** ^^^^^^^^^^^^^^^^^^^^^^ .. csv-table:: :file: tables/commited.csv :widths: 10, 20, 60, 10 :header-rows: 1 .. tabs:: .. code-tab:: Python NodeJs 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); }); .. code-tab:: Python Curl 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 }'