url = "https://api.cloudflare.com/client/v4/"
destination_conf = "s3://<BUCKET_NAME>/logs?region=us-west-1"
logpush_url = url + "/zones/ %s /logpush" % zone_id
'Content-Type' : 'application/json'
r = requests . post ( logpush_url + "/jobs" , headers = headers , data = json . dumps ({ "destination_conf" : destination_conf }))
print ( r . status_code , r . text )
assert r . status_code == 201
assert r . json ()[ "result" ][ "enabled" ] == False
id = r . json ()[ "result" ][ "id" ]
r = requests . get ( logpush_url + "/jobs/ %s " % id , headers = headers )
print ( r . status_code , r . text )
assert r . status_code == 200
# Get all jobs for a zone
r = requests . get ( logpush_url + "/jobs" , headers = headers )
print ( r . status_code , r . text )
assert r . status_code == 200
assert len ( r . json ()[ "result" ]) > 0
r = requests . put ( logpush_url + "/jobs/ %s " % id , headers = headers , data = json . dumps ({ "enabled" : True }))
print ( r . status_code , r . text )
assert r . status_code == 200
assert r . json ()[ "result" ][ "enabled" ] == True
r = requests . delete ( logpush_url + "/jobs/ %s " % id , headers = headers )
print ( r . status_code , r . text )
assert r . status_code == 200