Skip to content

Commit

Permalink
Update API
Browse files Browse the repository at this point in the history
  • Loading branch information
David Cruz committed Aug 31, 2023
1 parent 1ab5f45 commit 40dee27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
8 changes: 5 additions & 3 deletions panw_utils/get_panw_firewalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import signal
import ssl
import sys
import urllib.request
import xml.dom.minidom as MD
import xml.etree.ElementTree as ET
from urllib import parse
from urllib.request import urlopen


def sigint_handler(signum, frame):
sys.exit(1)
Expand All @@ -47,14 +49,14 @@ def query_api(args):
cmd = '<show><devices><connected></connected></devices></show>'
else:
cmd = '<show><devices><all></all></devices></show>'
params = urllib.parse.urlencode({
params = parse.urlencode({
'type': 'op',
'cmd': cmd,
'key': args.key,
})
url = f'https://{args.panorama}/api/?{params}'
try:
with urllib.request.urlopen(url, context=ctx) as response:
with urlopen(url, context=ctx) as response:
xml = response.read().decode('utf-8')
except OSError as err:
sys.stderr.write(f'{args.panorama}: Unable to connect to host ({err})\n')
Expand Down

0 comments on commit 40dee27

Please sign in to comment.