trafficcontrol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dang...@apache.org
Subject [1/2] incubator-trafficcontrol git commit: adds back GET api/1.1/asns. the only truly 1.1 api :)
Date Fri, 05 May 2017 17:05:15 GMT
Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master 63f6abf26 -> b74661ba4


adds back GET api/1.1/asns. the only truly 1.1 api :)


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/cebc5ede
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/cebc5ede
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/cebc5ede

Branch: refs/heads/master
Commit: cebc5ede307ea2844eae02b1f8318c921f9dc74c
Parents: 63f6abf
Author: Jeremy Mitchell <mitchell852@gmail.com>
Authored: Fri May 5 09:53:01 2017 -0600
Committer: Dan Kirkwood <dangogh@gmail.com>
Committed: Fri May 5 11:02:42 2017 -0600

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Asn.pm          | 18 ++++++++++++++++++
 traffic_ops/app/lib/TrafficOpsRoutes.pm |  6 ++++++
 2 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/cebc5ede/traffic_ops/app/lib/API/Asn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Asn.pm b/traffic_ops/app/lib/API/Asn.pm
index a271a96..0978abf 100644
--- a/traffic_ops/app/lib/API/Asn.pm
+++ b/traffic_ops/app/lib/API/Asn.pm
@@ -49,6 +49,24 @@ sub index {
 	$self->success( \@data );
 }
 
+sub index_v11 {
+	my $self = shift;
+	my @data;
+	my $orderby = $self->param('orderby') || "asn";
+	my $rs_data = $self->db->resultset("Asn")->search( undef, { prefetch => [ {
'cachegroup' => undef } ], order_by => "me." . $orderby } );
+	while ( my $row = $rs_data->next ) {
+		push(
+			@data, {
+				"id"          => $row->id,
+				"asn"         => $row->asn,
+				"cachegroup"  => $row->cachegroup->name,
+				"lastUpdated" => $row->last_updated,
+			}
+		);
+	}
+	$self->success( { "asns" => \@data } );
+}
+
 # Show
 sub show {
 	my $self = shift;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/cebc5ede/traffic_ops/app/lib/TrafficOpsRoutes.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/TrafficOpsRoutes.pm b/traffic_ops/app/lib/TrafficOpsRoutes.pm
index 483de16..09322b7 100644
--- a/traffic_ops/app/lib/TrafficOpsRoutes.pm
+++ b/traffic_ops/app/lib/TrafficOpsRoutes.pm
@@ -376,6 +376,12 @@ sub api_routes {
 	my $version   = shift;
 	my $namespace = shift;
 
+	# -- 1.1 API ROUTES
+
+	$r->get("/api/1.1/asns")->over( authenticated => 1 )->to( 'Asn#index_v11', namespace
=> $namespace );
+
+	# -- 1.1 or 1.2 API ROUTES
+
 	# -- ASNS (CRANS)
 	$r->get("/api/$version/asns")->over( authenticated => 1 )->to( 'Asn#index',
    namespace => $namespace );
 	$r->get("/api/$version/asns/:id" => [ id => qr/\d+/ ] )->over( authenticated
=> 1 )->to( 'Asn#show', namespace => $namespace );


Mime
View raw message