Repository: incubator-trafficcontrol Updated Branches: refs/heads/master b5d21b764 -> 81bfb561d
adds cachegroup parameters route Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/680a1b72 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/680a1b72 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/680a1b72 Branch: refs/heads/master Commit: 680a1b72c20286e27b91eff63080e5b80e333662 Parents: f0564a9 Author: Jeremy Mitchell <mitchell...@gmail.com> Authored: Wed Dec 28 12:39:44 2016 -0700 Committer: Jeremy Mitchell <mitchell...@gmail.com> Committed: Wed Dec 28 12:39:44 2016 -0700 ---------------------------------------------------------------------- .../traffic_ops_api/v12/cachegroup.rst | 41 ++++++++++++++++++++ traffic_ops/app/lib/API/Parameter.pm | 30 ++++++++++++++ traffic_ops/app/lib/TrafficOpsRoutes.pm | 2 + 3 files changed, 73 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/680a1b72/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..28302dd 100644 --- a/docs/source/development/traffic_ops_api/v12/cachegroup.rst +++ b/docs/source/development/traffic_ops_api/v12/cachegroup.rst @@ -184,6 +184,47 @@ Cache Group | +**GET /api/1.2/cachegroups/:id/parameters** + + Authentication Required: Yes + + Role(s) Required: None + + **Response Properties** + + +-----------------------------------+--------+--------------------------------------------------------------------------+ + | Parameter | Type | Description | + +===================================+========+==========================================================================+ + | ``id`` | int | Local unique identifier for the parameter | + +-----------------------------------+--------+--------------------------------------------------------------------------+ + | ``name`` | string | Name of the parameter | + +-----------------------------------+--------+--------------------------------------------------------------------------+ + | ``value`` | string | Value of the parameter | + +-----------------------------------+--------+--------------------------------------------------------------------------+ + | ``configFile`` | string | Config file associated with the parameter | + +-----------------------------------+--------+--------------------------------------------------------------------------+ + | ``secure`` | bool | Is the parameter value only visible to admin users | + +-----------------------------------+--------+--------------------------------------------------------------------------+ + | ``lastUpdated`` | string | The Time / Date this entry was last updated | + +-----------------------------------+--------+--------------------------------------------------------------------------+ + + **Response Example** :: + + { + "response": [ + { + "id": "1100", + "name": "cgw.originUrl", + "value": "http://to-short.g.foo.net/data/", + "configFile": "foo.config", + "secure": false, + "lastUpdated": "2015-08-27 15:11:49" + }, + { ... } + ] + } + +| **GET /api/1.2/cachegroup/:parameter_id/parameter** http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/680a1b72/traffic_ops/app/lib/API/Parameter.pm ---------------------------------------------------------------------- diff --git a/traffic_ops/app/lib/API/Parameter.pm b/traffic_ops/app/lib/API/Parameter.pm index 218d003..1771038 100644 --- a/traffic_ops/app/lib/API/Parameter.pm +++ b/traffic_ops/app/lib/API/Parameter.pm @@ -81,6 +81,36 @@ sub get_profile_params { $self->success( \@data ); } +sub get_cachegroup_params { + my $self = shift; + my $cg_id = $self->param('id'); + + my %criteria; + if ( defined $cg_id ) { + $criteria{'cachegroup.id'} = $cg_id; + } else { + return $self->alert("Cache Group ID is required"); + } + + my $rs_data = $self->db->resultset("CachegroupParameter")->search( \%criteria, { prefetch => [ 'cachegroup', 'parameter' ] } ); + my @data = (); + while ( my $row = $rs_data->next ) { + my $value = $row->parameter->value; + &UI::Parameter::conceal_secure_parameter_value( $self, $row->parameter->secure, \$value ); + push( + @data, { + "name" => $row->parameter->name, + "id" => $row->parameter->id, + "configFile" => $row->parameter->config_file, + "value" => $value, + "secure" => \$row->parameter->secure, + "lastUpdated" => $row->parameter->last_updated + } + ); + } + $self->success( \@data ); +} + sub create { my $self = shift; my $params = $self->req->json; http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/680a1b72/traffic_ops/app/lib/TrafficOpsRoutes.pm ---------------------------------------------------------------------- diff --git a/traffic_ops/app/lib/TrafficOpsRoutes.pm b/traffic_ops/app/lib/TrafficOpsRoutes.pm index 9d0e546..ae93ac3 100644 --- a/traffic_ops/app/lib/TrafficOpsRoutes.pm +++ b/traffic_ops/app/lib/TrafficOpsRoutes.pm @@ -403,6 +403,8 @@ sub api_routes { $r->put("/api/$version/cachegroups/:id")->over( authenticated => 1 )->to( 'Cachegroup#update', namespace => $namespace ); $r->delete("/api/$version/cachegroups/:id")->over( authenticated => 1 )->to( 'Cachegroup#delete', namespace => $namespace ); + $r->get( "/api/$version/cachegroups/:id/parameters")->over( authenticated => 1 )->to( 'Parameter#get_cachegroup_params', namespace => $namespace ); + # alternate cachegroup routes $r->get("/api/$version/cachegroups/list")->over( authenticated => 1 )->to( 'Cachegroup2#index', namespace => $namespace ); $r->post("/api/$version/cachegroups/create")->over( authenticated => 1 )->to( 'Cachegroup2#create', namespace => $namespace );