#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Text::ASCIITable;
use Perun::Agent;
use Perun::Common qw(printTable getSortingFunction);

sub help {
	return qq{
Find NotifRegex by id. Id is required field.
------------------------
Available options:
 --NotifRegexId         | -i NotifRegex id
 --batch                | -b batch
 --help                 | -h prints this help

};
}

our $batch;
my $regexId;
GetOptions ("help|h"   => sub {
		print help();
		exit 0;
	}, "batch|b"       => \$batch,
	"NotifRegexId|i=i" => \$regexId) || die help();

# Check options
unless (defined($regexId)) { die "ERROR: PerunNotifRegex: Id is required \n";}

my $agent = Perun::Agent->new();
my $notifAgent = $agent->getNotificationsAgent();

my $object = $notifAgent->getPerunNotifRegexById( id => $regexId );

#output
if (defined($object->getId)) {
	my $sortingFunction = getSortingFunction("getName", 1);
	printTable($sortingFunction, $object);
} else { die "NotifRegex with id $regexId does not exist \n" }
