Created
April 23, 2018 22:56
-
-
Save kongakong/85b3972c479e42cfb726884eb83adb19 to your computer and use it in GitHub Desktop.
Print out page rules on Cloudflare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import pprint | |
import os | |
TOKEN=os.environ['TOKEN'] | |
ZONE=os.environ['ZONE'] | |
EMAIL="your email" | |
def get_all_rules(): | |
headers = { | |
"X-Auth-Email": EMAIL, | |
"X-Auth-Key": TOKEN, | |
"Content-Type": "application/json" | |
} | |
url ="https://api.cloudflare.com/client/v4/zones/%s/pagerules?status=active&order=status&direction=desc&match=all" | |
r = requests.get(url % ZONE, headers=headers) | |
response = r.json() | |
for result in response['result']: | |
print "=" * 10 | |
pprint.pprint(result) | |
if __name__ == '__main__': | |
get_all_rules() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment