aboutsummaryrefslogtreecommitdiffstats
path: root/arthur/apis/cloudflare/zones.py
diff options
context:
space:
mode:
Diffstat (limited to 'arthur/apis/cloudflare/zones.py')
-rw-r--r--arthur/apis/cloudflare/zones.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/arthur/apis/cloudflare/zones.py b/arthur/apis/cloudflare/zones.py
new file mode 100644
index 0000000..48714a6
--- /dev/null
+++ b/arthur/apis/cloudflare/zones.py
@@ -0,0 +1,19 @@
+import aiohttp
+
+async def purge_zone(zone_identifier: str, api_token: str) -> dict:
+
+ endpoint = f"https://api.cloudflare.com/client/v4/zones/{zone_identifier}/purge_cache?purge_everything=true"
+ request_headers = {
+ "X-Auth-User-Service-Key": api_token
+ }
+
+ async with aiohttp.ClientSession() as session:
+ async with session.post(endpoint, headers=request_headers) as response:
+ info = await response.json()
+
+ return {
+ "success": info["success"],
+ "errors": info["errors"],
+ "messages": info["messages"]
+ }
+