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 2016/11/07 19:00:32 UTC
[1/2] incubator-trafficcontrol git commit: removes changes applied to
specific api endpoints that made the response nested or hierarchical.
Repository: incubator-trafficcontrol
Updated Branches:
refs/heads/master bc8007f61 -> e011a3438
removes changes applied to specific api endpoints that made the response nested or hierarchical.
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/4fefb881
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/4fefb881
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/4fefb881
Branch: refs/heads/master
Commit: 4fefb88194d43d37e11d88cfbfdc95b33067fc2c
Parents: bc8007f
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Mon Nov 7 11:45:53 2016 -0700
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Nov 7 11:45:53 2016 -0700
----------------------------------------------------------------------
traffic_ops/app/lib/API/Asn.pm | 28 +++--
traffic_ops/app/lib/API/Cachegroup.pm | 112 ++++++++++--------
traffic_ops/app/lib/API/Deliveryservice.pm | 78 ++++++-------
traffic_ops/app/lib/API/PhysLocation.pm | 32 +++---
traffic_ops/app/lib/API/Region.pm | 50 ++++----
traffic_ops/app/lib/API/Server.pm | 146 ++++++++++++------------
traffic_ops/app/lib/API/User.pm | 17 ++-
traffic_ops/app/t/api/1.1/cachegroup.t | 4 +-
traffic_ops/app/t/api/1.1/server.t | 32 +++---
traffic_ops/app/t/api/1.2/asn.t | 6 +-
traffic_ops/app/t/api/1.2/region.t | 2 +-
traffic_ops/app/t/api/1.2/server.t | 6 +-
12 files changed, 256 insertions(+), 257 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/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 958ebf9..080099a 100644
--- a/traffic_ops/app/lib/API/Asn.pm
+++ b/traffic_ops/app/lib/API/Asn.pm
@@ -29,12 +29,12 @@ sub index {
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 ) {
- my $cachegroup = { "id" => $row->cachegroup->id, "name" => $row->cachegroup->name };
push(
@data, {
"id" => $row->id,
"asn" => $row->asn,
- "cachegroup" => $cachegroup,
+ "cachegroupId" => $row->cachegroup->id,
+ "cachegroup" => $row->cachegroup->name,
"lastUpdated" => $row->last_updated
}
);
@@ -50,12 +50,12 @@ sub show {
my $rs_data = $self->db->resultset("Asn")->search( { 'me.id' => $id }, { prefetch => ['cachegroup'] } );
my @data = ();
while ( my $row = $rs_data->next ) {
- my $cachegroup = { "id" => $row->cachegroup->id, "name" => $row->cachegroup->name };
push(
@data, {
"id" => $row->id,
"asn" => $row->asn,
- "cachegroup" => $cachegroup,
+ "cachegroupId" => $row->cachegroup->id,
+ "cachegroup" => $row->cachegroup->name,
"lastUpdated" => $row->last_updated
}
);
@@ -85,23 +85,22 @@ sub update {
return $self->alert("ASN is required.");
}
- if ( !defined( $params->{cachegroup} ) ) {
+ if ( !defined( $params->{cachegroupId} ) ) {
return $self->alert("Cachegroup is required.");
}
my $values = {
asn => $params->{asn},
- cachegroup => $params->{cachegroup}->{id}
+ cachegroup => $params->{cachegroupId}
};
my $rs = $asn->update($values);
if ( $rs ) {
my $response;
- my $cachegroup = { "id" => $rs->cachegroup->id, "name" => $rs->cachegroup->name };
-
$response->{id} = $rs->id;
$response->{asn} = $rs->asn;
- $response->{cachegroup} = $cachegroup;
+ $response->{cachegroupId} = $rs->cachegroup->id;
+ $response->{cachegroup} = $rs->cachegroup->name;
$response->{lastUpdated} = $rs->last_updated;
&log( $self, "Updated ASN name '" . $rs->asn . "' for id: " . $rs->id, "APICHANGE" );
return $self->success( $response, "ASN update was successful." );
@@ -124,24 +123,23 @@ sub create {
return $self->alert("ASN is required.");
}
- if ( !defined($params->{cachegroup}) ) {
- return $self->alert("Cachegroup is required.");
+ if ( !defined($params->{cachegroupId}) ) {
+ return $self->alert("Cachegroup Id is required.");
}
my $values = {
asn => $params->{asn} ,
- cachegroup => $params->{cachegroup}->{id}
+ cachegroup => $params->{cachegroupId}
};
my $insert = $self->db->resultset('Asn')->create($values);
my $rs = $insert->insert();
if ($rs) {
my $response;
- my $cachegroup = { "id" => $rs->cachegroup->id, "name" => $rs->cachegroup->name };
-
$response->{id} = $rs->id;
$response->{asn} = $rs->asn;
- $response->{cachegroup} = $cachegroup;
+ $response->{cachegroupId} = $rs->cachegroup->id;
+ $response->{cachegroup} = $rs->cachegroup->name;
$response->{lastUpdated} = $rs->last_updated;
&log( $self, "Created ASN name '" . $rs->asn . "' for id: " . $rs->id, "APICHANGE" );
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/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 4a9db04..7066b6c 100644
--- a/traffic_ops/app/lib/API/Cachegroup.pm
+++ b/traffic_ops/app/lib/API/Cachegroup.pm
@@ -41,9 +41,6 @@ sub index {
my $rs_data = $self->db->resultset("Cachegroup")->search( undef, { prefetch => [ { 'type' => undef, } ], order_by => 'me.' . $orderby } );
while ( my $row = $rs_data->next ) {
- my $parent_cachegroup = ( defined $row->parent_cachegroup_id ) ? { "id" => $row->parent_cachegroup_id, "name" => $idnames{ $row->parent_cachegroup_id } } : undef;
- my $secondary_parent_cachegroup = ( defined $row->secondary_parent_cachegroup_id ) ? { "id" => $row->secondary_parent_cachegroup_id, "name" => $idnames{ $row->secondary_parent_cachegroup_id } } : undef;
- my $type = { "id" => $row->type->id, "name" => $row->type->name };
push(
@data, {
"id" => $row->id,
@@ -52,9 +49,14 @@ sub index {
"latitude" => $row->latitude,
"longitude" => $row->longitude,
"lastUpdated" => $row->last_updated,
- "parentCachegroup" => $parent_cachegroup,
- "secondaryParentCachegroup" => $secondary_parent_cachegroup,
- "type" => $type
+ "parentCachegroupId" => $row->parent_cachegroup_id,
+ "parentCachegroupName" => ( defined $row->parent_cachegroup_id ) ? $idnames{ $row->parent_cachegroup_id } : undef,
+ "secondaryParentCachegroupId" => $row->secondary_parent_cachegroup_id,
+ "secondaryParentCachegroupName" => ( defined $row->secondary_parent_cachegroup_id )
+ ? $idnames{ $row->secondary_parent_cachegroup_id }
+ : undef,
+ "typeId" => $row->type->id,
+ "typeName" => $row->type->name
}
);
}
@@ -92,9 +94,6 @@ sub show {
}
while ( my $row = $rs_data->next ) {
- my $parent_cachegroup = ( defined $row->parent_cachegroup_id ) ? { "id" => $row->parent_cachegroup_id, "name" => $idnames{ $row->parent_cachegroup_id } } : undef;
- my $secondary_parent_cachegroup = ( defined $row->secondary_parent_cachegroup_id ) ? { "id" => $row->secondary_parent_cachegroup_id, "name" => $idnames{ $row->secondary_parent_cachegroup_id } } : undef;
- my $type = { "id" => $row->type->id, "name" => $row->type->name };
push(
@data, {
"id" => $row->id,
@@ -103,9 +102,14 @@ sub show {
"latitude" => $row->latitude,
"longitude" => $row->longitude,
"lastUpdated" => $row->last_updated,
- "parentCachegroup" => $parent_cachegroup,
- "secondaryParentCachegroup" => $secondary_parent_cachegroup,
- "type" => $type
+ "parentCachegroupId" => $row->parent_cachegroup_id,
+ "parentCachegroupName" => ( defined $row->parent_cachegroup_id ) ? $idnames{ $row->parent_cachegroup_id } : undef,
+ "secondaryParentCachegroupId" => $row->secondary_parent_cachegroup_id,
+ "secondaryParentCachegroupName" => ( defined $row->secondary_parent_cachegroup_id )
+ ? $idnames{ $row->secondary_parent_cachegroup_id }
+ : undef,
+ "typeId" => $row->type->id,
+ "typeName" => $row->type->name
}
);
}
@@ -153,9 +157,9 @@ sub update {
short_name => $params->{shortName},
latitude => $params->{latitude},
longitude => $params->{longitude},
- parent_cachegroup_id => ( defined $params->{parentCachegroup} ) ? $params->{parentCachegroup}->{id} : undef,
- secondary_parent_cachegroup_id => ( defined $params->{secondaryParentCachegroup} ) ? $params->{secondaryParentCachegroup}->{id} : undef,
- type => $params->{type}->{id}
+ parent_cachegroup_id => $params->{parentCachegroupId},
+ secondary_parent_cachegroup_id => $params->{secondaryParentCachegroupId},
+ type => $params->{typeId}
};
my $rs = $cachegroup->update($values);
@@ -168,19 +172,24 @@ sub update {
$idnames{ $row->id } = $row->name;
}
- my $parent_cachegroup = ( defined $rs->parent_cachegroup_id ) ? { "id" => $rs->parent_cachegroup_id, "name" => $idnames{ $rs->parent_cachegroup_id } } : undef;
- my $secondary_parent_cachegroup = ( defined $rs->secondary_parent_cachegroup_id ) ? { "id" => $rs->secondary_parent_cachegroup_id, "name" => $idnames{ $rs->secondary_parent_cachegroup_id } } : undef;
- my $type = { "id" => $rs->type->id, "name" => $rs->type->name };
-
- $response->{id} = $rs->id;
- $response->{name} = $rs->name;
- $response->{shortName} = $rs->short_name;
- $response->{latitude} = $rs->latitude;
- $response->{longitude} = $rs->longitude;
- $response->{lastUpdated} = $rs->last_updated;
- $response->{parentCachegroup} = $parent_cachegroup;
- $response->{secondaryParentCachegroup} = $secondary_parent_cachegroup;
- $response->{type} = $type;
+ $response->{id} = $rs->id;
+ $response->{name} = $rs->name;
+ $response->{shortName} = $rs->short_name;
+ $response->{latitude} = $rs->latitude;
+ $response->{longitude} = $rs->longitude;
+ $response->{lastUpdated} = $rs->last_updated;
+ $response->{parentCachegroupId} = $rs->parent_cachegroup_id;
+ $response->{parentCachegroupName} =
+ ( defined $rs->parent_cachegroup_id )
+ ? $idnames{ $rs->parent_cachegroup_id }
+ : undef;
+ $response->{secondaryParentCachegroupId} = $rs->secondary_parent_cachegroup_id;
+ $response->{secondaryParentCachegroupName} =
+ ( defined $rs->secondary_parent_cachegroup_id )
+ ? $idnames{ $rs->secondary_parent_cachegroup_id }
+ : undef;
+ $response->{typeId} = $rs->type->id;
+ $response->{typeName} = $rs->type->name;
&log( $self, "Updated Cachegroup name '" . $rs->name . "' for id: " . $rs->id, "APICHANGE" );
@@ -223,9 +232,9 @@ sub create {
short_name => $params->{shortName},
latitude => $params->{latitude},
longitude => $params->{longitude},
- parent_cachegroup_id => ( defined $params->{parentCachegroup} ) ? $params->{parentCachegroup}->{id} : undef,
- secondary_parent_cachegroup_id => ( defined $params->{secondaryParentCachegroup} ) ? $params->{secondaryParentCachegroup}->{id} : undef,
- type => $params->{type}->{id}
+ parent_cachegroup_id => $params->{parentCachegroupId},
+ secondary_parent_cachegroup_id => $params->{secondaryParentCachegroupId},
+ type => $params->{typeId}
};
my $insert = $self->db->resultset('Cachegroup')->create($values);
@@ -239,19 +248,24 @@ sub create {
$idnames{ $row->id } = $row->name;
}
- my $parent_cachegroup = ( defined $rs->parent_cachegroup_id ) ? { "id" => $rs->parent_cachegroup_id, "name" => $idnames{ $rs->parent_cachegroup_id } } : undef;
- my $secondary_parent_cachegroup = ( defined $rs->secondary_parent_cachegroup_id ) ? { "id" => $rs->secondary_parent_cachegroup_id, "name" => $idnames{ $rs->secondary_parent_cachegroup_id } } : undef;
- my $type = { "id" => $rs->type->id, "name" => $rs->type->name };
-
- $response->{id} = $rs->id;
- $response->{name} = $rs->name;
- $response->{shortName} = $rs->short_name;
- $response->{latitude} = $rs->latitude;
- $response->{longitude} = $rs->longitude;
- $response->{lastUpdated} = $rs->last_updated;
- $response->{parentCachegroup} = $parent_cachegroup;
- $response->{secondaryParentCachegroup} = $secondary_parent_cachegroup;
- $response->{type} = $type;
+ $response->{id} = $rs->id;
+ $response->{name} = $rs->name;
+ $response->{shortName} = $rs->short_name;
+ $response->{latitude} = $rs->latitude;
+ $response->{longitude} = $rs->longitude;
+ $response->{lastUpdated} = $rs->last_updated;
+ $response->{parentCachegroupId} = $rs->parent_cachegroup_id;
+ $response->{parentCachegroupName} =
+ ( defined $rs->parent_cachegroup_id )
+ ? $idnames{ $rs->parent_cachegroup_id }
+ : undef;
+ $response->{secondaryParentCachegroupId} = $rs->secondary_parent_cachegroup_id;
+ $response->{secondaryParentCachegroupName} =
+ ( defined $rs->secondary_parent_cachegroup_id )
+ ? $idnames{ $rs->secondary_parent_cachegroup_id }
+ : undef;
+ $response->{typeId} = $rs->type->id;
+ $response->{typeName} = $rs->type->name;
&log( $self, "Updated Cachegroup name '" . $rs->name . "' for id: " . $rs->id, "APICHANGE" );
@@ -285,7 +299,7 @@ sub delete {
if ( defined($parent_cgs) ) {
return $self->alert("This cachegroup is currently used as a parent cachegroup.");
}
-
+
my $secondary_parent_cgs = $self->db->resultset('Cachegroup')->find( { secondary_parent_cachegroup_id => $cg->id } );
if ( defined($secondary_parent_cgs) ) {
return $self->alert("This cachegroup is currently used as a secondary parent cachegroup.");
@@ -295,7 +309,7 @@ sub delete {
if ( defined($asns) ) {
return $self->alert("This cachegroup is currently used by one or more ASNs.");
}
-
+
my $rs = $cg->delete();
if ($rs) {
return $self->success_message("Cachegroup deleted.");
@@ -429,18 +443,18 @@ sub is_cachegroup_valid {
my $self = shift;
my $params = shift;
- if (!$self->is_valid_cachegroup_type($params->{type}->{id})) {
+ if (!$self->is_valid_cachegroup_type($params->{typeId})) {
return ( 0, "Invalid cachegroup type" );
}
my $rules = {
- fields => [ qw/name shortName latitude longitude parentCachegroup secondaryParentCachegroup type/ ],
+ fields => [ qw/name shortName latitude longitude parentCachegroupId secondaryParentCachegroupId typeId/ ],
# Validation checks to perform
checks => [
name => [ is_required("is required"), \&is_alphanumeric ],
shortName => [ is_required("is required"), \&is_alphanumeric ],
- type => [ is_required("is required") ],
+ typeId => [ is_required("is required") ],
latitude => [ \&is_valid_lat ],
longitude => [ \&is_valid_long ]
]
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/traffic_ops/app/lib/API/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm b/traffic_ops/app/lib/API/Deliveryservice.pm
index 143ea71..27ee53c 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -53,16 +53,13 @@ sub index {
my $regexp_set = &UI::DeliveryService::get_regexp_set( $self, $row->id );
my @example_urls = &UI::DeliveryService::get_example_urls( $self, $row->id, $regexp_set, $row, $cdn_domain, $row->protocol );
- my $cdn = { "id" => $row->cdn->id, "name" => $row->cdn->name };
- my $profile = { "id" => $row->profile->id, "name" => $row->profile->name };
- my $type = { "id" => $row->type->id, "name" => $row->type->name };
-
push(
@data, {
"active" => \$row->active,
"cacheurl" => $row->cacheurl,
"ccrDnsTtl" => $row->ccr_dns_ttl,
- "cdn" => $cdn,
+ "cdnId" => $row->cdn->id,
+ "cdnName" => $row->cdn->name,
"checkPath" => $row->check_path,
"displayName" => $row->display_name,
"dnsBypassCname" => $row->dns_bypass_cname,
@@ -96,7 +93,9 @@ sub index {
"multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
"orgServerFqdn" => $row->org_server_fqdn,
"originShield" => $row->origin_shield,
- "profile" => $profile,
+ "profileId" => $row->profile->id,
+ "profileName" => $row->profile->name,
+ "profileDescription" => $row->profile->description,
"protocol" => $row->protocol,
"qstringIgnore" => $row->qstring_ignore,
"rangeRequestHandling" => $row->range_request_handling,
@@ -107,7 +106,8 @@ sub index {
"sslKeyVersion" => $row->ssl_key_version,
"trRequestHeaders" => $row->tr_request_headers,
"trResponseHeaders" => $row->tr_response_headers,
- "type" => $type,
+ "type" => $row->type->name,
+ "typeId" => $row->type->id,
"xmlId" => $row->xml_id
}
);
@@ -149,16 +149,13 @@ sub show {
my $regexp_set = &UI::DeliveryService::get_regexp_set( $self, $row->id );
my @example_urls = &UI::DeliveryService::get_example_urls( $self, $row->id, $regexp_set, $row, $cdn_domain, $row->protocol );
- my $cdn = { "id" => $row->cdn->id, "name" => $row->cdn->name };
- my $profile = { "id" => $row->profile->id, "name" => $row->profile->name };
- my $type = { "id" => $row->type->id, "name" => $row->type->name };
-
push(
@data, {
"active" => \$row->active,
"cacheurl" => $row->cacheurl,
"ccrDnsTtl" => $row->ccr_dns_ttl,
- "cdn" => $cdn,
+ "cdnId" => $row->cdn->id,
+ "cdnName" => $row->cdn->name,
"checkPath" => $row->check_path,
"displayName" => $row->display_name,
"dnsBypassCname" => $row->dns_bypass_cname,
@@ -193,7 +190,9 @@ sub show {
"multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
"orgServerFqdn" => $row->org_server_fqdn,
"originShield" => $row->origin_shield,
- "profile" => $profile,
+ "profileId" => $row->profile->id,
+ "profileName" => $row->profile->name,
+ "profileDescription" => $row->profile->description,
"protocol" => $row->protocol,
"qstringIgnore" => $row->qstring_ignore,
"rangeRequestHandling" => $row->range_request_handling,
@@ -204,7 +203,8 @@ sub show {
"sslKeyVersion" => $row->ssl_key_version,
"trRequestHeaders" => $row->tr_request_headers,
"trResponseHeaders" => $row->tr_response_headers,
- "type" => $type,
+ "type" => $row->type->name,
+ "typeId" => $row->type->id,
"xmlId" => $row->xml_id
}
);
@@ -244,7 +244,7 @@ sub update {
active => $params->{active} ? 1 : 0,
cacheurl => $params->{cacheurl},
ccr_dns_ttl => $params->{ccrDnsTtl},
- cdn_id => $params->{cdn}->{id},
+ cdn_id => $params->{cdnId},
check_path => $params->{checkPath},
display_name => $params->{displayName},
dns_bypass_cname => $params->{dnsBypassCname},
@@ -275,7 +275,7 @@ sub update {
multi_site_origin_algorithm => $params->{multiSiteOriginAlgorithm},
org_server_fqdn => $params->{orgServerFqdn},
origin_shield => $params->{originShield},
- profile => $params->{profile}->{id},
+ profile => $params->{profileId},
protocol => $params->{protocol},
qstring_ignore => $params->{qstringIgnore},
range_request_handling => $params->{rangeRequestHandling},
@@ -286,23 +286,20 @@ sub update {
ssl_key_version => $params->{sslKeyVersion},
tr_request_headers => $params->{trRequestHeaders},
tr_response_headers => $params->{trResponseHeaders},
- type => $params->{type}->{id},
+ type => $params->{typeId},
xml_id => $params->{xmlId}
};
my $rs = $ds->update($values);
if ($rs) {
my @response;
- my $cdn = { "id" => $rs->cdn->id, "name" => $rs->cdn->name };
- my $profile = { "id" => $rs->profile->id, "name" => $rs->profile->name };
- my $type = { "id" => $rs->type->id, "name" => $rs->type->name };
-
push(
@response, {
"active" => \$rs->active,
"cacheurl" => $rs->cacheurl,
"ccrDnsTtl" => $rs->ccr_dns_ttl,
- "cdn" => $cdn,
+ "cdnId" => $rs->cdn->id,
+ "cdnName" => $rs->cdn->name,
"checkPath" => $rs->check_path,
"displayName" => $rs->display_name,
"dnsBypassCname" => $rs->dns_bypass_cname,
@@ -335,7 +332,9 @@ sub update {
"multiSiteOriginAlgorithm" => $rs->multi_site_origin_algorithm,
"orgServerFqdn" => $rs->org_server_fqdn,
"originShield" => $rs->origin_shield,
- "profile" => $profile,
+ "profileId" => $rs->profile->id,
+ "profileName" => $rs->profile->name,
+ "profileDescription" => $rs->profile->description,
"protocol" => $rs->protocol,
"qstringIgnore" => $rs->qstring_ignore,
"rangeRequestHandling" => $rs->range_request_handling,
@@ -346,7 +345,8 @@ sub update {
"sslKeyVersion" => $rs->ssl_key_version,
"trRequestHeaders" => $rs->tr_request_headers,
"trResponseHeaders" => $rs->tr_response_headers,
- "type" => $type,
+ "type" => $rs->type->name,
+ "typeId" => $rs->type->id,
"xmlId" => $rs->xml_id
}
);
@@ -384,7 +384,7 @@ sub create {
active => $params->{active} ? 1 : 0,
cacheurl => $params->{cacheurl},
ccr_dns_ttl => $params->{ccrDnsTtl},
- cdn_id => $params->{cdn}->{id},
+ cdn_id => $params->{cdnId},
check_path => $params->{checkPath},
display_name => $params->{displayName},
dns_bypass_cname => $params->{dnsBypassCname},
@@ -415,7 +415,7 @@ sub create {
multi_site_origin_algorithm => $params->{multiSiteOriginAlgorithm},
org_server_fqdn => $params->{orgServerFqdn},
origin_shield => $params->{originShield},
- profile => $params->{profile}->{id},
+ profile => $params->{profileId},
protocol => $params->{protocol},
qstring_ignore => $params->{qstringIgnore},
range_request_handling => $params->{rangeRequestHandling},
@@ -426,7 +426,7 @@ sub create {
ssl_key_version => $params->{sslKeyVersion},
tr_request_headers => $params->{trRequestHeaders},
tr_response_headers => $params->{trResponseHeaders},
- type => $params->{type}->{id},
+ type => $params->{typeId},
xml_id => $params->{xmlId}
};
@@ -434,16 +434,13 @@ sub create {
my $rs = $insert->insert();
if ($rs) {
my @response;
- my $cdn = { "id" => $rs->cdn->id, "name" => $rs->cdn->name };
- my $profile = { "id" => $rs->profile->id, "name" => $rs->profile->name };
- my $type = { "id" => $rs->type->id, "name" => $rs->type->name };
-
push(
@response, {
"active" => \$rs->active,
"cacheurl" => $rs->cacheurl,
"ccrDnsTtl" => $rs->ccr_dns_ttl,
- "cdn" => $cdn,
+ "cdnId" => $rs->cdn->id,
+ "cdnName" => $rs->cdn->name,
"checkPath" => $rs->check_path,
"displayName" => $rs->display_name,
"dnsBypassCname" => $rs->dns_bypass_cname,
@@ -476,7 +473,9 @@ sub create {
"multiSiteOriginAlgorithm" => $rs->multi_site_origin_algorithm,
"orgServerFqdn" => $rs->org_server_fqdn,
"originShield" => $rs->origin_shield,
- "profile" => $profile,
+ "profileId" => $rs->profile->id,
+ "profileName" => $rs->profile->name,
+ "profileDescription" => $rs->profile->description,
"protocol" => $rs->protocol,
"qstringIgnore" => $rs->qstring_ignore,
"rangeRequestHandling" => $rs->range_request_handling,
@@ -487,7 +486,8 @@ sub create {
"sslKeyVersion" => $rs->ssl_key_version,
"trRequestHeaders" => $rs->tr_request_headers,
"trResponseHeaders" => $rs->tr_response_headers,
- "type" => $type,
+ "type" => $rs->type->name,
+ "typeId" => $rs->type->id,
"xmlId" => $rs->xml_id
}
);
@@ -755,19 +755,19 @@ sub is_deliveryservice_valid {
my $self = shift;
my $params = shift;
- if ( !$self->is_valid_deliveryservice_type( $params->{type}->{id} ) ) {
+ if ( !$self->is_valid_deliveryservice_type( $params->{typeId} ) ) {
return ( 0, "Invalid deliveryservice type" );
}
my $rules = {
fields => [
- qw/active cacheurl ccrDnsTtl cdn checkPath displayName dnsBypassCname dnsBypassIp dnsBypassIp6 dnsBypassTtl dscp edgeHeaderRewrite geoLimitRedirectURL geoLimit geoLimitCountries geoProvider globalMaxMbps globalMaxTps httpBypassFqdn infoUrl initialDispersion ipv6RoutingEnabled logsEnabled longDesc longDesc1 longDesc2 maxDnsAnswers midHeaderRewrite missLat missLong multiSiteOrigin multiSiteOriginAlgorithm orgServerFqdn originShield profile protocol qstringIgnore rangeRequestHandling regexRemap regionalGeoBlocking remapText signed sslKeyVersion trRequestHeaders trResponseHeaders type xmlId/
+ qw/active cacheurl ccrDnsTtl cdnId checkPath displayName dnsBypassCname dnsBypassIp dnsBypassIp6 dnsBypassTtl dscp edgeHeaderRewrite geoLimitRedirectURL geoLimit geoLimitCountries geoProvider globalMaxMbps globalMaxTps httpBypassFqdn infoUrl initialDispersion ipv6RoutingEnabled logsEnabled longDesc longDesc1 longDesc2 maxDnsAnswers midHeaderRewrite missLat missLong multiSiteOrigin multiSiteOriginAlgorithm orgServerFqdn originShield profileId protocol qstringIgnore rangeRequestHandling regexRemap regionalGeoBlocking remapText signed sslKeyVersion trRequestHeaders trResponseHeaders typeId xmlId/
],
# Validation checks to perform
checks => [
active => [ is_required("is required") ],
- cdn => [ is_required("is required") ],
+ cdnId => [ is_required("is required") ],
displayName => [ is_required("is required"), is_long_at_most( 48, 'too long' ) ],
dscp => [ is_required("is required") ],
geoLimit => [ is_required("is required") ],
@@ -779,13 +779,13 @@ sub is_deliveryservice_valid {
missLong => [ \&is_valid_long ],
multiSiteOrigin => [ is_required("is required") ],
orgServerFqdn => [ is_required("is required"), is_like( qr/^(https?:\/\/)/, "must start with http:// or https://" ) ],
- profile => [ is_required("is required") ],
+ profileId => [ is_required("is required") ],
protocol => [ is_required("is required") ],
qstringIgnore => [ is_required("is required") ],
rangeRequestHandling => [ is_required("is required") ],
regionalGeoBlocking => [ is_required("is required") ],
signed => [ is_required("is required") ],
- type => [ is_required("is required") ],
+ typeId => [ is_required("is required") ],
xmlId => [ is_required("is required"), is_like( qr/^\S*$/, "no spaces" ), is_long_at_most( 48, 'too long' ) ],
]
};
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/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 2b40180..6e2de39 100644
--- a/traffic_ops/app/lib/API/PhysLocation.pm
+++ b/traffic_ops/app/lib/API/PhysLocation.pm
@@ -33,9 +33,7 @@ sub index {
my $rs_data = $self->db->resultset("PhysLocation")->search( undef, { prefetch => ['region'], order_by => 'me.' . $orderby } );
while ( my $row = $rs_data->next ) {
- next if $row->short_name eq 'UNDEF'; # not sure what this is all about
-
- my $region = { "id" => $row->region->id, "name" => $row->region->name };
+ next if $row->short_name eq 'UNDEF';
push(
@data, {
@@ -48,7 +46,8 @@ sub index {
"name" => $row->name,
"phone" => $row->phone,
"poc" => $row->poc,
- "region" => $region,
+ "region" => $row->region->name,
+ "regionId" => $row->region->id,
"shortName" => $row->short_name,
"state" => $row->state,
"zip" => $row->zip
@@ -65,8 +64,6 @@ sub show {
my $rs_data = $self->db->resultset("PhysLocation")->search( { 'me.id' => $id }, { prefetch => ['region'] } );
my @data = ();
while ( my $row = $rs_data->next ) {
- my $region = { "id" => $row->region->id, "name" => $row->region->name };
-
push(
@data, {
"address" => $row->address,
@@ -78,7 +75,8 @@ sub show {
"name" => $row->name,
"phone" => $row->phone,
"poc" => $row->poc,
- "region" => $region,
+ "region" => $row->region->name,
+ "regionId" => $row->region->id,
"shortName" => $row->short_name,
"state" => $row->state,
"zip" => $row->zip
@@ -95,7 +93,7 @@ sub index_trimmed {
my $rs_data = $self->db->resultset("PhysLocation")->search( undef, { prefetch => ['region'], order_by => 'me.' . $orderby } );
while ( my $row = $rs_data->next ) {
- next if $row->short_name eq 'UNDEF'; # not sure what this is all about
+ next if $row->short_name eq 'UNDEF';
push(
@data, {
@@ -150,7 +148,7 @@ sub update {
name => $name,
phone => $params->{phone},
poc => $params->{poc},
- region => $params->{region}->{id},
+ region => $params->{regionId},
short_name => $short_name,
state => $params->{state},
zip => $params->{zip}
@@ -159,8 +157,6 @@ sub update {
my $rs = $phys_location->update($values);
if ($rs) {
my $response;
- my $region = { "id" => $rs->region->id, "name" => $rs->region->name };
-
$response->{address} = $rs->address;
$response->{city} = $rs->city;
$response->{comments} = $rs->comments;
@@ -170,7 +166,8 @@ sub update {
$response->{name} = $rs->name;
$response->{phone} = $rs->phone;
$response->{poc} = $rs->poc;
- $response->{region} = $region;
+ $response->{region} = $rs->region->name;
+ $response->{regionId} = $rs->region->id;
$response->{shortName} = $rs->short_name;
$response->{state} = $rs->state;
$response->{zip} = $rs->zip;
@@ -218,7 +215,7 @@ sub create {
name => $name,
phone => $params->{phone},
poc => $params->{poc},
- region => $params->{region}->{id},
+ region => $params->{regionId},
short_name => $short_name,
state => $params->{state},
zip => $params->{zip}
@@ -228,8 +225,6 @@ sub create {
my $rs = $insert->insert();
if ($rs) {
my $response;
- my $region = { "id" => $rs->region->id, "name" => $rs->region->name };
-
$response->{address} = $rs->address;
$response->{city} = $rs->city;
$response->{comments} = $rs->comments;
@@ -239,7 +234,8 @@ sub create {
$response->{name} = $rs->name;
$response->{phone} = $rs->phone;
$response->{poc} = $rs->poc;
- $response->{region} = $region;
+ $response->{region} = $rs->region->name;
+ $response->{regionId} = $rs->region->id;
$response->{shortName} = $rs->short_name;
$response->{state} = $rs->state;
$response->{zip} = $rs->zip;
@@ -341,13 +337,13 @@ sub is_phys_location_valid {
my $params = shift;
my $rules = {
- fields => [ qw/address city comments email name phone poc region shortName state zip/ ],
+ fields => [ qw/address city comments email name phone poc regionId shortName state zip/ ],
# Validation checks to perform
checks => [
# required fields
- [ qw/address city name region shortName state zip/ ] => is_required("is required")
+ [ qw/address city name regionId shortName state zip/ ] => is_required("is required")
]
};
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/traffic_ops/app/lib/API/Region.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Region.pm b/traffic_ops/app/lib/API/Region.pm
index 69543ab..a871a2b 100644
--- a/traffic_ops/app/lib/API/Region.pm
+++ b/traffic_ops/app/lib/API/Region.pm
@@ -31,14 +31,12 @@ sub index {
my $orderby = $self->param('orderby') || "name";
my $rs_data = $self->db->resultset("Region")->search( undef, { prefetch => ['division'], order_by => 'me.' . $orderby } );
while ( my $row = $rs_data->next ) {
- my $division = { "id" => $row->division->id,
- "name" => $row->division->name
- };
push(
@data, {
"id" => $row->id,
"name" => $row->name,
- "division" => $division,
+ "division" => $row->division->id,
+ "divisionName" => $row->division->name
}
);
}
@@ -52,9 +50,9 @@ sub index_by_name {
my $rs_data = $self->db->resultset("Region")->search( { 'me.name' => $name }, { prefetch => ['division'] } );
my @data = ();
while ( my $row = $rs_data->next ) {
- my $division = { "id" => $row->division->id,
- "name" => $row->division->name
- };
+ my $division = { "id" => $row->division->id,
+ "name" => $row->division->name
+ };
push(
@data, {
"id" => $row->id,
@@ -66,7 +64,6 @@ sub index_by_name {
$self->success( \@data );
}
-
sub show {
my $self = shift;
my $id = $self->param('id');
@@ -74,14 +71,12 @@ sub show {
my $rs_data = $self->db->resultset("Region")->search( { 'me.id' => $id }, { prefetch => ['division'] } );
my @data = ();
while ( my $row = $rs_data->next ) {
- my $division = { "id" => $row->division->id,
- "name" => $row->division->name
- };
push(
@data, {
"id" => $row->id,
"name" => $row->name,
- "division" => $division,
+ "division" => $row->division->id,
+ "divisionName" => $row->division->name
}
);
}
@@ -111,22 +106,22 @@ sub update {
}
if ( !defined( $params->{division} ) ) {
- return $self->alert("Division is required.");
+ return $self->alert("Division Id is required.");
}
my $values = {
name => $params->{name},
- division => $params->{division}->{id}
+ division => $params->{division}
};
my $rs = $region->update($values);
if ($rs) {
my $response;
- $response->{id} = $rs->id;
- $response->{name} = $rs->name;
- $response->{division}{id} = $rs->division->id;
- $response->{division}{name} = $rs->division->name;
- $response->{lastUpdated} = $rs->last_updated;
+ $response->{id} = $rs->id;
+ $response->{name} = $rs->name;
+ $response->{division} = $rs->division->id;
+ $response->{divisionName}= $rs->division->name;
+ $response->{lastUpdated} = $rs->last_updated;
&log( $self, "Updated Region name '" . $rs->name . "' for id: " . $rs->id, "APICHANGE" );
return $self->success( $response, "Region update was successful." );
}
@@ -151,7 +146,7 @@ sub create {
my $division_id = $params->{division};
if ( !defined($division_id) ) {
- return $self->alert("Division is required.");
+ return $self->alert("Division Id is required.");
}
my $existing = $self->db->resultset('Region')->search( { name => $name } )->get_column('name')->single();
@@ -161,7 +156,7 @@ sub create {
my $values = {
name => $params->{name} ,
- division => $params->{division}->{id}
+ division => $params->{division}
};
my $insert = $self->db->resultset('Region')->create($values);
@@ -170,8 +165,8 @@ sub create {
my $response;
$response->{id} = $rs->id;
$response->{name} = $rs->name;
- $response->{division}{id} = $rs->division->id;
- $response->{division}{name} = $rs->division->name;
+ $response->{division} = $rs->division->id;
+ $response->{divisionName} = $rs->division->name;
$response->{lastUpdated} = $rs->last_updated;
&log( $self, "Created Region name '" . $rs->name . "' for id: " . $rs->id, "APICHANGE" );
@@ -216,10 +211,10 @@ sub create_for_division {
my $response;
my $rs = $self->db->resultset('Region')->find( { id => $insert->id } );
if ( defined($rs) ) {
- $response->{id} = $rs->id;
- $response->{name} = $rs->name;
- $response->{division}{id} = $rs->division->id;
- $response->{division}{name} = $division_name;
+ $response->{id} = $rs->id;
+ $response->{name} = $rs->name;
+ $response->{divisionName} = $division_name;
+ $response->{divsionId} = $rs->division->id;
return $self->success($response);
}
return $self->alert( "create region " . $params->{name} . " failed." );
@@ -268,5 +263,4 @@ sub delete_by_name {
}
-
1;
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/traffic_ops/app/lib/API/Server.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Server.pm b/traffic_ops/app/lib/API/Server.pm
index 6877676..c7c7cab 100644
--- a/traffic_ops/app/lib/API/Server.pm
+++ b/traffic_ops/app/lib/API/Server.pm
@@ -60,17 +60,12 @@ sub index {
if ( defined($servers) ) {
my $is_admin = &is_admin($self);
while ( my $row = $servers->next ) {
- my $cachegroup = { "id" => $row->cachegroup->id, "name" => $row->cachegroup->name };
- my $cdn = { "id" => $row->cdn->id, "name" => $row->cdn->name };
- my $physLocation = { "id" => $row->phys_location->id, "name" => $row->phys_location->name };
- my $profile = { "id" => $row->profile->id, "name" => $row->profile->name };
- my $status = { "id" => $row->status->id, "name" => $row->status->name };
- my $type = { "id" => $row->type->id, "name" => $row->type->name };
-
push(
@data, {
- "cachegroup" => $cachegroup,
- "cdn" => $cdn,
+ "cachegroup" => $row->cachegroup->name,
+ "cachegroupId" => $row->cachegroup->id,
+ "cdnId" => $row->cdn->id,
+ "cdnName" => $row->cdn->name,
"domainName" => $row->domain_name,
"guid" => $row->guid,
"hostName" => $row->host_name,
@@ -92,15 +87,20 @@ sub index {
"mgmtIpAddress" => $row->mgmt_ip_address,
"mgmtIpNetmask" => $row->mgmt_ip_netmask,
"mgmtIpGateway" => $row->mgmt_ip_gateway,
- "offlineReason" => $row->offline_reason,
- "physLocation" => $physLocation,
- "profile" => $profile,
+ "offlineReason" => $row->offline_reason,
+ "physLocation" => $row->phys_location->name,
+ "physLocationId" => $row->phys_location->id,
+ "profile" => $row->profile->name,
+ "profileId" => $row->profile->id,
+ "profileDesc" => $row->profile->description,
"rack" => $row->rack,
"routerHostName" => $row->router_host_name,
"routerPortName" => $row->router_port_name,
- "status" => $status,
+ "status" => $row->status->name,
+ "statusId" => $row->status->id,
"tcpPort" => $row->tcp_port,
- "type" => $type,
+ "type" => $row->type->name,
+ "typeId" => $row->type->id,
"updPending" => \$row->upd_pending
}
);
@@ -118,17 +118,12 @@ sub show {
my @data = ();
my $is_admin = &is_admin($self);
while ( my $row = $rs_data->next ) {
- my $cachegroup = { "id" => $row->cachegroup->id, "name" => $row->cachegroup->name };
- my $cdn = { "id" => $row->cdn->id, "name" => $row->cdn->name };
- my $physLocation = { "id" => $row->phys_location->id, "name" => $row->phys_location->name };
- my $profile = { "id" => $row->profile->id, "name" => $row->profile->name };
- my $status = { "id" => $row->status->id, "name" => $row->status->name };
- my $type = { "id" => $row->type->id, "name" => $row->type->name };
-
push(
@data, {
- "cachegroup" => $cachegroup,
- "cdn" => $cdn,
+ "cachegroup" => $row->cachegroup->name,
+ "cachegroupId" => $row->cachegroup->id,
+ "cdnId" => $row->cdn->id,
+ "cdnName" => $row->cdn->name,
"domainName" => $row->domain_name,
"guid" => $row->guid,
"hostName" => $row->host_name,
@@ -151,14 +146,19 @@ sub show {
"mgmtIpNetmask" => $row->mgmt_ip_netmask,
"mgmtIpGateway" => $row->mgmt_ip_gateway,
"offline_reason" => $row->offline_reason,
- "physLocation" => $physLocation,
- "profile" => $profile,
+ "physLocation" => $row->phys_location->name,
+ "physLocationId" => $row->phys_location->id,
+ "profile" => $row->profile->name,
+ "profileId" => $row->profile->id,
+ "profileDesc" => $row->profile->description,
"rack" => $row->rack,
"routerHostName" => $row->router_host_name,
"routerPortName" => $row->router_port_name,
- "status" => $status,
+ "status" => $row->status->name,
+ "statusId" => $row->status->id,
"tcpPort" => $row->tcp_port,
- "type" => $type,
+ "type" => $row->type->name,
+ "typeId" => $row->type->id,
"updPending" => \$row->upd_pending
}
);
@@ -187,8 +187,8 @@ sub update {
}
my $values = {
- cachegroup => $params->{cachegroup}->{id},
- cdn_id => $params->{cdn}->{id},
+ cachegroup => $params->{cachegroupId},
+ cdn_id => $params->{cdnId},
domain_name => $params->{domainName},
host_name => $params->{hostName},
https_port => $params->{httpsPort},
@@ -208,31 +208,26 @@ sub update {
mgmt_ip_netmask => $params->{mgmtIpNetmask},
mgmt_ip_gateway => $params->{mgmtIpGateway},
offline_reason => $params->{offlineReason},
- phys_location => $params->{physLocation}->{id},
- profile => $params->{profile}->{id},
+ phys_location => $params->{physLocationId},
+ profile => $params->{profileId},
rack => $params->{rack},
router_host_name => $params->{routerHostName},
router_port_name => $params->{routerPortName},
- status => $params->{status}->{id},
+ status => $params->{statusId},
tcp_port => $params->{tcpPort},
- type => $params->{type}->{id},
+ type => $params->{typeId},
upd_pending => $params->{updPending}
};
my $rs = $server->update($values);
if ($rs) {
my @response;
- my $cachegroup = { "id" => $rs->cachegroup->id, "name" => $rs->cachegroup->name };
- my $cdn = { "id" => $rs->cdn->id, "name" => $rs->cdn->name };
- my $physLocation = { "id" => $rs->phys_location->id, "name" => $rs->phys_location->name };
- my $profile = { "id" => $rs->profile->id, "name" => $rs->profile->name };
- my $status = { "id" => $rs->status->id, "name" => $rs->status->name };
- my $type = { "id" => $rs->type->id, "name" => $rs->type->name };
-
push(
@response, {
- "cachegroup" => $cachegroup,
- "cdn" => $cdn,
+ "cachegroup" => $rs->cachegroup->name,
+ "cachegroupId" => $rs->cachegroup->id,
+ "cdnId" => $rs->cdn->id,
+ "cdnName" => $rs->cdn->name,
"domainName" => $rs->domain_name,
"guid" => $rs->guid,
"hostName" => $rs->host_name,
@@ -255,14 +250,19 @@ sub update {
"mgmtIpNetmask" => $rs->mgmt_ip_netmask,
"mgmtIpGateway" => $rs->mgmt_ip_gateway,
"offlineReason" => $rs->offline_reason,
- "physLocation" => $physLocation,
- "profile" => $profile,
+ "physLocation" => $rs->phys_location->name,
+ "physLocationId" => $rs->phys_location->id,
+ "profile" => $rs->profile->name,
+ "profileId" => $rs->profile->id,
+ "profileDesc" => $rs->profile->description,
"rack" => $rs->rack,
"routerHostName" => $rs->router_host_name,
"routerPortName" => $rs->router_port_name,
- "status" => $status,
+ "status" => $rs->status->name,
+ "statusId" => $rs->status->id,
"tcpPort" => $rs->tcp_port,
- "type" => $type,
+ "type" => $rs->type->name,
+ "typeId" => $rs->type->id,
"updPending" => \$rs->upd_pending
}
);
@@ -291,8 +291,8 @@ sub create {
}
my $values = {
- cachegroup => $params->{cachegroup}->{id},
- cdn_id => $params->{cdn}->{id},
+ cachegroup => $params->{cachegroupId},
+ cdn_id => $params->{cdnId},
domain_name => $params->{domainName},
host_name => $params->{hostName},
https_port => $params->{httpsPort},
@@ -312,14 +312,14 @@ sub create {
mgmt_ip_netmask => $params->{mgmtIpNetmask},
mgmt_ip_gateway => $params->{mgmtIpGateway},
offline_reason => $params->{offlineReason},
- phys_location => $params->{physLocation}->{id},
- profile => $params->{profile}->{id},
+ phys_location => $params->{physLocationId},
+ profile => $params->{profileId},
rack => $params->{rack},
router_host_name => $params->{routerHostName},
router_port_name => $params->{routerPortName},
- status => $params->{status}->{id},
+ status => $params->{statusId},
tcp_port => $params->{tcpPort},
- type => $params->{type}->{id},
+ type => $params->{typeId},
upd_pending => $params->{updPending}
};
@@ -327,17 +327,12 @@ sub create {
my $rs = $insert->insert();
if ($rs) {
my @response;
- my $cachegroup = { "id" => $rs->cachegroup->id, "name" => $rs->cachegroup->name };
- my $cdn = { "id" => $rs->cdn->id, "name" => $rs->cdn->name };
- my $physLocation = { "id" => $rs->phys_location->id, "name" => $rs->phys_location->name };
- my $profile = { "id" => $rs->profile->id, "name" => $rs->profile->name };
- my $status = { "id" => $rs->status->id, "name" => $rs->status->name };
- my $type = { "id" => $rs->type->id, "name" => $rs->type->name };
-
push(
@response, {
- "cachegroup" => $cachegroup,
- "cdn" => $cdn,
+ "cachegroup" => $rs->cachegroup->name,
+ "cachegroupId" => $rs->cachegroup->id,
+ "cdnId" => $rs->cdn->id,
+ "cdnName" => $rs->cdn->name,
"domainName" => $rs->domain_name,
"guid" => $rs->guid,
"hostName" => $rs->host_name,
@@ -360,14 +355,19 @@ sub create {
"mgmtIpNetmask" => $rs->mgmt_ip_netmask,
"mgmtIpGateway" => $rs->mgmt_ip_gateway,
"offlineReason" => $rs->offline_reason,
- "physLocation" => $physLocation,
- "profile" => $profile,
+ "physLocation" => $rs->phys_location->name,
+ "physLocationId" => $rs->phys_location->id,
+ "profile" => $rs->profile->name,
+ "profileId" => $rs->profile->id,
+ "profileDesc" => $rs->profile->description,
"rack" => $rs->rack,
"routerHostName" => $rs->router_host_name,
"routerPortName" => $rs->router_port_name,
- "status" => $status,
+ "status" => $rs->status->name,
+ "statusId" => $rs->status->id,
"tcpPort" => $rs->tcp_port,
- "type" => $type,
+ "type" => $rs->type->name,
+ "typeId" => $rs->type->id,
"updPending" => \$rs->upd_pending
}
);
@@ -759,17 +759,17 @@ sub is_server_valid {
my $self = shift;
my $params = shift;
- if (!$self->is_valid_server_type($params->{type}->{id})) {
+ if (!$self->is_valid_server_type($params->{typeId})) {
return ( 0, "Invalid server type" );
}
my $rules = {
- fields => [ qw/cachegroup cdn domainName hostName httpsPort iloIpAddress iloIpNetmask iloIpGateway iloUsername iloPassword interfaceMtu interfaceName ip6Address ip6Gateway ipAddress ipNetmask ipGateway mgmtIpAddress mgmtIpNetmask mgmtIpGateway offlineReason physLocation profile rack routerHostName routerPortName status tcpPort type updPending/ ],
+ fields => [ qw/cachegroupId cdnId domainName hostName httpsPort iloIpAddress iloIpNetmask iloIpGateway iloUsername iloPassword interfaceMtu interfaceName ip6Address ip6Gateway ipAddress ipNetmask ipGateway mgmtIpAddress mgmtIpNetmask mgmtIpGateway offlineReason physLocationId profileId rack routerHostName routerPortName statusId tcpPort typeId updPending/ ],
# Validation checks to perform
checks => [
- cachegroup => [ is_required("is required") ],
- cdn => [ is_required("is required") ],
+ cachegroupId => [ is_required("is required") ],
+ cdnId => [ is_required("is required") ],
domainName => [ is_required("is required") ],
hostName => [ is_required("is required") ],
interfaceMtu => [ is_required("is required") ],
@@ -777,10 +777,10 @@ sub is_server_valid {
ipAddress => [ is_required("is required") ],
ipNetmask => [ is_required("is required") ],
ipGateway => [ is_required("is required") ],
- physLocation => [ is_required("is required") ],
- profile => [ is_required("is required") ],
- status => [ is_required("is required") ],
- type => [ is_required("is required") ],
+ physLocationId => [ is_required("is required") ],
+ profileId => [ is_required("is required") ],
+ statusId => [ is_required("is required") ],
+ typeId => [ is_required("is required") ],
updPending => [ is_required("is required") ]
]
};
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/traffic_ops/app/lib/API/User.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/User.pm b/traffic_ops/app/lib/API/User.pm
index 9bb7e8e..fab4b85 100644
--- a/traffic_ops/app/lib/API/User.pm
+++ b/traffic_ops/app/lib/API/User.pm
@@ -76,8 +76,6 @@ sub index {
}
while ( my $row = $dbh->next ) {
- my $role = { "id" => $row->role->id, "name" => $row->role->name };
-
push(
@data, {
"addressLine1" => $row->address_line1,
@@ -95,7 +93,8 @@ sub index {
"postalCode" => $row->postal_code,
"publicSshKey" => $row->public_ssh_key,
"registrationSent"=> \$row->registration_sent,
- "role" => $role,
+ "role" => $row->role->id,
+ "rolename" => $row->role->name,
"stateOrProvince" => $row->state_or_province,
"uid" => $row->uid,
"username" => $row->username
@@ -112,8 +111,6 @@ sub show {
my $rs_data = $self->db->resultset("TmUser")->search( { 'me.id' => $id }, { prefetch => [ 'role' ] } );
my @data = ();
while ( my $row = $rs_data->next ) {
- my $role = { "id" => $row->role->id, "name" => $row->role->name };
-
push(
@data, {
"addressLine1" => $row->address_line1,
@@ -131,7 +128,8 @@ sub show {
"postalCode" => $row->postal_code,
"publicSshKey" => $row->public_ssh_key,
"registrationSent"=> \$row->registration_sent,
- "role" => $role,
+ "role" => $row->role->id,
+ "rolename" => $row->role->name,
"stateOrProvince" => $row->state_or_province,
"uid" => $row->uid,
"username" => $row->username
@@ -174,7 +172,7 @@ sub update {
postal_code => $params->{postalCode},
public_ssh_key => $params->{publicSshKey},
registration_sent => ( $params->{registrationSent} ) ? 1 : 0,
- role => $params->{role}->{id},
+ role => $params->{role},
state_or_province => $params->{stateOrProvince},
username => $params->{username}
};
@@ -189,8 +187,6 @@ sub update {
my $rs = $user->update($values);
if ($rs) {
my $response;
- my $role = { "id" => $rs->role->id, "name" => $rs->role->name };
-
$response->{addressLine1} = $rs->address_line1;
$response->{addressLine2} = $rs->address_line2;
$response->{city} = $rs->city;
@@ -206,7 +202,8 @@ sub update {
$response->{postalCode} = $rs->postal_code;
$response->{publicSshKey} = $rs->public_ssh_key;
$response->{registrationSent} = \$rs->registration_sent;
- $response->{role} = $role;
+ $response->{role} = $rs->role->id;
+ $response->{roleName} = $rs->role->name;
$response->{stateOrProvince} = $rs->state_or_province;
$response->{uid} = $rs->uid;
$response->{username} = $rs->username;
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/traffic_ops/app/t/api/1.1/cachegroup.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/cachegroup.t b/traffic_ops/app/t/api/1.1/cachegroup.t
index 1ccfc7e..8e2e10e 100644
--- a/traffic_ops/app/t/api/1.1/cachegroup.t
+++ b/traffic_ops/app/t/api/1.1/cachegroup.t
@@ -43,12 +43,12 @@ ok $t->post_ok( '/login', => form => { u => Test::TestHelper::PORTAL_USER, p =>
->or( sub { diag $t->tx->res->content->asset->{content}; } );
$t->get_ok("/api/1.1/cachegroups.json?orderby=name")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
- ->json_is( "/response/0/type/name", "EDGE_LOC" );
+ ->json_is( "/response/0/typeName", "EDGE_LOC" );
$t->get_ok("/api/1.1/cachegroups/trimmed.json")->status_is(200)->json_is( "/response/0/name", "edge_atl_group" )
->json_is( "/response/1/name", "edge_cg4" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
$t->get_ok("/api/1.1/cachegroups.json?orderby=name")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
- ->json_is( "/response/0/type/id", "5" );
+ ->json_is( "/response/0/typeId", "5" );
ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
$dbh->disconnect();
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/traffic_ops/app/t/api/1.1/server.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/server.t b/traffic_ops/app/t/api/1.1/server.t
index 47e20ee..7e42166 100644
--- a/traffic_ops/app/t/api/1.1/server.t
+++ b/traffic_ops/app/t/api/1.1/server.t
@@ -39,28 +39,28 @@ ok $t->post_ok( '/login', => form => { u => Test::TestHelper::ADMIN_USER, p => T
->or( sub { diag $t->tx->res->content->asset->{content}; } );
$t->get_ok('/api/1.1/servers.json?orderby=id')->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
- ->json_is( "/response/1/status/name", "ONLINE" )->json_is( "/response/1/ipGateway", "127.0.0.2" )->json_is( "/response/1/ip6Gateway", "2345:1234:12:9::1" )
- ->json_is( "/response/1/tcpPort", "80" )->json_is( "/response/1/cachegroup/name", "mid-northeast-group" )
+ ->json_is( "/response/1/status", "ONLINE" )->json_is( "/response/1/ipGateway", "127.0.0.2" )->json_is( "/response/1/ip6Gateway", "2345:1234:12:9::1" )
+ ->json_is( "/response/1/tcpPort", "80" )->json_is( "/response/1/cachegroup", "mid-northeast-group" )
->json_is( "/response/1/hostName", "atlanta-mid-01" )->json_is( "/response/1/domainName", "ga.atlanta.kabletown.net" )
- ->json_is( "/response/1/ipAddress", "127.0.0.2" )->json_is( "/response/1/profile/name", "MID1" )->json_is( "/response/1/type/name", "MID" )
- ->json_is( "/response/1/physLocation/name", "Denver" )->json_is( "/response/1/interfaceName", "bond0" )->json_is( "/response/1/interfaceMtu", "9000" )
+ ->json_is( "/response/1/ipAddress", "127.0.0.2" )->json_is( "/response/1/profile", "MID1" )->json_is( "/response/1/type", "MID" )
+ ->json_is( "/response/1/physLocation", "Denver" )->json_is( "/response/1/interfaceName", "bond0" )->json_is( "/response/1/interfaceMtu", "9000" )
- ->json_is( "/response/2/status/name", "ONLINE" )->json_is( "/response/2/ipGateway", "127.0.0.4" )->json_is( "/response/2/ip6Gateway", "2345:1234:12:b::1" )
- ->json_is( "/response/2/tcpPort", "81" )->json_is( "/response/2/cachegroup/name", "mid-northeast-group" )->json_is( "/response/2/hostName", "rascal01" )
- ->json_is( "/response/2/domainName", "kabletown.net" )->json_is( "/response/2/ipAddress", "127.0.0.4" )->json_is( "/response/2/profile/name", "RASCAL1" )
- ->json_is( "/response/2/type/name", "RASCAL" )->json_is( "/response/2/physLocation/name", "Denver" )->json_is( "/response/2/interfaceName", "bond0" )
+ ->json_is( "/response/2/status", "ONLINE" )->json_is( "/response/2/ipGateway", "127.0.0.4" )->json_is( "/response/2/ip6Gateway", "2345:1234:12:b::1" )
+ ->json_is( "/response/2/tcpPort", "81" )->json_is( "/response/2/cachegroup", "mid-northeast-group" )->json_is( "/response/2/hostName", "rascal01" )
+ ->json_is( "/response/2/domainName", "kabletown.net" )->json_is( "/response/2/ipAddress", "127.0.0.4" )->json_is( "/response/2/profile", "RASCAL1" )
+ ->json_is( "/response/2/type", "RASCAL" )->json_is( "/response/2/physLocation", "Denver" )->json_is( "/response/2/interfaceName", "bond0" )
->json_is( "/response/2/interfaceMtu", "9000" )
- ->json_is( "/response/4/status/name", "ONLINE" )->json_is( "/response/4/ipGateway", "127.0.0.6" )->json_is( "/response/4/ip6Gateway", "2345:1234:12:c::1" )
- ->json_is( "/response/4/tcpPort", "81" )->json_is( "/response/4/cachegroup/name", "mid-northeast-group" )->json_is( "/response/4/hostName", "rascal02" )
- ->json_is( "/response/4/domainName", "kabletown.net" )->json_is( "/response/4/ipAddress", "127.0.0.6" )->json_is( "/response/4/profile/name", "RASCAL2" )
- ->json_is( "/response/4/type/name", "RASCAL" )->json_is( "/response/4/physLocation/name", "Denver" )->json_is( "/response/4/interfaceName", "bond0" )
+ ->json_is( "/response/4/status", "ONLINE" )->json_is( "/response/4/ipGateway", "127.0.0.6" )->json_is( "/response/4/ip6Gateway", "2345:1234:12:c::1" )
+ ->json_is( "/response/4/tcpPort", "81" )->json_is( "/response/4/cachegroup", "mid-northeast-group" )->json_is( "/response/4/hostName", "rascal02" )
+ ->json_is( "/response/4/domainName", "kabletown.net" )->json_is( "/response/4/ipAddress", "127.0.0.6" )->json_is( "/response/4/profile", "RASCAL2" )
+ ->json_is( "/response/4/type", "RASCAL" )->json_is( "/response/4/physLocation", "Denver" )->json_is( "/response/4/interfaceName", "bond0" )
->json_is( "/response/4/interfaceMtu", "9000" )
- ->json_is( "/response/7/status/name", "ONLINE" )->json_is( "/response/7/ipGateway", "127.0.0.9" )->json_is( "/response/7/ip6Gateway", "2345:1234:12:f::1" )
- ->json_is( "/response/7/tcpPort", "8088" )->json_is( "/response/7/cachegroup/name", "mid-northeast-group" )->json_is( "/response/7/hostName", "riak02" )
- ->json_is( "/response/7/domainName", "kabletown.net" )->json_is( "/response/7/ipAddress", "127.0.0.9" )->json_is( "/response/7/profile/name", "RIAK1" )
- ->json_is( "/response/7/type/name", "RIAK" )->json_is( "/response/7/physLocation/name", "Boulder" )->json_is( "/response/7/interfaceName", "eth1" )
+ ->json_is( "/response/7/status", "ONLINE" )->json_is( "/response/7/ipGateway", "127.0.0.9" )->json_is( "/response/7/ip6Gateway", "2345:1234:12:f::1" )
+ ->json_is( "/response/7/tcpPort", "8088" )->json_is( "/response/7/cachegroup", "mid-northeast-group" )->json_is( "/response/7/hostName", "riak02" )
+ ->json_is( "/response/7/domainName", "kabletown.net" )->json_is( "/response/7/ipAddress", "127.0.0.9" )->json_is( "/response/7/profile", "RIAK1" )
+ ->json_is( "/response/7/type", "RIAK" )->json_is( "/response/7/physLocation", "Boulder" )->json_is( "/response/7/interfaceName", "eth1" )
->json_is( "/response/7/interfaceMtu", "1500" );
$t->get_ok('/api/1.1/servers/hostname/atlanta-edge-01/details.json')->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/traffic_ops/app/t/api/1.2/asn.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/asn.t b/traffic_ops/app/t/api/1.2/asn.t
index 58eac1e..2232a3a 100644
--- a/traffic_ops/app/t/api/1.2/asn.t
+++ b/traffic_ops/app/t/api/1.2/asn.t
@@ -40,15 +40,15 @@ Test::TestHelper->load_core_data($schema);
ok $t->post_ok( '/login', => form => { u => Test::TestHelper::ADMIN_USER, p => Test::TestHelper::ADMIN_USER_PASSWORD } )->status_is(302)
->or( sub { diag $t->tx->res->content->asset->{content}; } );
-$t->get_ok("/api/1.2/asns.json")->status_is(200)->json_is( "/response/0/id", "1" )->json_is( "/response/0/cachegroup/name", "mid-northeast-group" )
+$t->get_ok("/api/1.2/asns.json")->status_is(200)->json_is( "/response/0/id", "1" )->json_is( "/response/0/cachegroup", "mid-northeast-group" )
->json_is( "/response/0/asn", "9939" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
$t->get_ok("/api/1.2/asns.json?orderby=id")->status_is(200)->json_is( "/response/0/id", "1" )
- ->json_is( "/response/0/cachegroup/name", "mid-northeast-group" )->json_is( "/response/0/asn", "9939" )
+ ->json_is( "/response/0/cachegroup", "mid-northeast-group" )->json_is( "/response/0/asn", "9939" )
->or( sub { diag $t->tx->res->content->asset->{content}; } );
$t->get_ok("/api/1.2/asns.json?orderby=cachegroup")->status_is(200)->json_is( "/response/0/id", "1" )
- ->json_is( "/response/0/cachegroup/name", "mid-northeast-group" )->json_is( "/response/0/asn", "9939" )
+ ->json_is( "/response/0/cachegroup", "mid-northeast-group" )->json_is( "/response/0/asn", "9939" )
->or( sub { diag $t->tx->res->content->asset->{content}; } );
ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/traffic_ops/app/t/api/1.2/region.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/region.t b/traffic_ops/app/t/api/1.2/region.t
index e223e33..213168e 100644
--- a/traffic_ops/app/t/api/1.2/region.t
+++ b/traffic_ops/app/t/api/1.2/region.t
@@ -41,7 +41,7 @@ ok $t->post_ok( '/login', => form => { u => Test::TestHelper::ADMIN_USER, p => T
ok $t->post_ok('/api/1.2/divisions/mountain/regions' => {Accept => 'application/json'} => json => {
"name" => "region1"})->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
->json_is( "/response/name" => "region1" )
- ->json_is( "/response/division/name" => "mountain" )
+ ->json_is( "/response/divisionName" => "mountain" )
, 'Does the region details return?';
ok $t->post_ok('/api/1.2/divisions/mountain/regions' => {Accept => 'application/json'} => json => {
"name" => "region1"})->status_is(400);
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4fefb881/traffic_ops/app/t/api/1.2/server.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/server.t b/traffic_ops/app/t/api/1.2/server.t
index 25d330c..60675e1 100644
--- a/traffic_ops/app/t/api/1.2/server.t
+++ b/traffic_ops/app/t/api/1.2/server.t
@@ -53,14 +53,14 @@ ok $t->get_ok('/api/1.2/servers/details.json?orderby=hostName')->status_is(400)-
ok $t->get_ok('/api/1.2/servers?type=MID')->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
->json_is( "/response/0/hostName", "atlanta-mid-01" )
->json_is( "/response/0/domainName", "ga.atlanta.kabletown.net" )
- ->json_is( "/response/0/type/name", "MID" )
+ ->json_is( "/response/0/type", "MID" )
->or( sub { diag $t->tx->res->content->asset->{content}; } );
ok $t->get_ok('/api/1.2/servers?type=MID&status=ONLINE')->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
->json_is( "/response/0/hostName", "atlanta-mid-01" )
->json_is( "/response/0/domainName", "ga.atlanta.kabletown.net" )
- ->json_is( "/response/0/type/name", "MID" )
- ->json_is( "/response/0/status/name", "ONLINE" )
+ ->json_is( "/response/0/type", "MID" )
+ ->json_is( "/response/0/status", "ONLINE" )
->or( sub { diag $t->tx->res->content->asset->{content}; } );
ok $t->post_ok('/api/1.2/servers/create' => {Accept => 'application/json'} => json => {
[2/2] incubator-trafficcontrol git commit: The closes #55
Posted by de...@apache.org.
The closes #55
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/e011a343
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/e011a343
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/e011a343
Branch: refs/heads/master
Commit: e011a34380ccd55d2d1e29f3e9a09d928c722f2a
Parents: 4fefb88
Author: Dewayne Richardson <de...@apache.org>
Authored: Mon Nov 7 12:00:17 2016 -0700
Committer: Dewayne Richardson <de...@apache.org>
Committed: Mon Nov 7 12:00:17 2016 -0700
----------------------------------------------------------------------
----------------------------------------------------------------------