-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery_cnames.py
More file actions
30 lines (19 loc) · 823 Bytes
/
query_cnames.py
File metadata and controls
30 lines (19 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import dns.resolver, requests, json, sys, os
from akamai.edgegrid import EdgeGridAuth,EdgeRc
import urllib
edgerc_file_path = os.path.expanduser('~/.edgerc')
edgerc_object = EdgeRc(edgerc_file_path)
baseurl = 'https://' + edgerc_object.get('default', 'host')
r = requests.Session()
r.auth = EdgeGridAuth.from_edgerc(edgerc_object, 'default')
# api_enr = baseurl + '/cps/v2/enrollments?contractId=ctr_C-IXCOB3&accountSwitchKey=EP-2LU'
api_enr = baseurl + '/papi/v1/contracts?accountSwitchKey=1-AITJY'
print(api_enr)
response = r.get(url=api_enr)
enrollments_json = response.json()
print(json.dumps(enrollments_json, indent=3))
# for enrollment in enrollments_json['enrollments']:
# print (enrollment['location'])
# answer = dns.resolver.query('www.discover.com', 'CNAME')
# for rdata in answer:
# print (rdata)