diff options
author | mia <mia@mia.jetzt> | 2024-07-30 12:58:25 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-07-30 12:58:25 -0700 |
commit | f0606a08799663f12f7999945980dc1df06fe048 (patch) | |
tree | 704d7b702beb5c1a16299930519e3cc01b4bbaaa /zoner.py | |
parent | 1d3ae7d37838be13b7c5dc28f0657577eeaff759 (diff) | |
download | zoner-f0606a08799663f12f7999945980dc1df06fe048.tar.gz zoner-f0606a08799663f12f7999945980dc1df06fe048.zip |
replace requests with httpx
Diffstat (limited to 'zoner.py')
-rw-r--r-- | zoner.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/zoner.py b/zoner.py index f4d4b1c..7772384 100644 --- a/zoner.py +++ b/zoner.py @@ -1,7 +1,7 @@ from pathlib import Path import tomllib import os -import requests +import httpx import subprocess import sys @@ -78,15 +78,15 @@ def update_rules(rules: dict, statement: str): raise ValueError(f"invalid rule {key}") -def check_porkbun(resp: requests.Response): +def check_porkbun(resp: httpx.Response): if resp.status_code >= 400: - raise requests.HTTPError( + raise httpx.HTTPError( f"got code {resp.status_code}: {resp.json()}", response=resp ) def retrieve(domain: str): - resp = requests.post( + resp = httpx.post( f"https://porkbun.com/api/json/v3/dns/retrieve/{domain}", json={"apikey": cfg["api_key"], "secretapikey": cfg["secret_key"]}, ) @@ -156,7 +156,7 @@ def balance(domain: str): for record in to_delete: print(f"delete {record}") - resp = requests.post( + resp = httpx.post( f"https://porkbun.com/api/json/v3/dns/delete/{domain}/{record.meta['id']}", json={"apikey": cfg["api_key"], "secretapikey": cfg["secret_key"]}, ) @@ -168,7 +168,7 @@ def balance(domain: str): prio = None if record.kind == "MX": prio, content = content.split(" ") - resp = requests.post( + resp = httpx.post( f"https://porkbun.com/api/json/v3/dns/create/{domain}", json={ "apikey": cfg["api_key"], |