TT#36007 Remove /api/sipcaptures standard GET method

Change-Id: I6b318df167056486181542460217de3b2b221773
changes/88/21588/21
Irina Peshinskaya 7 years ago
parent 033eb856ee
commit 2431c0efd9

@ -3,12 +3,6 @@ use NGCP::Panel::Utils::Generic qw(:all);
use Sipwise::Base;
use boolean qw(true);
use Data::HAL qw();
use Data::HAL::Link qw();
use HTTP::Headers qw();
use HTTP::Status qw(:constants);
use DateTime::TimeZone;
use NGCP::Panel::Utils::DateTime;
use parent qw/NGCP::Panel::Role::Entities NGCP::Panel::Role::API::SIPCaptures/;
@ -90,53 +84,6 @@ sub query_params {
];
}
sub GET :Allow {
my ($self, $c) = @_;
my $page = $c->request->params->{page} // 1;
my $rows = $c->request->params->{rows} // 10;
{
if($c->req->param('tz') && !DateTime::TimeZone->is_valid_name($c->req->param('tz'))) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Query parameter 'tz' value is not a valid time zone");
return;
}
my $items = $self->item_rs($c);
(my $total_count, $items) = $self->paginate_order_collection($c, $items);
my (@embedded, @links);
my $form = $self->get_form($c);
for my $item ($items->all) {
push @embedded, $self->hal_from_item($c, $item, $form);
push @links, Data::HAL::Link->new(
relation => 'ngcp:'.$self->resource_name,
href => sprintf('/%s%s', $c->request->path, $item->call_id),
);
}
push @links,
Data::HAL::Link->new(
relation => 'curies',
href => 'http://purl.org/sipwise/ngcp-api/#rel-{rel}',
name => 'ngcp',
templated => true,
),
Data::HAL::Link->new(relation => 'profile', href => 'http://purl.org/sipwise/ngcp-api/'),
$self->collection_nav_links($c, $page, $rows, $total_count, $c->request->path, $c->request->query_params);
my $hal = Data::HAL->new(
embedded => [@embedded],
links => [@links],
);
$hal->resource({
total_count => $total_count,
});
my $response = HTTP::Response->new(HTTP_OK, undef,
HTTP::Headers->new($hal->http_headers(skip_links => 1)), $hal->as_json);
$c->response->headers($response->headers);
$c->response->body($response->content);
return;
}
return;
}
1;
# vim: set tabstop=4 expandtab:

@ -26,17 +26,11 @@ sub allowed_methods {
sub GET :Allow {
my ($self, $c, $id) = @_;
{
if($c->req->param('tz') && !DateTime::TimeZone->is_valid_name($c->req->param('tz'))) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Query parameter 'tz' value is not a valid time zone");
return;
}
my $packets = $self->packets_by_callid($c, $id);
unless ($packets) {
$self->error($c, HTTP_NOT_FOUND, "Non-existing call id");
last;
}
my $pcap = NGCP::Panel::Utils::Callflow::generate_pcap($packets);
last unless $pcap;
@ -44,6 +38,7 @@ sub GET :Allow {
my $file_dt = sprintf "%s_%s%s%s",
$dt->ymd, $dt->hour, $dt->minute, $dt->second;
my $filename = sprintf "%s_-%s.pcap", $file_dt, $id;
$c->response->header("Content-Disposition" => "attachment; filename=$filename");
$c->response->content_type('application/vnd.tcpdump.pcap');
$c->response->body($pcap);

@ -10,6 +10,8 @@ use Data::HAL qw();
use Data::HAL::Link qw();
use HTTP::Status qw(:constants);
use DateTime::TimeZone;
sub resource_name {
return 'sipcaptures';
}
@ -106,5 +108,17 @@ sub get_item_id {
return $item->call_id;
}
sub validate_request {
my($self, $c) = @_;
my $method = uc($c->request->method);
if ($method eq 'GET') {
if($c->req->param('tz') && !DateTime::TimeZone->is_valid_name($c->req->param('tz'))) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Query parameter 'tz' value is not a valid time zone");
return;
}
}
return 1;
}
1;
# vim: set tabstop=4 expandtab:

Loading…
Cancel
Save