You can use our REST API to read and edit your site info with Python.
Here's an example that uses the Python requests
module to query the API to produce a list with the info you've mentioned, feel free to modify it to do whatever you need:
import requests
import pprint
# create an API token at https://my.opalstack.com/tokens
# then use that token value in the next line
OPAL_TOKEN = 'XXXXXXXX'
OPAL_HEADERS = {
'Authorization': f'Token {OPAL_TOKEN}',
'Content-Type':'application/json'
}
servers = requests.get(
'https://my.opalstack.com/api/v0/servers/list/',
headers=OPAL_HEADERS
).json()['web_servers']
ips = requests.get(
'https://my.opalstack.com/api/v0/ips/list/',
headers=OPAL_HEADERS
).json()['ips']
sites = requests.get(
'https://my.opalstack.com/api/v0/site/list/',
headers=OPAL_HEADERS
).json()['sites']
for s in sites:
site = requests.get(
f'https://my.opalstack.com/api/v0/site/read/{s["id"]}',
headers=OPAL_HEADERS
).json()
result={}
result['url'] = f'http://my.opalstack.com/site/edit/{site["id"]}'
result['name'] = site['name']
result['server'] = [i['hostname'] for i in servers if i['id'] == site['server']][0]
result['ip'] = [i['ip'] for i in ips if i['id'] == site['ip']][0]
result['domains'] = [i['name'] for i in site['domains']]
result['routes'] = []
for r in site['routes']:
app = requests.get(
f'https://my.opalstack.com/api/v0/app/read/{r["application"]}',
headers=OPAL_HEADERS
).json()
result['routes'].append({
'uri': r['uri'],
'app': app['name'],
'app type': app['app_type']
})
pprint.pprint(result, width=1)