#!/usr/bin/perl -w

use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Perun::Agent;
use Perun::Common qw(printMessage);

sub help {
	return qq{
	Adds PERUNADMIN role to the user. User id is required.
	------------------------------------
	Available options:
	--userId         | -u user id
	--batch          | -b batch
	--help           | -h prints this help
	};
}

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

# Check options
unless (defined($userId)) { die "ERROR: userId is required \n";}
my $role = "PERUNADMIN";

my $agent = Perun::Agent->new();
my $authzResolverAgent = $agent->getAuthzResolverAgent;

$authzResolverAgent->setRole( user => $userId, role => $role );

printMessage("User Id: $userId became PERUNADMIN", $batch);
