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
|
|
|
|
2015-03-28 13:04:49 +01:00
|
|
|
class ASResource(ModelResource):
|
|
|
|
crawl = fields.ForeignKey("bgpdata.api.CrawlResource", "crawl")
|
|
|
|
class Meta:
|
|
|
|
list_allowed_methods = ['get']
|
|
|
|
detail_allowed_methods = ['get']
|
|
|
|
filtering = {'crawl': ALL_WITH_RELATIONS, 'number': ALL}
|
|
|
|
|
|
|
|
queryset = AS.objects.all()
|
|
|
|
resource_name = "as"
|
|
|
|
|
|
|
|
class CrawlResource(ModelResource):
|
|
|
|
class Meta:
|
|
|
|
queryset = CrawlRun.objects.all()
|
|
|
|
resource_name = "crawl"
|
|
|
|
|
|
|
|
class BorderRouterResource(ModelResource):
|
|
|
|
AS = fields.ForeignKey("bgpdata.api.ASResource", "AS")
|
|
|
|
class Meta:
|
|
|
|
list_allowed_methods = ['get']
|
|
|
|
detail_allowed_methods = ['get']
|
|
|
|
filtering = {'AS': ALL_WITH_RELATIONS}
|
|
|
|
|
|
|
|
queryset = BorderRouter.objects.all()
|
|
|
|
resource_name = "borderrouter"
|
|
|
|
|
|
|
|
class AnnouncementResource(ModelResource):
|
|
|
|
router = fields.ForeignKey("bgpdata.api.BorderRouterResource", "router")
|
|
|
|
class Meta:
|
|
|
|
list_allowed_methods = ['get']
|
|
|
|
detail_allowed_methods = ['get']
|
2017-01-18 00:19:36 +01:00
|
|
|
filtering = {'originAS': ALL_WITH_RELATIONS, 'crawlAS': ALL_WITH_RELATIONS, 'router': ALL_WITH_RELATIONS}
|
2015-03-28 13:04:49 +01:00
|
|
|
queryset = Announcement.objects.all()
|