Firewall

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 Firewall

To find the list of firewall, send a HTTP GET request :-

https://api.e2enetworks.com/myaccount/api/v1/fortigate/list/?
apikey={{apikey}}&location={{location}}&project_id={{project-id}}
import http.client

conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
        'Authorization': 'api_token',
        }
conn.request("GET", "/myaccount/api/v1/fortigate/list?apikey={{api_key}}&location=Delhi&project_id={{project-id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "code": 200,
    "data": [
        {
            "id": 97077,
            "name": "Fortinet-7-01-Fortinet-408",
            "created_at": "2022-06-20T06:28:53.620681Z",
            "public_ip_address": "164.52.192.194",
            "private_ip_address": "10.4.222.11",
            "backup": false,
            "disk": "20 GB",
            "status": "Creating",
            "vcpus": "1",
            "memory": "9 GB",
            "plan": "FTN.100V",
            "region": null,
            "is_locked": false,
            "zabbix_host_id": null,
            "gpu": "",
            "price": "Rs 13/Hour or Rs 9490 Monthly",
            "additional_ip": [],
            "label": "Default",
            "ssh_keys": [],
            "is_active": true,
            "scaler_id": null,
            "os_info": {
                "name": "Fortinet",
                "version": "7.01",
                "category": ""
            },
            "is_monitored": false,
            "backup_status": {
                "status": "backup_unsupported",
                "detail": "Backup Unsupported"
            },
            "location": "Delhi",
            "monitor_status": {
                "status": "not_activated",
                "reason": ""
            },
            "enable_bitninja_details": {
                "show_bitninja": false,
                "bitninja_cost": 0
            },
            "is_bitninja_license_active": false,
            "any_license_attached": {
                "is_license_attached": false,
                "license_deletion_message": "",
                "mssql_license_attached": false
            },
            "is_committed": true,
            "audit_log_message": null,
            "monitoring_tabs_enabled": true,
            "cdp_tabs_enabled": true,
            "alert_tabs_enabled": true,
            "bitninja_discount_percentage": 0.0,
            "is_image_deleted": false,
            "vpc_enabled": true,
            "is_snapshot_allowed": false,
            "is_fortigate_vm": true,
            "rescue_mode_status": "Disabled",
            "is_upgradable": false,
            "abuse_flag": false
        },

    ],
    "errors": {},
    "message": "Success"
}

Create a new Firewall

To create a firewall , send a Post request :-

https://api.e2enetworks.com/myaccount/api/v1/fortigate/create/
?apikey={{apikey}}&location={{location}}&project_id={{project-id}}
import http.client
import json

conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
        "backups": False,
        "cn_id": 1036,
        "default_public_ip": False,
        "disable_password": False,
        "enable_bitninja": False,
        "image": "Fortinet-7.01-Fortinet",
        "is_ipv6_availed": False,
        "is_saved_image": False,
    "label": "Default",
    "name": "Fortinet-7-01-Fortinet-408",
        "ngc_container_id": None,
    "plan": "FTN-1vCPU-9RAM-20DISK-FTN.100V",
    "region": "ncr",
    "reserve_ip": "164.52.192.194",
    "saved_image_template_id": None,
    "ssh_keys": [],
    "vpc_id": "8299"
    })
headers = {
    'Authorization': 'api_token',
    'Content-Type': 'application/json',
    }
conn.request("POST", "/myaccount/api/v1/fortigate/create?apikey=7{{api_key}}&location=Delhi&project_id={{project-id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "backups": false,
    "cn_id": 1036,
    "default_public_ip": false,
    "disable_password": false,
    "enable_bitninja": false,
    "image": "Fortinet-7.01-Fortinet",
    "is_ipv6_availed": false,
    "is_saved_image": false,
    "label": "Default",
    "name": "Fortinet-7-01-Fortinet-408",
    "ngc_container_id": null,
    "plan": "FTN-1vCPU-9RAM-20DISK-FTN.100V",
    "region": "ncr",
    "reserve_ip": "164.52.192.194",
    "saved_image_template_id": null,
    "ssh_keys": [],
    "vpc_id": "8299"
}

Delete a Firewall -

To delete a Firewall , send a DELETE request to firewall endpoint :-

https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/
?apikey={{apikey}}&project_id={{project-id}}&reserve_ip_required=
import http.client

conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
            'Authorization': 'api_token'
        }
conn.request("DELETE", "/myaccount/api/v1/nodes/<<node_id>>/?apikey={{api_key}}&project_id={{project-id}}&reserve_ip_required=", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "code": 200,
    "data": {},
    "errors": {},
    "message": "Success"
}

Lock Firewall

To lock firewall , send a PUT request to firewall end point :-

https://api.e2enetworks.com/myaccount/api/v1/nodes/{{node_id}}/
actions/?apikey={{apikey}}&project_id={{project-id}}
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("PUT", "/myaccount/api/v1/nodes/97072/actions/?apikey={{api_key}}&project_id={{project-id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "type": "lock_vm"
}

Unlock Firewall

To unlock firewall , send a PUT request -

https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/
actions/?apikey={{apikey}}&project_id={{project-id}}
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("PUT", "/myaccount/api/v1/nodes/<<node_id>>/actions/?apikey={{api_key}}&project_id={{project-id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "type": "unlock_vm"
}

Power-On Firewall

To power-on firewall , send a PUT request-

https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/
actions/?apikey={{apikey}}&project_id={{project-id}}
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("PUT", "/myaccount/api/v1/nodes/<<node_id>>/actions/?apikey={{api_key}}&project_id={{project-id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "type": "power_on"
}

Power -off Firewall

To power-off firewall , send a PUT request-

https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/
actions/?apikey={{apikey}}&project_id={{project-id}}
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("PUT", "/myaccount/api/v1/nodes/<<node_id>>/actions/?apikey={{api_key}}&project_id={{project-id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "type": "power_off"
}

Reboot Firewall

To reboot firewall, send a PUT request :-

https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/
actions/?apikey={{apikey}}&project_id={{project-id}}
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}}&project_id={{project-id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "type": "reboot"
}

Reinstall Firewall

To reinstall firewall, send a PUT request-

https://api.e2enetworks.com/myaccount/api/v1/nodes/<<node_id>>/
actions/?apikey={{apikey}}&project_id={{project-id}}
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}}&project_id={{project-id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "type": "reinstall"
}

Response Body

{

“code”: 200, “data”: {

“id”: 122635, “created_at”: “2022-06-20T07:52:19.761953Z”, “status”: “done”, “action_type”: “reinstall”, “resource_id”: “97072”

}, “errors”: {}, “message”: “Success”

}

Commited node setting

To update node to commited node, send a Post request:-

https://api.e2enetworks.com/myaccount/api/v1/update_committed_node_status/
?apikey={{apikey}}&location={{location}}&project_id={{project-id}}
import http.client
import json

conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
                "committed_plan": 1036,
                "node_status": "auto_renew",
                "vcn_id": 97072
                })
headers = {
            'Authorization': 'api_token',
            'Content-Type': 'application/json',
        }
conn.request("POST", "/myaccount/api/v1/update_committed_node_status/?apikey={{api_key}}&location=Delhi&project_id={{project-id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
    "committed_plan": 1036,
    "node_status": "auto_renew",
    "vcn_id": 97072
}