Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/export-firewall-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Export all of the firewall configurations given a user and a company.
In this example app, we use the Python SDK to perform various operations:
* Login.
* Get all of the edges for a given user and company.
* Iterate through all of the edges and get their firewall configurations.
* Export all the firewall configs to a JSON file.
34 changes: 34 additions & 0 deletions examples/export-firewall-config/export-firewall-config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import iland
import time
import json

CLIENT_ID = ''
CLIENT_SECRET = ''
USERNAME = ''
PASSWORD = ''
COMPANY_ID = ''

api = iland.Api(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, username=USERNAME, password=PASSWORD)

def main():
export_edge_firewalls()

def export_edge_firewalls():

# Get all the edges for a given user and company.
edges = api.get('/users/%s/companies/%s/edges' % (USERNAME, COMPANY_ID))['data']

# After getting all the edges, iterate through all of them and get the firewall for each.
firewalls = []
for edge in edges:
# Get the uuid of the edge
edge_uuid = edge['uuid']
firewall = api.get('/edge-gateways/%s/firewall' % (edge_uuid))
firewalls.append(firewall)

# Write all the firewall configurations to a file.
with open('firewall-configs.json', 'w') as outfile:
json.dump(firewalls, outfile, indent=1)

if __name__ == '__main__':
main()