adds the ability to filter profiles by cdn
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/cda457a9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/cda457a9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/cda457a9 Branch: refs/heads/master Commit: cda457a9bf211616aad04db6f2c6219989fb38fb Parents: 84a0cd3 Author: Jeremy Mitchell <mitchell...@gmail.com> Authored: Wed Mar 22 21:30:59 2017 -0600 Committer: Dewayne Richardson <dewr...@apache.org> Committed: Fri Mar 31 09:46:40 2017 -0600 ---------------------------------------------------------------------- docs/source/development/traffic_ops_api/v12/profile.rst | 2 ++ traffic_ops/app/lib/API/Profile.pm | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/cda457a9/docs/source/development/traffic_ops_api/v12/profile.rst ---------------------------------------------------------------------- diff --git a/docs/source/development/traffic_ops_api/v12/profile.rst b/docs/source/development/traffic_ops_api/v12/profile.rst index 546222b..72e3583 100644 --- a/docs/source/development/traffic_ops_api/v12/profile.rst +++ b/docs/source/development/traffic_ops_api/v12/profile.rst @@ -37,6 +37,8 @@ Profiles +===============+==========+====================================================+ | ``param`` | no | Used to filter profiles by parameter ID. | +---------------+----------+----------------------------------------------------+ + | ``cdn`` | no | Used to filter profiles by CDN ID. | + +---------------+----------+----------------------------------------------------+ **Response Properties** http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/cda457a9/traffic_ops/app/lib/API/Profile.pm ---------------------------------------------------------------------- diff --git a/traffic_ops/app/lib/API/Profile.pm b/traffic_ops/app/lib/API/Profile.pm index 8a0793e..6b8831f 100644 --- a/traffic_ops/app/lib/API/Profile.pm +++ b/traffic_ops/app/lib/API/Profile.pm @@ -25,9 +25,12 @@ use JSON; sub index { my $self = shift; - my @data; my $orderby = $self->param('orderby') || "me.name"; my $parameter_id = $self->param('param'); + my $cdn_id = $self->param('cdn'); + + my @data; + my %criteria; if ( defined $parameter_id ) { my $rs = $self->db->resultset('ProfileParameter')->search( { parameter => $parameter_id }, { prefetch => [ 'profile' ] } ); @@ -45,7 +48,10 @@ sub index { ); } } else { - my $rs_data = $self->db->resultset("Profile")->search( undef, { order_by => $orderby } ); + if ( defined $cdn_id ) { + $criteria{'cdn'} = $cdn_id; + } + my $rs_data = $self->db->resultset("Profile")->search( \%criteria, { order_by => $orderby } ); while ( my $row = $rs_data->next ) { push( @data, {