[GitHub] incubator-trafficcontrol pull request #740: add safe (limited field) update ...
Github user mitchell852 commented on a diff in the pull request: https://github.com/apache/incubator-trafficcontrol/pull/740#discussion_r129148171 --- Diff: docs/source/development/traffic_ops_api/v12/deliveryservice.rst --- @@ -2648,7 +2648,266 @@ SSL Keys } | +**PUT /api/1.2/deliveryservices/{:id}/safe** + Allows a portal user to edit limited fields of an assigned delivery service. + + Authentication Required: Yes + + Role(s) Required: portal or above --- End diff -- can you update this? what's the rule? ops or above or deliveryservice is assigned to the user? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] incubator-trafficcontrol pull request #740: add safe (limited field) update ...
Github user mitchell852 commented on a diff in the pull request: https://github.com/apache/incubator-trafficcontrol/pull/740#discussion_r128634422 --- Diff: traffic_ops/app/lib/API/Deliveryservice.pm --- @@ -442,6 +442,139 @@ sub update { } } +sub safe_update { + my $self = shift; + my $id = $self->param('id'); + my $params = $self->req->json; + + + my $helper = new Utils::Helper( { mojo => $self } ); + + my $ds = $self->db->resultset('Deliveryservice')->find( { id => $id } ); + if ( !defined($ds) ) { + return $self->not_found(); + } + + + if ( _portal($self) && $helper->is_delivery_service_assigned($id) ) { + + my $xml_id = $params->{xmlId}; + if ( $ds->xml_id ne $xml_id ) { + my $existing = $self->db->resultset('Deliveryservice')->find( { xml_id => $xml_id } ); + if ($existing) { + return $self->alert( "A deliveryservice with xmlId " . $xml_id . " already exists." ); + } + } + + my $values = { + display_name => $params->{displayName}, + info_url => $params->{infoUrl}, + long_desc => $params->{longDesc}, + long_desc_1=> $params->{longDesc1}, + long_desc_2=> $params->{longDesc2}, + }; + + my $rs = $ds->update($values); + if ($rs) { + + # create location parameters for header_rewrite*, regex_remap* and cacheurl* config files if necessary + ::DeliveryService::header_rewrite( $self, $rs->id, $params->{profileId}, $params->{xmlId}, $params->{edgeHeaderRewrite}, "edge" ); + ::DeliveryService::header_rewrite( $self, $rs->id, $params->{profileId}, $params->{xmlId}, $params->{midHeaderRewrite}, "mid" ); + ::DeliveryService::regex_remap( $self, $rs->id, $params->{profileId}, $params->{xmlId}, $params->{regexRemap} ); + ::DeliveryService::cacheurl( $self, $rs->id, $params->{profileId}, $params->{xmlId}, $params->{cacheurl} ); + + # build example urls + my @example_urls = (); + my $cdn_domain= $rs->cdn->domain_name; + my $regexp_set = ::DeliveryService::get_regexp_set( $self, $rs->id ); + @example_urls = ::DeliveryService::get_example_urls( $self, $rs->id, $regexp_set, $rs, $cdn_domain, $rs->protocol ); + + # build the matchlist (the list of ds regexes and their type) + my @matchlist = (); + my $ds_regexes = $self->db->resultset('DeliveryserviceRegex')->search( { deliveryservice => $rs->id }, { prefetch => [ { 'regex' => 'type' } ] } ); + while ( my $ds_regex = $ds_regexes->next ) { + push( + @matchlist, { + type => $ds_regex->regex->type->name, + pattern => $ds_regex->regex->pattern, + setNumber => $ds_regex->set_number + } + ); + } + + my @response; + push( + @response, { + "active" => $rs->active, + "cacheurl" => $rs->cacheurl, + "ccrDnsTtl"=> $rs->ccr_dns_ttl, + "cdnId"=> $rs->cdn->id, + "cdnName" => $rs->cdn->name, + "checkPath"=> $rs->check_path, + "displayName" => $rs->display_name, + "dnsBypassCname" => $rs->dns_bypass_cname, + "dnsBypassIp" => $rs->dns_bypass_ip, + "dnsBypassIp6" => $rs->dns_bypass_ip6, + "dnsBypassTtl" => $rs->dns_bypass_ttl, + "dscp" => $rs->dscp, + "edgeHeaderRewrite"=> $rs->edge_header_rewrite, + "exampleURLs" => \@example_urls, +
[GitHub] incubator-trafficcontrol pull request #740: add safe (limited field) update ...
Github user mitchell852 commented on a diff in the pull request: https://github.com/apache/incubator-trafficcontrol/pull/740#discussion_r128633810 --- Diff: traffic_ops/app/lib/API/Deliveryservice.pm --- @@ -442,6 +442,139 @@ sub update { } } +sub safe_update { + my $self = shift; + my $id = $self->param('id'); + my $params = $self->req->json; + + + my $helper = new Utils::Helper( { mojo => $self } ); + + my $ds = $self->db->resultset('Deliveryservice')->find( { id => $id } ); + if ( !defined($ds) ) { + return $self->not_found(); + } + + + if ( _portal($self) && $helper->is_delivery_service_assigned($id) ) { + + my $xml_id = $params->{xmlId}; + if ( $ds->xml_id ne $xml_id ) { + my $existing = $self->db->resultset('Deliveryservice')->find( { xml_id => $xml_id } ); + if ($existing) { + return $self->alert( "A deliveryservice with xmlId " . $xml_id . " already exists." ); + } + } + + my $values = { + display_name => $params->{displayName}, + info_url => $params->{infoUrl}, + long_desc => $params->{longDesc}, + long_desc_1=> $params->{longDesc1}, + long_desc_2=> $params->{longDesc2}, + }; + + my $rs = $ds->update($values); + if ($rs) { + + # create location parameters for header_rewrite*, regex_remap* and cacheurl* config files if necessary --- End diff -- I don't think you need to do lines 481-484, actually you probably shouldn't be because this would imply that i can pass in a new profileId or xmlId and make significant changes to the delivery service when really they can change xmlId and profileId all day long and it "should" have no effect in this route. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] incubator-trafficcontrol pull request #740: add safe (limited field) update ...
Github user mitchell852 commented on a diff in the pull request: https://github.com/apache/incubator-trafficcontrol/pull/740#discussion_r128633945 --- Diff: traffic_ops/app/lib/API/Deliveryservice.pm --- @@ -442,6 +442,139 @@ sub update { } } +sub safe_update { + my $self = shift; + my $id = $self->param('id'); + my $params = $self->req->json; + + + my $helper = new Utils::Helper( { mojo => $self } ); + + my $ds = $self->db->resultset('Deliveryservice')->find( { id => $id } ); + if ( !defined($ds) ) { + return $self->not_found(); + } + + + if ( _portal($self) && $helper->is_delivery_service_assigned($id) ) { + + my $xml_id = $params->{xmlId}; --- End diff -- I don't think you have to do this because xmlId is ignored anyhow, right? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] incubator-trafficcontrol pull request #740: add safe (limited field) update ...
GitHub user DylanVolz opened a pull request: https://github.com/apache/incubator-trafficcontrol/pull/740 add safe (limited field) update endpoint to delivery service crud You can merge this pull request into a Git repository by running: $ git pull https://github.com/DylanVolz/incubator-trafficcontrol safe-self-service Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-trafficcontrol/pull/740.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #740 commit 2c6b737db4d28f99daa0abeb08625a1ae7ff9736 Author: Dylan VolzDate: 2017-07-11T15:23:34Z add safe (limited field) update endpoint to delivery service crud --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---