Skip to content

Instantly share code, notes, and snippets.

@tonytan4ever
Created January 20, 2015 16:35
Show Gist options
  • Save tonytan4ever/0ac175d0ab29247a3621 to your computer and use it in GitHub Desktop.
Save tonytan4ever/0ac175d0ab29247a3621 to your computer and use it in GitHub Desktop.
import requests
import json
from akamai.edgegrid import EdgeGridAuth
def main():
s = requests.Session()
s.auth = EdgeGridAuth(
# This is rax_test credential
client_token = '<your_token>',
client_secret='<your_secret>',
access_token='<your_access_token>')
data = {u'rules':
[{u'matches': [{u'name': u'url-wildcard', u'value': u'/*'}],
u'behaviors': [
{u'params':
{u'cacheKeyValue': u'-',
u'digitalProperty': u'preview.drawbuildplay.com',
u'cacheKeyType': u'origin',
u'hostHeaderValue': u'-',
u'originDomain': u'preview.drawbuildplay.com',
u'hostHeaderType': u'digital_property'
},
u'name': u'origin',
u'value': u'-'},
{u'type': u'fixed', u'name': u'caching', u'value': u'3600s'}]}]}
response = s.put(
'https://<your_access_url>/partner-api/v1/network/production/properties/208892/sub-properties/www.textxxx.com/policy',
data=json.dumps(data),
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'})
#===========================================================================
#===========================================================================
# response = s.delete(
# 'https://akab-3r276kizolbgfqbi-6tnfu4jessqtn4b4.luna.akamaiapis.net'
# '/partner-api/v1/network/production/properties/205644/'
# 'sub-properties/new_service_name/policy', #data=json.dumps(data),
# headers = {'Content-type': 'application/json', 'Accept': 'text/plain'})
#===========================================================================
print response.status_code
print json.loads(response.text)
resp_dict = json.loads(response.text)
#print resp_dict['rules'][0]['matches']#[0].get('url-scheme', 'http')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment