Skip to content

Commit

Permalink
Add function that shows all domains
Browse files Browse the repository at this point in the history
  • Loading branch information
nikilase committed Apr 12, 2024
1 parent d9e288a commit b3f5a6e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
}


def get_domains():
url = f"{API_URL}/domains"
response = requests.get(url, headers=HEADERS)
if response.status_code == 200:
domain_info = response.json()
domains = [x["qualifiedDomainName"] for x in domain_info["domains"]]
print(f"Domains are:\n" f"{domains}\n")
else:
print(
f"Error fetching domains. Status code: {response.status_code} error message:\n"
f"{response.content}\n"
)


def get_domain_data(domain_name):
url = f"{API_URL}/domains/{domain_name}"
response = requests.get(url, headers=HEADERS)
Expand Down
14 changes: 14 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse

from app import push_letsencrypt, check_status
from app.api import get_domains

parser = argparse.ArgumentParser(
description="Run tool for CSC Domain Manager API and Letsencrypt Script."
Expand All @@ -17,10 +18,23 @@
action="store_true",
help="Check the status of the domain. Runs before letsencrypt.",
)

parser.add_argument(
"-d",
"--domains",
action="store_true",
help="Function that can be used to see all domains. Also useful to run every week so that the API Token does not "
"get inactive (after 30 days of no use).",
)
args = parser.parse_args()
print("―" * 20)
no_arg = True

if args.domains:
no_arg = False
get_domains()
print("―" * 20)

if args.check:
no_arg = False
check_status.main()
Expand Down

0 comments on commit b3f5a6e

Please sign in to comment.