You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2017/01/03 17:54:03 UTC
[4/8] incubator-trafficcontrol git commit: adds region filter to
phys_locations
adds region filter to phys_locations
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/179411b1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/179411b1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/179411b1
Branch: refs/heads/master
Commit: 179411b17970bdf2b48ac8be5f4401c83a94efe6
Parents: 9059556
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Wed Dec 28 20:56:43 2016 -0700
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Wed Dec 28 20:56:43 2016 -0700
----------------------------------------------------------------------
.../development/traffic_ops_api/v12/phys_location.rst | 8 ++++++++
traffic_ops/app/lib/API/PhysLocation.pm | 11 +++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/179411b1/docs/source/development/traffic_ops_api/v12/phys_location.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/phys_location.rst b/docs/source/development/traffic_ops_api/v12/phys_location.rst
index b9e6cb6..67359e5 100644
--- a/docs/source/development/traffic_ops_api/v12/phys_location.rst
+++ b/docs/source/development/traffic_ops_api/v12/phys_location.rst
@@ -29,6 +29,14 @@ Physical Location
Role(s) Required: None
+ **Request Query Parameters**
+
+ +--------------+----------+---------------------------------------------+
+ | Name | Required | Description |
+ +==============+==========+=============================================+
+ | ``region`` | no | Filter by Region ID. |
+ +--------------+----------+---------------------------------------------+
+
**Response Properties**
+----------------------+--------+------------------------------------------------+
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/179411b1/traffic_ops/app/lib/API/PhysLocation.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/PhysLocation.pm b/traffic_ops/app/lib/API/PhysLocation.pm
index 6e2de39..ed5d0bb 100644
--- a/traffic_ops/app/lib/API/PhysLocation.pm
+++ b/traffic_ops/app/lib/API/PhysLocation.pm
@@ -27,10 +27,17 @@ use Validate::Tiny ':all';
my $finfo = __FILE__ . ":";
sub index {
- my $self = shift;
+ my $self = shift;
+ my $region = $self->param('region');
+
+ my %criteria;
+ if ( defined $region ) {
+ $criteria{'region.id'} = $region;
+ }
+
my @data;
my $orderby = $self->param('orderby') || "name";
- my $rs_data = $self->db->resultset("PhysLocation")->search( undef, { prefetch => ['region'], order_by => 'me.' . $orderby } );
+ my $rs_data = $self->db->resultset("PhysLocation")->search( \%criteria, { prefetch => ['region'], order_by => 'me.' . $orderby } );
while ( my $row = $rs_data->next ) {
next if $row->short_name eq 'UNDEF';