You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/01/03 19:28:20 UTC

[10/13] incubator-trafficcontrol git commit: provides the ability to filter cache groups by type

provides the ability to filter cache groups by type


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

Branch: refs/heads/master
Commit: d018a1ebbed992b66abf90cf9c5bcbe1dc039554
Parents: 77096b1
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Fri Dec 30 09:59:26 2016 -0700
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Fri Dec 30 09:59:26 2016 -0700

----------------------------------------------------------------------
 docs/source/development/traffic_ops_api/v12/cachegroup.rst | 8 ++++++++
 traffic_ops/app/lib/API/Cachegroup.pm                      | 8 +++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d018a1eb/docs/source/development/traffic_ops_api/v12/cachegroup.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/cachegroup.rst b/docs/source/development/traffic_ops_api/v12/cachegroup.rst
index 2d9f08d..cc7999a 100644
--- a/docs/source/development/traffic_ops_api/v12/cachegroup.rst
+++ b/docs/source/development/traffic_ops_api/v12/cachegroup.rst
@@ -29,6 +29,14 @@ Cache Group
 
   Role(s) Required: None
 
+  **Request Query Parameters**
+
+  +-----------------+----------+---------------------------------------------------+
+  | Name            | Required | Description                                       |
+  +=================+==========+===================================================+
+  | ``type``        | no       | Filter cache groups by Type ID.                   |
+  +-----------------+----------+---------------------------------------------------+
+
   **Response Properties**
 
   +-----------------------------------+--------+--------------------------------------------------------------------------+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d018a1eb/traffic_ops/app/lib/API/Cachegroup.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Cachegroup.pm b/traffic_ops/app/lib/API/Cachegroup.pm
index 7066b6c..e91a82b 100644
--- a/traffic_ops/app/lib/API/Cachegroup.pm
+++ b/traffic_ops/app/lib/API/Cachegroup.pm
@@ -33,13 +33,19 @@ sub index {
 	my @data;
 	my %idnames;
 	my $orderby = $self->param('orderby') || "name";
+	my $type_id = $self->param('type');
 
 	my $rs_idnames = $self->db->resultset("Cachegroup")->search( undef, { columns => [qw/id name/] } );
 	while ( my $row = $rs_idnames->next ) {
 		$idnames{ $row->id } = $row->name;
 	}
 
-	my $rs_data = $self->db->resultset("Cachegroup")->search( undef, { prefetch => [ { 'type' => undef, } ], order_by => 'me.' . $orderby } );
+	my %criteria;
+	if ( defined $type_id ) {
+		$criteria{'type'} = $type_id;
+	}
+
+	my $rs_data = $self->db->resultset("Cachegroup")->search( \%criteria, { prefetch => [ { 'type' => undef, } ], order_by => 'me.' . $orderby } );
 	while ( my $row = $rs_data->next ) {
 		push(
 			@data, {