Skip to content
Snippets Groups Projects
Commit f5d0f732 authored by Sam Roberts's avatar Sam Roberts
Browse files

individual asn requests work, but not the complete list

parent 9fabc328
No related branches found
No related tags found
1 merge request!3Feature/reporting 311 add msr asn peers
......@@ -1173,3 +1173,23 @@ def vpn_proxy():
peerings = list(_format_peerings(vpnproxy))
response = json.dumps(peerings)
return Response(response, mimetype='application/json')
@routes.route('/asn-peers', methods=['GET', 'POST'], defaults={'asn': None})
@routes.route('/asn-peers/<asn>', methods=['GET', 'POST'])
@common.require_accepts_json
def asn_peers(asn):
r = common.get_current_redis()
if asn is not None:
cache_key = f'classifier-cache:msr:asn-peers:{asn}'
response = _ignore_cache_or_retrieve(request, cache_key, r)
if not response:
peers = json.loads(r.get(f'juniper-peerings:peer-asn:{asn}'))
response = json.dumps(peers)
else:
cache_key = f'classifier-cache:msr:asn-peers'
response = _ignore_cache_or_retrieve(request, cache_key, r)
if not response:
peers = json.loads(r.get(f'juniper-peerings:peer-asn'))
response = json.dumps(peers)
return Response(response, mimetype='application/json')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment