|
|
@ -13,7 +13,9 @@ from typing import Union
|
|
|
|
import argcomplete
|
|
|
|
import argcomplete
|
|
|
|
import requests
|
|
|
|
import requests
|
|
|
|
import yaml
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
from requests.exceptions import JSONDecodeError as RequestsJSONDecodeError
|
|
|
|
from requests.models import HTTPBasicAuth
|
|
|
|
from requests.models import HTTPBasicAuth
|
|
|
|
|
|
|
|
from simplejson.errors import JSONDecodeError as SimplejsonJSONDecodeError
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Helper functions
|
|
|
|
# Helper functions
|
|
|
@ -241,14 +243,18 @@ def main() -> int:
|
|
|
|
if 'ttl' in args:
|
|
|
|
if 'ttl' in args:
|
|
|
|
ttl = args.ttl
|
|
|
|
ttl = args.ttl
|
|
|
|
url = setup_url(baseurl, args.data, args.name, args.rtype, ttl, args.zone)
|
|
|
|
url = setup_url(baseurl, args.data, args.name, args.rtype, ttl, args.zone)
|
|
|
|
if args.command == "add":
|
|
|
|
try:
|
|
|
|
run_add(url, args.json, headers)
|
|
|
|
if args.command == "add":
|
|
|
|
elif args.command == "delete":
|
|
|
|
run_add(url, args.json, headers)
|
|
|
|
run_delete(url, args.json, headers)
|
|
|
|
elif args.command == "delete":
|
|
|
|
elif args.command == "list":
|
|
|
|
run_delete(url, args.json, headers)
|
|
|
|
run_list(url, args.json, headers)
|
|
|
|
elif args.command == "list":
|
|
|
|
elif args.command == "update":
|
|
|
|
run_list(url, args.json, headers)
|
|
|
|
run_update(url, args.json, headers)
|
|
|
|
elif args.command == "update":
|
|
|
|
|
|
|
|
run_update(url, args.json, headers)
|
|
|
|
|
|
|
|
except (RequestsJSONDecodeError, SimplejsonJSONDecodeError):
|
|
|
|
|
|
|
|
output(
|
|
|
|
|
|
|
|
error("Could not decode api response as JSON", "Could not decode"))
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|