No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

api.py 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # This file is part of dnmapper, an AS--level mapping tool
  2. # Licensed under GNU General Public License v3 or later
  3. # Written by Sebastian Lohff (seba@someserver.de)
  4. from tastypie.resources import ModelResource, ALL_WITH_RELATIONS, ALL
  5. from tastypie import fields
  6. from bgpdata.models import AS, CrawlRun, Announcement, BorderRouter
  7. class ASResource(ModelResource):
  8. crawl = fields.ForeignKey("bgpdata.api.CrawlResource", "crawl")
  9. class Meta:
  10. list_allowed_methods = ['get']
  11. detail_allowed_methods = ['get']
  12. filtering = {'crawl': ALL_WITH_RELATIONS, 'number': ALL}
  13. queryset = AS.objects.all()
  14. resource_name = "as"
  15. class CrawlResource(ModelResource):
  16. class Meta:
  17. queryset = CrawlRun.objects.all()
  18. resource_name = "crawl"
  19. class BorderRouterResource(ModelResource):
  20. AS = fields.ForeignKey("bgpdata.api.ASResource", "AS")
  21. class Meta:
  22. list_allowed_methods = ['get']
  23. detail_allowed_methods = ['get']
  24. filtering = {'AS': ALL_WITH_RELATIONS}
  25. queryset = BorderRouter.objects.all()
  26. resource_name = "borderrouter"
  27. class AnnouncementResource(ModelResource):
  28. router = fields.ForeignKey("bgpdata.api.BorderRouterResource", "router")
  29. class Meta:
  30. list_allowed_methods = ['get']
  31. detail_allowed_methods = ['get']
  32. filtering = {'originAS': ALL_WITH_RELATIONS, 'crawlAS': ALL_WITH_RELATIONS, 'router': ALL_WITH_RELATIONS}
  33. queryset = Announcement.objects.all()