aboutsummaryrefslogtreecommitdiffstats
path: root/arthur/apis/cloudflare/zones.py
diff options
context:
space:
mode:
authorGravatar Vivaan Verma <[email protected]>2021-07-19 15:49:41 +0100
committerGravatar Vivaan Verma <[email protected]>2021-07-19 15:49:41 +0100
commitd8fbfffebfac31604c7b6fcf9b5b96a8e945791b (patch)
treee6becef46e0639de9ebece0405f36cefc7570336 /arthur/apis/cloudflare/zones.py
parentFinished the CF cache purge command (diff)
Lint all code with black
Diffstat (limited to 'arthur/apis/cloudflare/zones.py')
-rw-r--r--arthur/apis/cloudflare/zones.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/arthur/apis/cloudflare/zones.py b/arthur/apis/cloudflare/zones.py
index 93c29d1..e2955f7 100644
--- a/arthur/apis/cloudflare/zones.py
+++ b/arthur/apis/cloudflare/zones.py
@@ -7,12 +7,11 @@ from arthur.config import CONFIG
CF_TOKEN = CONFIG.cloudflare_token
+
async def list_zones(zone_name: Optional[str] = None) -> dict[str, str]:
endpoint = f"https://api.cloudflare.com/client/v4/zones"
- request_headers = {
- "X-Auth-User-Service-Key": CF_TOKEN
- }
+ request_headers = {"X-Auth-User-Service-Key": CF_TOKEN}
if zone_name is not None:
endpoint += f"?name={zone_name}"
@@ -29,16 +28,10 @@ async def list_zones(zone_name: Optional[str] = None) -> dict[str, str]:
async def purge_zone(zone_identifier: 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": CF_TOKEN
- }
+ request_headers = {"X-Auth-User-Service-Key": CF_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"]
- }
+ return {"success": info["success"], "errors": info["errors"]}