Compare commits

..

No commits in common. '35593bb503be3a36aff1dc3f35acf80693999cc8' and 'fb89d01be1d48942c0f31618ca30c991e8cb75c9' have entirely different histories.

@ -7,7 +7,7 @@ import os
import sys import sys
import urllib.parse import urllib.parse
from os import environ, mkdir from os import environ, mkdir
from os.path import isdir, isfile, islink, join, split from os.path import isdir, isfile, join, split
from typing import Union from typing import Union
from urllib.parse import urlparse from urllib.parse import urlparse
@ -81,7 +81,7 @@ def run_add(url: str, jsonout: bool, headers: dict):
output(out, jsonout) output(out, jsonout)
def run_log(url: str, jsonout: bool, headers: dict): def run_audit(url: str, jsonout: bool, headers: dict):
response = requests.get(url, headers=headers) response = requests.get(url, headers=headers)
string = response.content.decode("utf-8") string = response.content.decode("utf-8")
if jsonout: if jsonout:
@ -139,15 +139,7 @@ def run_config(
baseurl: Union[None, str] = None, baseurl: Union[None, str] = None,
username: Union[None, str] = None, username: Union[None, str] = None,
password: Union[None, str] = None, password: Union[None, str] = None,
current: Union[None, str] = None,
): ):
if current:
if os.path.islink(config_filename):
actual_path = os.readlink(config_filename)
print(actual_path.split('-')[-1])
else:
print("none")
return
config = {"baseurl": baseurl, "username": username, "password": password} config = {"baseurl": baseurl, "username": username, "password": password}
needed = [] needed = []
if context: if context:
@ -362,12 +354,8 @@ def main() -> int:
addcmd.add_argument("-t", "--ttl") addcmd.add_argument("-t", "--ttl")
addcmd.add_argument("-z", "--zone", required=True) addcmd.add_argument("-z", "--zone", required=True)
auditlog_description = "Audit the log file for errors." audit_description = "Audit the log file for errors."
subparsers.add_parser("auditlog", description=auditlog_description) subparsers.add_parser("audit", description=audit_description)
changelog_description = "View the changelog of a zone."
changelogcmd = subparsers.add_parser("changelog", description=changelog_description)
changelogcmd.add_argument("-z", "--zone", required=True)
complete_description = "Generate shell completion script." complete_description = "Generate shell completion script."
completecmd = subparsers.add_parser("completion", description=complete_description) completecmd = subparsers.add_parser("completion", description=complete_description)
@ -377,7 +365,6 @@ def main() -> int:
configcmd = subparsers.add_parser("config", description=config_description) configcmd = subparsers.add_parser("config", description=config_description)
configcmd.add_argument("-b", "--baseurl") configcmd.add_argument("-b", "--baseurl")
configcmd.add_argument("-c", "--context") configcmd.add_argument("-c", "--context")
configcmd.add_argument("-C", "--current", action=argparse.BooleanOptionalAction)
configcmd.add_argument("-p", "--password") configcmd.add_argument("-p", "--password")
configcmd.add_argument("-u", "--username") configcmd.add_argument("-u", "--username")
@ -446,7 +433,7 @@ def main() -> int:
if args.command == "config": if args.command == "config":
run_config( run_config(
config_filename, args.context, args.baseurl, args.username, args.password, args.current config_filename, args.context, args.baseurl, args.username, args.password
) )
return 0 return 0
@ -486,8 +473,8 @@ def main() -> int:
soa_url = setup_url(baseurl, None, None, zname, "SOA", None, args.zone) soa_url = setup_url(baseurl, None, None, zname, "SOA", None, args.zone)
soa_json = run_list(soa_url, True, headers, ret=True) soa_json = run_list(soa_url, True, headers, ret=True)
ttl = soa_json[0]["ttl"] ttl = soa_json[0]["ttl"]
elif args.command in ["auditlog", "changelog"]: if args.command == "audit":
pass url = baseurl + "/user/auditlog"
else: else:
try: try:
url = setup_url( url = setup_url(
@ -512,12 +499,8 @@ def main() -> int:
run_list(url, args.json, headers) run_list(url, args.json, headers)
elif args.command == "update": elif args.command == "update":
run_update(url, args.json, headers) run_update(url, args.json, headers)
elif args.command == "auditlog": elif args.command == "audit":
url = baseurl + "/user/auditlog" run_audit(url, args.json, headers)
run_log(url, args.json, headers)
elif args.command == "changelog":
url = baseurl + f"/zones/changelog/{args.zone.rstrip('.')}"
run_log(url, args.json, headers)
else: else:
parser.print_help(sys.stderr) parser.print_help(sys.stderr)
return 1 return 1

Loading…
Cancel
Save