cloudflare-delete-all-dns-r.../app.py

32 lines
884 B
Python

import json
from sys import argv
from pathlib import Path
import requests
from apicalls import *
# Get API key and Email address
def getCredentials():
api_key = input("Enter the Cloudflare API key: ")
email_address = input("Enter the Cloudflare Email address: ")
return {"api_key": api_key, "email": email_address}
# Get credentials
if len(argv) > 1 and 'loadconfig' in argv:
if Path("config.json").exists():
configfile = open("config.json")
config = json.load(configfile)
credentials = {'api_key': config['API_Key'], 'email': config['Email']}
else:
print('config.json was not found. Please enter the credentials manually')
credentials = getCredentials()
else:
credentials = getCredentials()
# print(credentials)
zones = listAllZones(credentials).json()["result"]
# print(f"{zones.status_code}\n{zones.json()}")