New clean rules script
1import os
2
3import dotenv
4from cf_rules import Cloudflare
5
6dotenv.load_dotenv(".env")
7
8cf = Cloudflare("expressions")
9cf.auth_key(os.environ.get("EMAIL"), os.environ.get("KEY"))
10
11# TODO Have some rules in the expressions folder
12
13# First delete all existing rules
14cf.purge_rules("example.com")
15
16# Then import all the rules from your expressions folder
17cf.import_rules("example.com", "block")
Danger
This script is cleaning all the rules from a domain. It is used if you want to replicate the rules from a domain to another one.
Be careful when using cf.Cloudflare.purge_rules()
method.