|
|
|
@ -115,9 +115,16 @@ def run_delete(url: str, jsonout: bool, headers: dict):
|
|
|
|
|
output(reply, jsonout)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_list(url: str, jsonout: bool, headers: dict):
|
|
|
|
|
def run_list(url: str,
|
|
|
|
|
jsonout: bool,
|
|
|
|
|
headers: dict,
|
|
|
|
|
ret=False) -> Union[None, str]:
|
|
|
|
|
response = requests.get(url, headers=headers)
|
|
|
|
|
output(response.json(), jsonout)
|
|
|
|
|
string = response.json()
|
|
|
|
|
if ret:
|
|
|
|
|
return string
|
|
|
|
|
else:
|
|
|
|
|
output(string, jsonout)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_update(url: str, jsonout: bool, headers: dict):
|
|
|
|
@ -182,7 +189,7 @@ def main() -> int:
|
|
|
|
|
addcmd.add_argument("-d", "--data", required=True)
|
|
|
|
|
addcmd.add_argument("-n", "--name", required=True)
|
|
|
|
|
addcmd.add_argument("-r", "--rtype", required=True)
|
|
|
|
|
addcmd.add_argument("-t", "--ttl", required=True)
|
|
|
|
|
addcmd.add_argument("-t", "--ttl")
|
|
|
|
|
addcmd.add_argument("-z", "--zone", required=True)
|
|
|
|
|
|
|
|
|
|
completecmd = subparsers.add_parser("completion")
|
|
|
|
@ -261,6 +268,16 @@ def main() -> int:
|
|
|
|
|
ttl = args.ttl
|
|
|
|
|
if args.command != "update":
|
|
|
|
|
args.argument = None
|
|
|
|
|
if args.command == "add" and not ttl:
|
|
|
|
|
if args.zone.endswith('.'):
|
|
|
|
|
zname = args.zone
|
|
|
|
|
else:
|
|
|
|
|
zname = args.zone + '.'
|
|
|
|
|
soa_url = setup_url(baseurl, None, None, zname, "SOA", None,
|
|
|
|
|
args.zone)
|
|
|
|
|
soa_json = run_list(soa_url, True, headers, ret=True)
|
|
|
|
|
ttl = soa_json[0]["ttl"]
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
url = setup_url(baseurl, args.argument, args.data, args.name,
|
|
|
|
|
args.rtype, ttl, args.zone)
|
|
|
|
|