36 lines
917 B
Python
36 lines
917 B
Python
# flake8: noqa
|
|
import os
|
|
import subprocess
|
|
import json
|
|
from pprint import pp
|
|
import httpx
|
|
|
|
# todo: dnspython to read builtins.toString vacuconfig.x86_64-linux.vacu.dns."jean-luc.org"
|
|
|
|
SOPS_BIN = '@sops@'
|
|
DNS_SECRETS_FILE = '@dns_secrets_file@'
|
|
data_str = '@data@'
|
|
DATA = json.loads(data_str)
|
|
|
|
secrets_json = subprocess.check_output([SOPS_BIN, "-d", DNS_SECRETS_FILE])
|
|
secrets = json.loads(secrets_json)
|
|
|
|
AUTH_ID = secrets["auth_id"]
|
|
AUTH_PASSWORD = secrets["auth_password"]
|
|
|
|
BASE_URL = "https://api.cloudns.net"
|
|
|
|
def req(path, **kwargs):
|
|
auth_params = {
|
|
"auth-id": AUTH_ID,
|
|
"auth-password": AUTH_PASSWORD,
|
|
}
|
|
|
|
params = { k.replace("_","-"): v for k, v in kwargs.items() }
|
|
|
|
return httpx.get(BASE_URL + path, params={**auth_params, **params}).json()
|
|
|
|
res = req("/dns/records.json", domain_name = "jean-luc.org", rows_per_page = 100)
|
|
#records = [x for x in res.values()]
|
|
pp(res.get("status"))
|