Update to latest version of cloudflare package

This commit is contained in:
Quantum 2025-01-02 00:52:45 -05:00
parent dea0154077
commit 7ff577fd0c
2 changed files with 5 additions and 6 deletions

View file

@ -1,18 +1,16 @@
from CloudFlare import CloudFlare from cloudflare import Cloudflare
from django.conf import settings from django.conf import settings
from qlinks.cdn_cache import BaseCDNCache from qlinks.cdn_cache import BaseCDNCache
class CloudflareCDNCache(BaseCDNCache): class CloudflareCDNCache(BaseCDNCache):
cf: CloudFlare cf: Cloudflare
zone: str zone: str
def __init__(self): def __init__(self):
self.cf = CloudFlare(token=getattr(settings, 'QLINKS_CDN_CLOUDFLARE_API_TOKEN', None)) self.cf = Cloudflare(api_token=getattr(settings, 'QLINKS_CDN_CLOUDFLARE_API_TOKEN', None))
self.zone = settings.QLINKS_CDN_CLOUDFLARE_ZONE_ID self.zone = settings.QLINKS_CDN_CLOUDFLARE_ZONE_ID
def purge(self, url: str) -> None: def purge(self, url: str) -> None:
self.cf.zones.purge_cache.post(self.zone, data={ self.cf.cache.purge(zone_id=self.zone, files=[url])
'files': [url],
})

View file

@ -1,3 +1,4 @@
Django>=4.2,<5 Django>=4.2,<5
django-hosts django-hosts
requests requests
cloudflare