dns-check-py/generate-zone-list.py
2023-11-30 14:53:37 +01:00

25 lines
455 B
Python

import requests
import yaml
__API_KEY = 'YXJkQU1VVkRoSGZyV0FP'
__API_URL = 'https://dns.it53.nl:8443/api/v1/servers/localhost/zones'
__MASTER_DNS = 'ns1.it53.nl'
headers = {
'X-API-Key': __API_KEY,
}
response = requests.get(__API_URL, headers=headers)
data = response.json()
# Format zones
zones = [{'name': d['name'].rstrip('.'), 'type': d['kind'].lower()} for d in data]
# Dump to YAML
output = yaml.dump({'zones': zones})
print(output)