MT#22992 journal time range query parameters

+fix journal action method config

Change-Id: I3e72e0928d185a5052ad556597661517920dd6b4
changes/52/8852/3
Rene Krenn 9 years ago
parent ae5e887dc2
commit 7a89ab811d

@ -105,62 +105,62 @@ sub add_journal_item_hal {
sub get_api_journal_action_config { sub get_api_journal_action_config {
my ($path_part,$action_template,$journal_methods) = @_; my ($path_part,$action_template,$journal_methods) = @_;
my %journal_actions_found = map { $_ => 1 } @$journal_methods; my %journal_actions_found = map { $_ => 1 } @$journal_methods;
if (exists $journal_actions_found{'item_base_journal'}) { if (exists $journal_actions_found{'handle_item_base_journal'}) {
my @result = (); my @result = ();
if (exists $journal_actions_found{'journals_get'}) { if (exists $journal_actions_found{'handle_journals_get'}) {
my $action_config = Storable::dclone($action_template); my $action_config = Storable::dclone($action_template);
$action_config->{Chained} = 'item_base_journal'; $action_config->{Chained} = 'handle_item_base_journal';
$action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME; $action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME;
$action_config->{Args} = 0; $action_config->{Args} = 0;
$action_config->{Method} = 'GET'; $action_config->{Method} = 'GET';
push(@result,$action_config,'journals_get'); push(@result,$action_config,'handle_journals_get');
} }
if (exists $journal_actions_found{'journals_options'}) { if (exists $journal_actions_found{'handle_journals_options'}) {
my $action_config = Storable::dclone($action_template); my $action_config = Storable::dclone($action_template);
$action_config->{Chained} = 'item_base_journal'; $action_config->{Chained} = 'handle_item_base_journal';
$action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME; $action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME;
$action_config->{Args} = 0; $action_config->{Args} = 0;
$action_config->{Method} = 'OPTIONS'; $action_config->{Method} = 'OPTIONS';
push(@result,$action_config,'journals_options'); push(@result,$action_config,'handle_journals_options');
} }
if (exists $journal_actions_found{'journals_head'}) { if (exists $journal_actions_found{'handle_journals_head'}) {
my $action_config = Storable::dclone($action_template); my $action_config = Storable::dclone($action_template);
$action_config->{Chained} = 'item_base_journal'; $action_config->{Chained} = 'handle_item_base_journal';
$action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME; $action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME;
$action_config->{Args} = 0; $action_config->{Args} = 0;
$action_config->{Method} = 'HEAD'; $action_config->{Method} = 'HEAD';
push(@result,$action_config,'journals_head'); push(@result,$action_config,'handle_journals_head');
} }
if (exists $journal_actions_found{'journalsitem_get'}) { if (exists $journal_actions_found{'handle_journalsitem_get'}) {
my $action_config = Storable::dclone($action_template); my $action_config = Storable::dclone($action_template);
$action_config->{Chained} = 'item_base_journal'; $action_config->{Chained} = 'handle_item_base_journal';
$action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME; $action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME;
$action_config->{Args} = 1; $action_config->{Args} = 1;
$action_config->{Method} = 'GET'; $action_config->{Method} = 'GET';
push(@result,$action_config,'journalsitem_get'); push(@result,$action_config,'handle_journalsitem_get');
} }
if (exists $journal_actions_found{'journalsitem_options'}) { if (exists $journal_actions_found{'handle_journalsitem_options'}) {
my $action_config = Storable::dclone($action_template); my $action_config = Storable::dclone($action_template);
$action_config->{Chained} = 'item_base_journal'; $action_config->{Chained} = 'handle_item_base_journal';
$action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME; $action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME;
$action_config->{Args} = 1; $action_config->{Args} = 1;
$action_config->{Method} = 'OPTIONS'; $action_config->{Method} = 'OPTIONS';
push(@result,$action_config,'journalsitem_options'); push(@result,$action_config,'handle_journalsitem_options');
} }
if (exists $journal_actions_found{'journalsitem_head'}) { if (exists $journal_actions_found{'handle_journalsitem_head'}) {
my $action_config = Storable::dclone($action_template); my $action_config = Storable::dclone($action_template);
$action_config->{Chained} = 'item_base_journal'; $action_config->{Chained} = 'handle_item_base_journal';
$action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME; $action_config->{PathPart} //= API_JOURNAL_RESOURCE_NAME;
$action_config->{Args} = 1; $action_config->{Args} = 1;
$action_config->{Method} = 'HEAD'; $action_config->{Method} = 'HEAD';
push(@result,$action_config,'journalsitem_head'); push(@result,$action_config,'handle_journalsitem_head');
} }
if ((scalar @result) > 0) { if ((scalar @result) > 0) {
push(@result,{ push(@result,{
Chained => '/', Chained => '/',
PathPart => $path_part, PathPart => $path_part,
CaptureArgs => 1, CaptureArgs => 1,
},'item_base_journal'); },'handle_item_base_journal');
@result = reverse @result; @result = reverse @result;
return \@result; return \@result;
} }
@ -181,6 +181,38 @@ sub get_api_journal_query_params {
}, },
second => sub { }, second => sub { },
}, },
},{
param => 'username',
description => 'Filter for journal items by the name of the user who performed the operation',
query => {
first => sub {
my $q = shift;
{ 'username' => $q };
},
second => sub { },
},
},{
param => 'from',
description => 'Filter for journal items recorded after or at the specified time stamp',
query => {
first => sub {
my $q = shift;
my $dt = NGCP::Panel::Utils::DateTime::from_string($q);
return { 'timestamp' => { '>=' => $dt->epoch } };
},
second => sub { },
},
},{
param => 'to',
description => 'Filter for journal items recorded before or at the specified time stamp',
query => {
first => sub {
my $q = shift;
my $dt = NGCP::Panel::Utils::DateTime::from_string($q);
return { 'timestamp' => { '<=' => $dt->epoch } };
},
second => sub { },
},
}); });
return \@params; return \@params;
} }

Loading…
Cancel
Save