create new api/cli function to set event on progress

This commit is contained in:
marcos 2020-06-03 15:56:19 +02:00
parent 7676852bd0
commit e270776a01
2 changed files with 27 additions and 5 deletions

View File

@ -16027,12 +16027,12 @@ function api_get_event_mcid($server_id, $console_event_id, $trash2, $returnType)
* Function to set events in progress status. * Function to set events in progress status.
* *
* @param [int] $event_id Id event (Node or Meta). * @param [int] $event_id Id event (Node or Meta).
* @param [int] $server_id Id node event in tmetaconsole_event. * @param [int] $server_id Id node event in tmetaconsole_event (optional).
* @param [string] $trash2 don't use. * @param [string] $trash2 don't use.
* @param [string] $returnType * @param [string] $returnType
* *
* Example * Example
* http://172.17.0.1/pandora_console/include/api.php?op=set&op2=event_in_progress&return_type=json&id=0&id2=0&apipass=1234&user=admin&pass=pandora * http://127.0.0.1/pandora_console/include/api.php?op=set&op2=event_in_progress&return_type=json&id=0&id2=0&apipass=1234&user=admin&pass=pandora
* *
* @return void * @return void
*/ */
@ -16045,8 +16045,8 @@ function api_set_event_in_progress($event_id, $server_id, $trash2, $returnType)
'tmetaconsole_event', 'tmetaconsole_event',
['estado' => 2], ['estado' => 2],
[ [
'id_source_event' => $event_id,
'server_id' => $server_id, 'server_id' => $server_id,
'id_evento' => $event_id,
] ]
); );
if ($event !== false) { if ($event !== false) {

View File

@ -243,6 +243,8 @@ sub help_screen{
help_screen_line('--duplicate_visual_console', '<id> <times> [<prefix>]', 'Duplicate a visual console'); help_screen_line('--duplicate_visual_console', '<id> <times> [<prefix>]', 'Duplicate a visual console');
help_screen_line('--export_json_visual_console', '<id> [<path>] [<with_element_id>]', 'Creates a json with the visual console elements information'); help_screen_line('--export_json_visual_console', '<id> [<path>] [<with_element_id>]', 'Creates a json with the visual console elements information');
print "\nEVENTS\n\n" unless $param ne '';
help_screen_line('--event_in_progress', '<id_event> <id_node>', 'Set event in progress');
print "\n"; print "\n";
exit; exit;
@ -7676,6 +7678,9 @@ sub pandora_manage_main ($$$) {
elsif ($param eq '--reset_agent_counts') { elsif ($param eq '--reset_agent_counts') {
param_check($ltotal, 1, 0); param_check($ltotal, 1, 0);
cli_reset_agent_counts(); cli_reset_agent_counts();
}elsif ($param eq '--event_in_progress') {
param_check($ltotal, 2, 0);
cli_event_in_progress();
} }
else { else {
print_log "[ERROR] Invalid option '$param'.\n\n"; print_log "[ERROR] Invalid option '$param'.\n\n";
@ -8325,3 +8330,20 @@ sub cli_reset_agent_counts() {
print "$result \n\n "; print "$result \n\n ";
} }
##############################################################################
# Set an event in progress.
# Related option: --event_in_progress
##############################################################################
sub cli_event_in_progress() {
my ($event_id, $server_id) = @ARGV[2..3];
# Call the API.
my $result = api_call(
$conf, 'set', 'event_in_progress', $event_id, $server_id
);
print "\n$result\n";
}