From f0606a08799663f12f7999945980dc1df06fe048 Mon Sep 17 00:00:00 2001 From: mia Date: Tue, 30 Jul 2024 12:58:25 -0700 Subject: replace requests with httpx --- zoner.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'zoner.py') 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"], -- cgit 1.4.1