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}}

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/fortigate/list?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/fortigate/list?apikey={{api_key}}&location=Delhi"

    payload={}
    headers = {
                 'Authorization': 'api_token'
             }

   response = requests.request("GET", url, headers=headers, data=payload)

   print(response.text)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Response Body

{
   "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_tab_enabled": true,
           "cdp_tab_enabled": true,
           "alert_tab_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}}

PYTHON

1. Python - http.client Example

   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", 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/fortigate/create?apikey={{api_key}}&location=Delhi"

   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',
          }

    response = requests.request("POST", url, headers=headers, data=payload)

   print(response.text)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Request Body-

{
   "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"
}

Response Body

{
   "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_tab_enabled": true,
       "cdp_tab_enabled": true,
       "alert_tab_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"
}

Delete a Firewall -

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

https://api.e2enetworks.com/myaccount/api/v1/nodes/97077/?apikey={{apikey}}&reserve_ip_required=

PYTHON

1. Python - http.client Example

  import http.client

  conn = http.client.HTTPSConnection("api.e2enetworks.com")
  payload = ''
  headers = {
             'Authorization': 'api_token'
          }
  conn.request("DELETE", "/myaccount/api/v1/nodes/97077/?apikey={{api_key}}&reserve_ip_required=", 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/nodes/97077/?apikey={{api_key}}&reserve_ip_required="

   payload={}
   headers = {
             'Authorization': 'api_token'
          }

   response = requests.request("DELETE", url, headers=headers, data=payload)

  print(response.text)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Response Body

{
   "code": 200,
   "data": {},
   "errors": {},
   "message": "Success"
}

Lock Firewall

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

https://api.e2enetworks.com/myaccount/api/v1/nodes/97072/actions/?apikey={{apikey}}

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/97072/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/97072/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)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Request Body-

{
       "type": "lock_vm"
}

Response Body

{
   "code": 200,
   "data": {
       "id": 122605,
       "created_at": "2022-06-20T06:47:47.579245Z",
       "status": "done",
       "action_type": "lock_vm",
       "resource_id": "97072"
   },
   "errors": {},
   "message": "Success"
}

Unlock Firewall

To unlock firewall , send a Post request -

https://api.e2enetworks.com/myaccount/api/v1/nodes/97072/actions/?apikey={{apikey}}

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/97072/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/97072/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)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Request Body-

{
       "type": "unlock_vm"
}

Response Body

{
   "code": 200,
   "data": {
       "id": 122606,
       "created_at": "2022-06-20T06:48:01.999965Z",
       "status": "done",
       "action_type": "unlock_vm",
       "resource_id": "97072"
   },
   "errors": {},
   "message": "Success"
}

Power-On Firewall

To power-on firewall , send a Post request-

https://api.e2enetworks.com/myaccount/api/v1/nodes/97072/actions/?apikey={{apikey}}

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/97072/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/97072/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)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Request Body-

{
       "type": "power_on"
}

Response Body

{
   "code": 200,
   "data": {
       "id": 122622,
       "created_at": "2022-06-20T07:39:09.066759Z",
       "status": "done",
       "action_type": "power_on",
       "resource_id": "97072"
   },
   "errors": {},
   "message": "Success"
}

Power -off Firewall

To power-off firewall , send a Get request-

https://api.e2enetworks.com/myaccount/api/v1/nodes/97072/actions/?apikey={{apikey}}

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/97072/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/97072/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)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Request Body-

{
       "type": "power_off"
}

Response Body

{
   "code": 200,
   "data": {
       "id": 122621,
       "created_at": "2022-06-20T07:38:34.259238Z",
       "status": "done",
       "action_type": "power_off",
       "resource_id": "97072"
   },
   "errors": {},
   "message": "Success"
}

Reboot Firewall

To reboot firewall, send a Post request :-

https://api.e2enetworks.com/myaccount/api/v1/nodes/96382/actions/?apikey={{apikey}}

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/97072/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/97072/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)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Request Body-

{
       "type": "reboot"
}

Response Body

{
   "code": 200,
   "data": {
       "id": 122629,
       "created_at": "2022-06-20T07:49:25.471551Z",
       "status": "done",
       "action_type": "reboot",
       "resource_id": "97072"
   },
   "errors": {},
   "message": "Success"
}

Reinstall Firewall

To reinstall firewall, send a Post request-

https://api.e2enetworks.com/myaccount/api/v1/nodes/96382/actions/?apikey={{apikey}}

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/97072/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/97072/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)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Request Body-

{
       "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}}

PYTHON

1. Python - http.client Example

  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", 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/update_committed_node_status/?apikey={{api_key}}&location=Delhi"

   payload = json.dumps({
              "committed_plan": 1036,
              "node_status": "auto_renew",
              "vcn_id": 97072
               })
    headers = {
              'Authorization': 'api_token',
              'Content-Type': 'application/json',
          }

    response = requests.request("POST", url, headers=headers, data=payload)

    print(response.text)

Headers

Request Headers

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Response Headers:-

content-type: application/json; charset=utf-8
status: 202 Accepted

Body

Request Body-

{
       "committed_plan": 1036,
       "node_status": "auto_renew",
       "vcn_id": 97072
}

Response Body

{
   "status": 200,
   "message": "Updated Successfully"
}