Purge cache in Akamai CDN

Python script to purge cache in Akamai CDN (you can add it as automation in your CI CD flow)

33

Votes

baseurl = 'AKAMAI-BASE-URL'
s = requests.Session()
s.auth = EdgeGridAuth(
    client_token='YOUR-CLIENT-TOKEN',
    client_secret='YOUR-CLIENT-SECRET',
    access_token='YOUR-ACCESS-TOKEN'
)

url=baseurl+"ccu/v2/queues/default"
headers = {'Content-Type': 'application/json'}
v ='{"type": "arl","action": "invalidate","domain": "DOMAIN","objects": [ "'+URL+'" ]}'
value = json.dumps(v)
values = json.loads(value)
r = s.post(urljoin(baseurl, 'ccu/v2/queues/default'), data=values, headers=headers)
print r.status_code
print r.content

Vote Here

You must earn at least 1 vote on your snippets to be allowed to vote

Terms Of Use

Privacy Policy

Featured snippets are MIT license

Gears & Masters

Advertise

DevOpsnipp.com © 2020

medium.png