aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Vivaan Verma <[email protected]>2021-07-19 14:12:16 +0100
committerGravatar Vivaan Verma <[email protected]>2021-07-19 14:12:16 +0100
commit872d5c0049abbaae9c05e0fdffe5e8bb52a0bbcf (patch)
tree959705f3658fb86f3bb29e2bdf2ac090af9f8a99
parentCorrect usage of interaction.respond in deployments (diff)
Add Cloudflare API for zones
-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"]
+ }
+