========== Reserve IP ========== Create an API Key and access token:- ==================================== For create a **API Key** and **Access Token** to refer this link :- `https://www.e2enetworks.com/help/knowledge-base/how-to-create-an-api-access-token/ `_ List of Reserve IP- =================== To find a list of **Reserve IP** to send a **GET** request .. code-block:: bash https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}} The request returns a JSON object that contains the following attributes: .. csv-table:: :file: list_reserveip..csv :widths: 25, 25, 50 :header-rows: 1 .. tabs:: .. code-tab:: python http client import http.client conn = http.client.HTTPSConnection("api.e2enetworks.com") payload = '' headers = { 'Authorization': 'API_Token ', } conn.request("GET", "/myaccount/api/v1/reserve_ips/?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 http client import requests url = "https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}}" payload={} headers = { 'Authorization': 'API_Token', } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) .. 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 .. tabs:: .. code-tab:: python Response Body { "code": 200, "data": [ { "ip_address": "216.48.189.38", "status": "Available", "bought_at": "24-02-2022 08:31", "vm_id": null, "vm_name": "--", "reserve_id": 4558, "appliance_type": "--" }, ], "errors": {}, "message": "Success", "is_limit_available": true, "reserved_ip_details": { "customer_max_limit": 3, "reserved_ips_count": 2 }, "reserve_ip_price": "199 infra credits" } Create a new Reserve IP ----------------------- To create a **Reserve IP** to send a **Post** request .. code-block:: bash https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}} The request returns a JSON object that contains the following attributes: .. csv-table:: :file: table/create_reserveip.csv :widths: 20, 20, 60 :header-rows: 1 .. tabs:: .. code-tab:: python http client import http.client conn = http.client.HTTPSConnection("api.e2enetworks.com") payload = '' headers = { 'Authorization': 'API_Token ', 'Content-Type': 'application/json', } conn.request("POST", "/myaccount/api/v1/reserve_ips/?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 http client import requests url = "https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}}" payload={} headers = { 'Authorization': 'API_Token ', 'Content-Type': 'application/json', } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) .. 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 .. tabs:: .. code-tab:: python Response Body { "code": 200, "data": { "ip_address": "216.48.189.51", "status": "Available", "bought_at": "25-02-2022 03:07", "vm_id": null, "vm_name": "--", "reserve_id": 4575, "appliance_type": "--" }, "errors": {}, "message": "Success", "is_limit_available": false, "reserved_ip_details": { "customer_max_limit": 3, "reserved_ips_count": 3 }, "reserve_ip_price": "199 infra credits" } Delete Reserve IP ----------------- To delete a **Reserve IP** to send a **DELETE** request .. code-block:: bash https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}} .. tabs:: .. code-tab:: python http client import http.client conn = http.client.HTTPSConnection("api.e2enetworks.com") payload = '' headers = { 'Authorization': 'API_Token ', 'Content-Type': 'application/json', } conn.request("DELETE", "/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?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 http client import requests url = "https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?apikey={{Api_key}}&location=Delhi&project_id={{project-id}}" payload={} headers = { 'Authorization': 'API_Token ', 'Content-Type': 'application/json', } response = requests.request("DELETE", url, headers=headers, data=payload) print(response.text) .. 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 .. tabs:: .. code-tab:: python Response Body { "code": 200, "data": { "message": "IP Released 216.48.189.38" }, "errors": {}, "message": "Success", "is_limit_available": true, "reserved_ip_details": { "customer_max_limit": 3, "reserved_ips_count": 2 }, "reserve_ip_price": "199 infra credits" } Attached to Node ---------------- Attach **Reserve IP** through node to send a **POST** request .. code-block:: bash https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}} Attributes and respective values required to send this POST request are: .. csv-table:: :file: table/attach_node.csv :widths: 25, 25, 25, 25 :header-rows: 1 The request returns a JSON object that contains the following attributes: .. csv-table:: :file: table/attach_node1.csv :widths: 20, 20, 60 :header-rows: 1 .. tabs:: .. code-tab:: python http client import http.client import json conn = http.client.HTTPSConnection("api.e2enetworks.com") payload = json.dumps({ "type": "attach", "vm_id": 99321 }) headers = { 'Authorization': 'api_token ', 'Content-Type': 'application/json', conn.request("POST", "/myaccount/api/v1/reserve_ips/{{ip_adress}}/actions/?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 http client import requests import json url = "https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/{{ip_adderess}}/actions/?apikey={{api_key}}&location=Delhi&project_id={{project-id}}" payload = json.dumps({ "type": "attach", "vm_id": 99321 }) headers = { 'Authorization': 'API_Token ', 'Content-Type': 'application/json', } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) .. 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 .. tabs:: .. code-tab:: python Request Body { "type":"attach", "vm_id":99769 } .. code-tab:: python Response Body { "code": 200, "data": { "IP": "101.53.135.29", "status": "Attached", "vm_name": "C2-12GB-CentOS-8-0-601", "vm_id": 99321 }, "errors": {}, "message": "IP assign successfully " } Detach Reserve IP from Node --------------------------- Detach **Reserve IP** through node to send a **Post** request .. code-block:: bash https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}} Attributes and respective values required to send this POST request are: .. csv-table:: :file: table/attach_node.csv :widths: 25,25,25,25 :header-rows: 1 The request returns a JSON object that contains the following attributes: .. csv-table:: :file: table/attach_node1.csv :widths: 20, 20, 60 :header-rows: 1 .. tabs:: .. code-tab:: python http client import http.client import json conn = http.client.HTTPSConnection("api.e2enetworks.com") payload = json.dumps({ "type": "detach", "vm_id": 99321 }) headers = { 'Authorization': 'API_Token ', 'Content-Type': 'application/json', } conn.request("POST", "/myaccount/api/v1/reserve_ips/{{ip_adress}}/actions/?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 http client import requests import json url = "https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/{{ip_adress}}/actions/?apikey={{api_key}}&location=Delhi&project_id={{project-id}}" payload = json.dumps({ "type": "detach", "vm_id": 99321 }) headers = { 'Authorization': 'api_token', 'Content-Type': 'application/json', } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) .. 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 .. tabs:: .. code-tab:: Python Request Body { "type":"detach", "vm_id":99321 } .. code-tab:: Python Response Body { "code": 200, "data": { "IP": "101.53.135.29", "status": "Available", "vm_name": "--" }, "errors": {}, "message": "IP Detach Successfully." } Attached Reserve IP to Load Balancer ------------------------------------ Attach **Reserve IP** through **Load Balancer** to send a **Post** request .. code-block:: bash https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}} Attributes and respective values required to send this POST request are: .. csv-table:: :file: table/attach_node.csv :widths: 25,25,25,25 :header-rows: 1 The request returns a JSON object that contains the following attributes: .. csv-table:: :file: table/attach_node1.csv :widths: 20, 20, 60 :header-rows: 1 .. tabs:: .. code-tab:: Python http client import http.client import json conn = http.client.HTTPSConnection("api.e2enetworks.com") payload = json.dumps({ "type": "attach", "vm_id": 99769 }) headers = { 'Authorization': 'API_Token ', 'Content-Type': 'application/json', } conn.request("POST", "/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?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 http client import requests import json url = "https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?apikey={{api_key}}&location=Delhi&project_id={{project-id}}" payload = json.dumps({ "type": "attach", "vm_id": 99769 }) headers = { 'Authorization': 'api_token ', 'Content-Type': 'application/json', } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) .. 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 .. tabs:: .. code-tab:: Python Request Body { "type":"attach", "vm_id":99769 } .. code-tab:: Python Response Body { "code": 200, "data": { "IP": "216.48.189.41", "status": "Attached", "vm_name": "E2E-LB-1-446", "vm_id": 99769 }, "errors": {}, "message": "IP assign successfully " } Detach Reserve IP to Load Balancer ---------------------------------- Detach **Reserve IP** through Load Balancer to send a **Post** request .. code-block:: bash https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}} Attributes and respective values required to send this POST request are: .. csv-table:: :file: table/attach_node.csv :widths: 25,25,25,25 :header-rows: 1 The request returns a JSON object that contains the following attributes: .. csv-table:: :file: table/attach_node1.csv :widths: 20, 20, 60 :header-rows: 1 .. tabs:: .. code-tab:: Python http client import http.client import json conn = http.client.HTTPSConnection("api.e2enetworks.com") payload = json.dumps({ "type": "detach", "vm_id": 99006 }) headers = { 'Authorization': 'api_token ', 'Content-Type': 'application/json', } conn.request("POST", "/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?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 http client import requests import json url = "https://api.e2enetworks.com/myaccount/api/v1/reserve_ips/{{ip_address}}/actions/?apikey={{api_key}}&location=Delhi&project_id={{project-id}}" headers = { 'Authorization': 'api_token ', 'Content-Type': 'application/json', } payload = json.dumps({ "type": "detach", "vm_id": 99006 }) response = requests.request("POST", url, headers=headers, data=payload) print(response.text) .. tabs:: .. code-tab:: Python Request Headers Content-Type: application/json Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi... .. code-tab:: Response Headers content-type: application/json; charset=utf-8 status: 202 Accepted .. tabs:: .. code-tab:: Request Body { "type":"attach", "vm_id":99769 } .. code-tab:: Response Body { "code": 200, "data": { "IP": "216.48.189.41", "status": "Available", "vm_name": "--" }, "errors": {}, "message": "IP Detach Successfully." }