rawlinp commented on a change in pull request #2029: [Issue 1907] TO API for 
backup edge cachegroup
URL: 
https://github.com/apache/incubator-trafficcontrol/pull/2029#discussion_r191428268
 
 

 ##########
 File path: traffic_ops/app/lib/API/CachegroupFallback.pm
 ##########
 @@ -0,0 +1,287 @@
+package API::CachegroupFallback;
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# a note about locations and cachegroups. This used to be "Location", before 
we had physical locations in 12M. Very confusing.
+# What used to be called a location is now called a "cache group" and location 
is now a physical address, not a group of caches working together.
+#
+
+# JvD Note: you always want to put Utils as the first use. Sh*t don't work if 
it's after the Mojo lines.
+use UI::Utils;
+use Mojo::Base 'Mojolicious::Controller';
+use Data::Dumper;
+use JSON;
+use MojoPlugins::Response;
+use Validate::Tiny ':all';
+
+sub delete {
+       my $self = shift;
+       my $cache_id = $self->param('cacheGroupId');
+       my $fallback_id = $self->param('fallbackId');
+       my $params = $self->req->json;
+       my $rs_backups = undef; 
+
+       if ( !&is_oper($self) ) {
+               return $self->forbidden();
+       }
+
+       if ( defined ($cache_id) && defined($fallback_id) ) {
+               $rs_backups = 
$self->db->resultset('CachegroupFallback')->search( { primary_cg => $cache_id , 
backup_cg => $fallback_id} );
+       } elsif (defined ($cache_id)) {
+               $rs_backups = 
$self->db->resultset('CachegroupFallback')->search( { primary_cg => $cache_id} 
);
+       } elsif (defined ($fallback_id)) {
+               $rs_backups = 
$self->db->resultset('CachegroupFallback')->search( { backup_cg => 
$fallback_id} );
+       }
+
+       if ( ($rs_backups->count > 0) ) {
+               my $del_records = $rs_backups->delete();
+               if ($del_records) {
+                       &log( $self, "Backup configuration DELETED", 
"APICHANGE");
 
 Review comment:
   For 2, I'm ok with leaving as-is in the Perl, but in the Golang API it will 
be wrapped in a transaction so that all or none of the requested backups are 
created/updated. People should not have to double-check our API when getting a 
200 success code.
   
   For 3 let's just keep it nullable for now.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to