import requests
import base64
import json
# Configuration
baseUrl = "https://localhost:8443"
username = "---USERNAME---"
password = "---PASSWORD---"
# Login & get JWT token
headers = {
"Authorization":
"Basic " +
base64
.b64encode(
(username + ":" + password)
.encode('utf-8')
)
.decode('utf-8')
}
response = requests.request("POST", "%s/api/v1/auth/login" % baseUrl, headers=headers, verify=False)
if response.status_code != 200:
print("Login failed")
exit()
authToken = response.text
headers = {"Authorization": "Bearer " + authToken}
response = requests.get("%s/api/v1/listeners" % baseUrl, headers=headers, verify=False)
if response.status_code != 200:
print("Could not get list of added listeners")
print(response.text)
exit()
data = json.loads(response.text)
print("Listeners:")
for listenerId in data:
print(" #%s %s %s " % (data[listenerId]["id"], data[listenerId]["status"], data[listenerId]["info"]))