Move API from /map/api/ to /api/v1/

This commit is contained in:
Sebastian Lohff 2020-06-07 02:19:50 +02:00
parent a609eff143
commit 15f4971bde
4 changed files with 27 additions and 19 deletions

21
bgpdata/api_urls.py Normal file
View File

@ -0,0 +1,21 @@
# 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)
from django.conf.urls import url, include
from bgpdata.api import ASResource, CrawlResource, CrawlGraphResource, BorderRouterResource, AnnouncementResource
asResource = ASResource()
crawlResource = CrawlResource()
crawlGraphResource = CrawlGraphResource()
borderRouterResource = BorderRouterResource()
announcementResource = AnnouncementResource()
urlpatterns = (
url('', include(asResource.urls)),
url('', include(crawlResource.urls)),
url('', include(crawlGraphResource.urls)),
url('', include(borderRouterResource.urls)),
url('', include(announcementResource.urls)),
)

View File

@ -238,12 +238,12 @@ function click(d) {
//}); //});
if(d.crawled) { if(d.crawled) {
$.ajax({url: "/map/api/borderrouter/?AS__crawl={{crawl.pk}}&AS__number=" + d.asnumber, success: function(result) { $.ajax({url: "/api/v1/borderrouter/?AS__crawl={{crawl.pk}}&AS__number=" + d.asnumber, success: function(result) {
$("#infowin").html(''); $("#infowin").html('');
$("#infowin").fadeIn('fast', function() {}); $("#infowin").fadeIn('fast', function() {});
for(var i=0; i<result.objects.length; i++) { for(var i=0; i<result.objects.length; i++) {
(function(currRouter) { (function(currRouter) {
$.ajax({url:"/map/api/announcement/?router="+currRouter.id, success: function(result2) { $.ajax({url:"/api/v1/announcement/?router="+currRouter.id, success: function(result2) {
astable = 'Table for AS'+d.asnumber+' router ID ' + currRouter.routerID; astable = 'Table for AS'+d.asnumber+' router ID ' + currRouter.routerID;
astable += '<table class="table table-bordered">'; astable += '<table class="table table-bordered">';
astable += '<tr><th>Network</th><th>Next Hop</th><th>AS Path</th></tr>'; astable += '<tr><th>Network</th><th>Next Hop</th><th>AS Path</th></tr>';

View File

@ -1,28 +1,12 @@
# This file is part of dnmapper, an AS--level mapping tool # This file is part of dnmapper, an AS--level mapping tool
# Licensed under GNU General Public License v3 or later # Licensed under GNU General Public License v3 or later
# Written by Sebastian Lohff (seba@someserver.de) # Written by Sebastian Lohff (seba@someserver.de)
from django.conf.urls import url
from django.conf.urls import url, include
from bgpdata.api import ASResource, CrawlResource, CrawlGraphResource, BorderRouterResource, AnnouncementResource
from bgpdata import views as bgpdata_views from bgpdata import views as bgpdata_views
asResource = ASResource()
crawlResource = CrawlResource()
crawlGraphResource = CrawlGraphResource()
borderRouterResource = BorderRouterResource()
announcementResource = AnnouncementResource()
urlpatterns = ( urlpatterns = (
url(r'^$', bgpdata_views.overview), url(r'^$', bgpdata_views.overview),
url(r'^([0-9]+)/$', bgpdata_views.showMap), url(r'^([0-9]+)/$', bgpdata_views.showMap),
url(r'^new/([0-9]+|live)/$', bgpdata_views.show_new_map), url(r'^new/([0-9]+|live)/$', bgpdata_views.show_new_map),
# url(r'^api/crawl/(?P<crawlID>\d+)/asses/$', 'bgpdata.api.asses'),
# (r'^api/', include(asResource.urls)),
url(r'^api/', include(asResource.urls)),
url(r'^api/', include(crawlResource.urls)),
url(r'^api/', include(crawlGraphResource.urls)),
url(r'^api/', include(borderRouterResource.urls)),
url(r'^api/', include(announcementResource.urls)),
) )

View File

@ -5,7 +5,9 @@
from django.conf.urls import include, url from django.conf.urls import include, url
from django.contrib import admin from django.contrib import admin
from django.views.generic import RedirectView from django.views.generic import RedirectView
import bgpdata.urls import bgpdata.urls
import bgpdata.api_urls
urlpatterns = ( urlpatterns = (
# Examples: # Examples:
@ -13,6 +15,7 @@ urlpatterns = (
# url(r'^blog/', include('blog.urls')), # url(r'^blog/', include('blog.urls')),
url(r'^$', RedirectView.as_view(url='/map/')), url(r'^$', RedirectView.as_view(url='/map/')),
url(r'^map/', include(bgpdata.urls)), url(r'^map/', include(bgpdata.urls)),
url(r'^api/v1/', include(bgpdata.api_urls)),
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
) )