2018-01-19 13:28:52 +01:00
|
|
|
# This file is part of dnmapper, an AS--level mapping tool
|
|
|
|
# Licensed under GNU General Public License v3 or later
|
|
|
|
# Written by Sebastian Lohff (seba@someserver.de)
|
|
|
|
|
2015-03-28 13:04:49 +01:00
|
|
|
from tastypie.resources import ModelResource, ALL_WITH_RELATIONS, ALL
|
|
|
|
from tastypie import fields
|
|
|
|
from bgpdata.models import AS, CrawlRun, Announcement, BorderRouter
|
2015-03-27 15:33:54 +01:00
|
|
|
|
2020-06-06 17:46:08 +02:00
|
|
|
|
2015-03-28 13:04:49 +01:00
|
|
|
class ASResource(ModelResource):
|
2020-05-31 01:07:44 +02:00
|
|
|
crawl = fields.ForeignKey("bgpdata.api.CrawlResource", "crawl")
|
2020-06-06 17:46:08 +02:00
|
|
|
|
2020-05-31 01:07:44 +02:00
|
|
|
class Meta:
|
|
|
|
list_allowed_methods = ['get']
|
|
|
|
detail_allowed_methods = ['get']
|
|
|
|
filtering = {'crawl': ALL_WITH_RELATIONS, 'number': ALL}
|
2015-03-28 13:04:49 +01:00
|
|
|
|
2020-05-31 01:07:44 +02:00
|
|
|
queryset = AS.objects.all()
|
|
|
|
resource_name = "as"
|
2015-03-28 13:04:49 +01:00
|
|
|
|
2020-06-06 17:46:08 +02:00
|
|
|
|
2015-03-28 13:04:49 +01:00
|
|
|
class CrawlResource(ModelResource):
|
2020-05-31 01:07:44 +02:00
|
|
|
class Meta:
|
|
|
|
queryset = CrawlRun.objects.all()
|
|
|
|
resource_name = "crawl"
|
2020-06-06 17:46:08 +02:00
|
|
|
excludes = ["graph"]
|
|
|
|
|
|
|
|
|
|
|
|
class CrawlGraphResource(ModelResource):
|
|
|
|
class Meta:
|
|
|
|
queryset = CrawlRun.objects.all()
|
|
|
|
resource_name = "crawl_graph"
|
|
|
|
|
2015-03-28 13:04:49 +01:00
|
|
|
|
|
|
|
class BorderRouterResource(ModelResource):
|
2020-05-31 01:07:44 +02:00
|
|
|
AS = fields.ForeignKey("bgpdata.api.ASResource", "AS")
|
2020-06-06 17:46:08 +02:00
|
|
|
|
2020-05-31 01:07:44 +02:00
|
|
|
class Meta:
|
|
|
|
list_allowed_methods = ['get']
|
|
|
|
detail_allowed_methods = ['get']
|
|
|
|
filtering = {'AS': ALL_WITH_RELATIONS}
|
2015-03-28 13:04:49 +01:00
|
|
|
|
2020-05-31 01:07:44 +02:00
|
|
|
queryset = BorderRouter.objects.all()
|
|
|
|
resource_name = "borderrouter"
|
2015-03-28 13:04:49 +01:00
|
|
|
|
2020-06-06 17:46:08 +02:00
|
|
|
|
2015-03-28 13:04:49 +01:00
|
|
|
class AnnouncementResource(ModelResource):
|
2020-05-31 01:07:44 +02:00
|
|
|
router = fields.ForeignKey("bgpdata.api.BorderRouterResource", "router")
|
2020-06-06 17:46:08 +02:00
|
|
|
|
2020-05-31 01:07:44 +02:00
|
|
|
class Meta:
|
|
|
|
list_allowed_methods = ['get']
|
|
|
|
detail_allowed_methods = ['get']
|
|
|
|
filtering = {'originAS': ALL_WITH_RELATIONS, 'crawlAS': ALL_WITH_RELATIONS, 'router': ALL_WITH_RELATIONS}
|
|
|
|
queryset = Announcement.objects.all()
|