2018-08-15 21:41:57 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
2018-08-15 22:00:21 +00:00
|
|
|
import json
|
2018-08-15 21:41:57 +00:00
|
|
|
import CloudFlare
|
|
|
|
|
2018-11-19 14:04:08 +00:00
|
|
|
email = 'jakub@status.im'
|
|
|
|
token = os.environ['CF_TOKEN']
|
|
|
|
|
|
|
|
cf = CloudFlare.CloudFlare(email, token)
|
|
|
|
|
2018-08-15 22:00:21 +00:00
|
|
|
#zones = cf.zones.get(params = {'per_page':100})
|
|
|
|
#zone_id = zones[0]['id']
|
|
|
|
#zone_name = zones[0]['id']
|
|
|
|
#print('Zones:', [z['name'] for z in zones])
|
2018-08-15 21:41:57 +00:00
|
|
|
|
2018-11-19 14:04:08 +00:00
|
|
|
logs = cf.organizations.audit_logs.get('113ef908d19933ef327f079a3def53fc',
|
|
|
|
params={
|
|
|
|
'since': '2018-01-01',
|
|
|
|
'per_page': 5000,
|
|
|
|
'order': 'when',
|
|
|
|
'direction': 'asc',
|
|
|
|
'zone.name': 'status.im'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
for log in logs:
|
|
|
|
if log['action']['type'] not in ['add', 'delete']:
|
2018-08-15 22:00:21 +00:00
|
|
|
continue
|
2018-11-19 14:04:08 +00:00
|
|
|
print('{:30} {:20} {:12} {:>10} {:>7} {:30} {}'.format(
|
|
|
|
log['when'],
|
|
|
|
log['actor'].get('email', log['metadata'].get('acted_on_behalf_of')),
|
|
|
|
log['metadata'].get('zone_name'),
|
|
|
|
log['action'].get('type'),
|
|
|
|
log['metadata'].get('type') or '',
|
|
|
|
log['metadata'].get('name') or '',
|
|
|
|
log['metadata'].get('content') or ''
|
|
|
|
))
|