diff options
| -rw-r--r-- | arthur/apis/cloudflare/zones.py | 6 | ||||
| -rw-r--r-- | arthur/exts/cloudflare/zones.py | 12 |
2 files changed, 11 insertions, 7 deletions
diff --git a/arthur/apis/cloudflare/zones.py b/arthur/apis/cloudflare/zones.py index a5a81d8..9098d99 100644 --- a/arthur/apis/cloudflare/zones.py +++ b/arthur/apis/cloudflare/zones.py @@ -1,15 +1,15 @@ +"""APIs for managing Cloudflare zones.""" from typing import Optional import aiohttp from arthur.config import CONFIG - CF_TOKEN = CONFIG.cloudflare_token async def list_zones(zone_name: Optional[str] = None) -> dict[str, str]: - + """List all Cloudflare zones.""" endpoint = "https://api.cloudflare.com/client/v4/zones" request_headers = {"X-Auth-User-Service-Key": CF_TOKEN} @@ -26,7 +26,7 @@ async def list_zones(zone_name: Optional[str] = None) -> dict[str, str]: async def purge_zone(zone_identifier: str) -> dict: - + """Purge the cache for a Cloudflare zone.""" endpoint = f"https://api.cloudflare.com/client/v4/zones/{zone_identifier}/purge_cache?purge_everything=true" # noqa: E501 request_headers = {"X-Auth-User-Service-Key": CF_TOKEN} diff --git a/arthur/exts/cloudflare/zones.py b/arthur/exts/cloudflare/zones.py index 3b8b3b7..c6e625f 100644 --- a/arthur/exts/cloudflare/zones.py +++ b/arthur/exts/cloudflare/zones.py @@ -1,4 +1,4 @@ -"""The zones cog helps with managing Cloudflare zones""" +"""The zones cog helps with managing Cloudflare zones.""" from typing import Optional from discord.ext import commands @@ -8,17 +8,21 @@ from arthur.bot import KingArthur class Zones(commands.Cog): + """Commands for working with Cloudflare zones.""" + def __init__(self, bot: KingArthur) -> None: self.bot = bot @commands.group(name="zones", invoke_without_command=True) async def zones(self, ctx: commands.Context) -> None: - "Commands for working with Cloudflare zones" + """Commands for working with Cloudflare zones.""" await ctx.send_help(ctx.command) @zones.command(name="purge") - async def purge(self, ctx: commands.Context, zone_name: Optional[str] = "pythondiscord.com"): - """Command to clear the Cloudflare cache of the specified zone""" + async def purge(self, ctx: commands.Context, + zone_name: Optional[str] = "pythondiscord.com" + ) -> None: + """Command to clear the Cloudflare cache of the specified zone.""" pydis_zones = await zones.list_zones(zone_name) required_id = pydis_zones[zone_name] purge_attempt_response = await zones.purge_zone(required_id) |